fix: HTML-escape all user data in slide generator to prevent stored XSS#274
Open
TemaDeveloper wants to merge 1 commit intonextlevelbuilder:mainfrom
Open
fix: HTML-escape all user data in slide generator to prevent stored XSS#274TemaDeveloper wants to merge 1 commit intonextlevelbuilder:mainfrom
TemaDeveloper wants to merge 1 commit intonextlevelbuilder:mainfrom
Conversation
Add html.escape() to all 46 user-controlled data.get() calls across all 7 slide generator functions (title, problem, solution, metrics, chart, testimonial, cta) and the deck title. Add URL scheme validation for cta_url href to block javascript: URI injection. Closes nextlevelbuilder#247
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
Fixes the Stored XSS vulnerability (CVSS 8.1) in
generate-slide.pyreported in #247.data.get()calls across all 7 slide generator functions usinghtml.escape()— prevents<script>,<img onerror>, and<iframe>injection into generated HTMLcta_urlin the CTA slide — blocksjavascript:URI injection by only allowinghttp://,https://,#, and/schemes<title>in the template rendering to prevent metadata injectionvaluetoint()in the style attribute to prevent CSS injection via theheightpropertyApproach
Added two small helpers at the top of the file:
_e(value, default)— wrapshtml.escape(str(...))for all content injection points_safe_url(url, default)— validates URL scheme before escaping forhrefattributesTesting
Verified with the exact PoC payload from #247:
<script>alert('XSS')</script>in title → rendered as escaped text<img src=x onerror=alert(1)>in badge → rendered as escaped textjavascript:alert(document.domain)in cta_url → replaced with#Closes #247