fix: guard filterXSSWithResult option copy against prototype pollution - #301
Open
mahirhir wants to merge 1 commit into
Open
fix: guard filterXSSWithResult option copy against prototype pollution#301mahirhir wants to merge 1 commit into
mahirhir wants to merge 1 commit into
Conversation
leizongmin#298 added hasOwnProperty guards to every config-copy loop. The filterXSSWithResult helper added in leizongmin#297 has its own option-copy loop that was missed, so a polluted Object.prototype still injects config through that entry point. Mirror the shallowCopyObject guard.
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.
#298 added
Object.prototype.hasOwnPropertyguards to every place the library copies config out of afor...inloop (shallowCopyObject,keysToLowerCase, theFilterXSSoption handling and theexportssetup) so a pollutedObject.prototypecan't inject sanitizer config.filterXSSWithResult, added in #297 in the same release, copies the caller'soptionswith its ownfor...inloop that didn't get that guard:It copies inherited enumerable properties onto
optsas own properties, so they survive the now-guardedshallowCopyObjectinsideFilterXSSand become the effective config. A polluted prototype therefore still reaches the sanitizer through this entry point when an options object is passed.Repro on
master(assumingObject.prototypewas polluted elsewhere in the process, the same threat model as #298):The fix mirrors
shallowCopyObject:This is the same threat model as #298 (hardening against an externally polluted
Object.prototype, not a new vector from HTML input) — it just completes that fix for the one config-copy path that was missed.Added a regression test in
test/test_filter_xss_with_result.js(fails before this change, passes after) and rebuiltdist/to match. Full test suite (43 tests) passes.