{{ message }}
Escape ME_DATA JSON in script block and add HSTS#442
Open
martinmain93 wants to merge 1 commit into
Open
Conversation
Fixes a stored XSS: app_html injects MeView.get_me_data() into a <script> block via json.dumps(), which does not escape <, >, or &. A repo's emailmap contains attacker-influenced sender email addresses, so a crafted from_email could break out of the script element and execute in a repo admin's browser. Escape <, >, & to their \uXXXX forms before injection (U+2028/U+2029 are already escaped by json.dumps' ensure_ascii default), matching Django's json_script scheme. Also add HSTS response headers to production (SECURE_HSTS_SECONDS=1y, includeSubDomains, preload), which were previously unset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
68c0887 to
d4f4e41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Two security fixes for
fire.fundersclub.com, both surfaced by a recent pentest:1. Stored XSS via unescaped JSON in a
<script>block (the high-severity one)app_htmlinjectsMeView.get_me_data()into a<script>block usingjson.dumps(), which does not escape<,>, or&. A repository'semailmap_setcontains attacker-influenceable sender email addresses (from_email), so a crafted address could break out of the script element and execute in a repo admin's browser when they load/repos.Fix: escape
<,>,&to their\uXXXXforms before injection (U+2028/U+2029 are already escaped byjson.dumps'ensure_asciidefault), matching Django'sjson_scriptscheme. This neutralizes the payload regardless of who plants it.2. Missing HSTS in production
firebot/settings/prod.pysetSECURE_SSL_REDIRECTand secure cookies but never set HSTS headers. AddedSECURE_HSTS_SECONDS(1 year),includeSubDomains, andpreload.Notes
associate-emailPOST authorization. After investigation we deliberately left it asis_authenticated-only: that endpoint is designed for external (non-admin) senders to self-link their email, so requiring repo-admin would break the feature. The XSS escaping above is the actual remediation; the residual identity-binding weakness is low severity and accepted.app_html; a regression test asserting a</script>payload inME_DATAis escaped would be a good follow-up.🤖 Generated with Claude Code