Skip to content
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

Format error messages as text to avoid XSS vulnerabilities #2161

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

artwyman
Copy link
Member

Mark error messages from api.zupass.org as text to ensure any <script> tags in them are not executed. Those could come directly from user input.

This was reported by Andrew (a different one, not me) at Devcon. The risk here is low since api.zupass.org is a different domain with no sensitive data in cookies or local storage, but still good to clean up the risk that users could be tricked into something dangerous.

Two test URLs which demonstrate script injection via URL parameters on api.zupass.org:

https://api-staging.zupass.org/sync/v3/load?blobKey=%3Cscript%3Ealert(%22andrewwashere%22)%3C%2fscript%3E

https://api.zupass.org/generic-issuance/api/feed/19ffc405-742f-4485-a831-2ea7e987666d/zu-thailand%3Cscript%3Ealert(%60Cookies%3A%20%24%7Bdocument.cookie%7D%2C%20LocalStorage%3A%20%24%7BJSON.stringify(localStorage)%7D%60)%3C%2Fscript%3E

Here are versions of those URLs which demonstrate the issue on my local test server:

http://localhost:3002/sync/v3/load?blobKey=%3Cscript%3Ealert(%22andrewwashere%22)%3C%2fscript%3E

http://localhost:3002/generic-issuance/api/feed/d16ddd24-0155-4244-8799-80f2c4afdc5f/0%3Cscript%3Ealert(%60Cookies%3A%20%24%7Bdocument.cookie%7D%2C%20LocalStorage%3A%20%24%7BJSON.stringify(localStorage)%7D%60)%3C%2Fscript%3E

Attn: @antimatter15 who submitted an initial version of this in #2159 .

@artwyman artwyman requested review from ichub and rrrliu November 12, 2024 07:25
@artwyman artwyman self-assigned this Nov 12, 2024
@artwyman artwyman mentioned this pull request Nov 12, 2024
@artwyman artwyman added this pull request to the merge queue Nov 12, 2024
Merged via the queue into main with commit b34222c Nov 12, 2024
1 check passed
@artwyman artwyman deleted the artwyman/xss-errors branch December 10, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants