-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gitea markdown not sanitised (links can contain API URLs) #4596
Comments
AddendumSame bug for images. Note that the user does not even has to click the image, loading the page will execute the injected API code. Testcase: create README.md containing an image with URL to API endpoint, log in, visit repository page, do something else and realise that gitea has logged you out:
|
Yes this should be cleaned up but no harming actions can be done as GET requests are only for getting data not doing actions (except for logout url) |
@lafriks: Are you sure? The team/org router go suggested otherwise; logout was used above only as harmless example |
Maybe some collaboration possible: gogs/gogs#5355 (comment) |
The two issues seem distinct, would need distinct fixes, if solved via sanitizing as discussed there: removing/sanitizing HTML tags from markdown wouldn't fix this one. Markdown links need special treatment unless URLs and images are completely forbidden, which is probably not desirable |
I'd say, actions that can change system states, such as logout or star, shall be POST only. |
@msg7086: it‘s about the missing CSRF protection token, and that user-provided content is executed/rendered in the same DOM context as the gitea API calls. CSRF on GET is technically possible, albeit sometimes considered bad practice (one might argue that token is a bit less exposed when passed in body instead of header). Unfortunately it seems that the macaron CSRF checker does not support CSRF on GET (is this correct? I might be wrong here). Sending post from simple link URL is possible via jquery $.post(...). This could possibly be used as minimally invasive hotfix: Replace all GET API actions fav/watch/logout/org.action/etc by href="javascript:$.post(url, CSRF-token-string)", and do not accept GET anywhere in the gitea/router except for landing pages and repo-over-http. |
Thanks for pointing out. Yes CSRF is also needed in this particular case. Just that my reply was focusing on best practices about HTTP verbs (e.g. RESTful style) and not about XSS protection. Cheers |
@lafriks : related, with example: gogs/gogs#5367 |
One more to check, this one had affected gitlab too:
|
[x]
):Description
Create README.md or other markdown file containing a link to some gitea API endpoint:
Problem
API endpoints are normal GET requests, not protected by auth (normal session id used).
Markdown is rendered in normal (non-sandboxed) DOM.
Potential solutions
ideally all three
The text was updated successfully, but these errors were encountered: