Security hardening: 4 MEDIUM fixes (content_types determinism, NaN, SVG gaps, font cache) - #20
Merged
Merged
Conversation
…aps, font caching C1: [Content_Types].xml was non-deterministic (HashMap iteration order is randomized per process). Fixed by sorting defaults/overrides keys before serializing, ensuring byte-for-byte stability across runs. C2: parse_attr_f64 accepted NaN/Infinity from OOXML attributes, producing malformed XML on save. Fixed by rejecting non-finite values. C3: SVG sanitizer gaps — protocol-relative URLs (//evil.example), <style> elements, inline style attributes, and entity-bypass in URL values. All now rejected. Added 3 new tests. C4: Font embedding re-encoded each font per-alias per-render (~10MB of base64 per export where ~2.3MB sufficed). Fixed with OnceLock caching — each font is base64-encoded once and reused.
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
Follow-up to PR #19 (CRITICAL+HIGH fixes). Addresses 4 MEDIUM issues from the full audit.
Fixes
C1: [Content_Types].xml non-deterministic
crates/slides-pptx/src/package.rs— HashMap iteration order was randomized per process, violating byte-for-byte preservation. Fixed by sorting keys before serialization.C2: parse_attr_f64 accepts NaN/Infinity
crates/slides-pptx/src/load.rs—NaN/inffrom OOXML attributes produced malformed XML on save. Fixed by rejecting non-finite values.C3: SVG sanitizer gaps
crates/slides-media/src/lib.rs— Three bypasses closed://evil.example/x) now rejected<style>elements now rejected (CSS@import/url()vectors)styleattributes now rejectedC4: Font re-encoding cache
crates/slides-render/src/lib.rs— Each font was base64-encoded per-alias per-export (~10MB redundant base64). Fixed withOnceLockcaching — each font encoded once and reused.Test results
npm run check: 0 errors, 0 warnings.scripts/verify-local.sh: green.scripts/verify-public-release.sh: green.