Stored XSS and HTML injection from markdown in kiwitcms/kiwi
Reported on
Nov 2nd 2022
Description
Stored XSS, also known as persistent XSS, is the more damaging of the XSS. It occurs when a malicious script is injected directly into a vulnerable web application. Due to a sanitization problem it is possible to perform both a Stored XSS and an HTML injection. Thanks to this attack it is possible to disable the history page making it unusable (for example I created a transparent page above with an infinite redirect), or it is possible to create a stored XSS.
The problem is that the markdown input is sanitized in the TestPlan, but it is not sanitized by the history page. On the history page it will run.
Proof of Concept
1 - Insert one of the following payloads into a Test Plan.
2 - Go to the history
Stored XSS:
<a href="https://evil.com/users/signin" onmouseover="confirm(document.cookie)" style="position: fixed; top: 0; right: 0; width: 10000px; height: 10040px; opacity:0.00001;">foo</a>
Stored HTML Injection - Disable the history page:
<a href='https://evil.com/users/signin' style='position: fixed; top: 0; right: 0; width: 10000px; height: 10040px; opacity:0.00001;'>foo</a>
POC Video (Payload execution):
https://drive.google.com/file/d/1n7ZSrOOIb47vZro4ck2-hPRkzbSiX8CF/view?usp=sharing
Update:
I made a video where a basic user (not an admin) creates a testplan. When Admin goes into the history of the testplan created by the basic user, the XSS will appear (stored blind XSS)
POC:
https://drive.google.com/file/d/1FlGvATGWKWXXoMB6h2Z-JOX1gVhkssx5/view?usp=share_link
Impact
Stored XSS to run malicious javascript.
- HTML Injection to perform a UI redressing attack (clickjacking)
- HTML injection which disables the use of the history page
I made a video where a basic user (not an admin) creates a testplan. When Admin goes into the history of the testplan created by the basic user, the XSS will appear (stored blind XSS)
POC:
https://drive.google.com/file/d/1FlGvATGWKWXXoMB6h2Z-JOX1gVhkssx5/view?usp=share_link
Patch in https://github.com/kiwitcms/Kiwi/pull/2970. Will update this bounty once we have packaged an updated version in the next few days.
@admin this is my first time using this platform. Could I know if I will be able to have a cve being a framework with more than a million downloads? Can I possibly report the cve a miter? Plus I don't understand how it works, will I have a bounty for vulnerability?
Hi Antonio, welcome! Our systems recognise popular repos and will ask the maintainer to assign a CVE automatically as soon as they're ready to publish your vulnerability. Unfortunately, this report doesn't have a bounty associated with it.
To go to MITRE you must be a CNA. In our case, we put that ability in the hands of the maintainer.
Hope that helps! Feel free to directly message us if anything else is unclear :)
perfect, thank you so much for the clarification. I will look forward to the recognition of CVE.
@maintainer Hi, I saw that a new software version has been released dated 09 November and a vulnerability fix has been implemented. In the changelog it says "Sanitize HTML input when generating history diff to prevent XSS attacks". I would like to know from the maintainer if it was possible now that it has been fixed to get the CVE and make the vulnerability public. https://kiwitcms.readthedocs.io/en/latest/changelog.html
@admin for the admin, I have no idea if the maintainer is able to see this message or not, if not I would appreciate if you could ask for updates, as the patch has now been released and the software up to date. I would like to know less if the CVE will be released in the future because I don't quite understand if the mainteiner wants to release it or not.
Hi again Antonio! Could you please nudge them to publish it and assign a CVE via their security.md email?
Hi, I wrote a mail to the team as you suggested, thanks a lot for your reply :)
@admin the team replied to me with: "You can make the vulnerability public, but we don't know how to create a CVE number because we've not done this before."
What should i tell him? Could you explain to me how they should do it or possibly contact them? For me it is not a problem to act as an intermediary.
For now I answered like this, let me know what to do: "I reported the vulnerability from huntr.dev. They have the necessary permissions to let you perform the CVE request and they replied to me with the following text: "To go to MITRE you must be a CNA. In our case, we put that ability in the hands of the maintainer. (meaning kiwitcms maintainer)". I contacted their team again, asking about the CVE assignment process so you can go through it, it shouldn't be anything complicated, I think it takes a few minutes and filling out an online form, and for me as a security analyst it's a great reason to be proud if you could do it. If you recognize me the CVE, I would analyze more versions of your software for free, and like me other cyber security analysts who believe in open source would do it. I will contact you with the info on how to do it or eventually they will contact you (huntr.dev). Since the framework has over a million downloads and huntr.dev gives the ability for you as a team to assign a CVE, and since the vulnerability was quite severe I'd like a CVE code to be assigned.
hope to hear from you soon, have a nice day Antonio Rocco Spataro"