Security hardening: XSS, decompression bombs, and input validation#3
Draft
Security hardening: XSS, decompression bombs, and input validation#3
Conversation
… type annotations Co-authored-by: ljack <3129138+ljack@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Conduct security review for quality improvements
Security hardening: XSS, decompression bombs, and input validation
Mar 14, 2026
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.
Security audit identified several medium/low severity issues across the JS browser app and Python CLI. All pending items from Task 12 are resolved.
XSS —
docs/app.jssetInfo()andsetSourceFromCanvas()both injected user-controlled values (file names) viainnerHTML. Replaced with safe DOM API calls so filenames are always plain text.Encoding consistency —
docs/app.jsencodeIndices()had asorted.length > 100guard on the bitmap path that never existed in the Python encoder, causing the two implementations to disagree on encoding choice for small index sets. Guard removed.Python decompression bomb —
switching_compress.pydecompress()calledzlib.decompress()unbounded. Added_safe_decompress()usingdecompressobj.decompress(data, max_length)capped at 256 MB (matching the JS-side limit already in place), aborting ifunconsumed_tailis non-empty.Python input validation & types —
switching_compress.pycompress()now raisesValueErrorearly forlayers < 1,dct_ratio ∉ (0, 1],max_iter < 1target_psnrtyped asOptional[float]instead offloat = None; return types added tocompress()anddecompress()📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.