Repository navigation
Conversation
buildRawContent()/buildAttributesForStopNode() in fxb.js (plain-object mode) and getRawContent()/attr_to_str_raw() in orderedJs2Xml.js (preserveOrder mode) wrote element and attribute names to the output without routing them through resolveName(). When sanitizeName is configured, names inside a stopNode subtree therefore bypassed sanitization entirely, allowing quote injection in attribute names and '>'/'"' break-out in tag names to forge document structure. Route all stopNode name paths through resolveName so sanitizeName applies uniformly. Raw VALUE handling for stopNodes is unchanged. 8 regression specs added (4 plain-object, 4 preserveOrder). 178 specs, 0 failures.
hicay
force-pushed
the
fix-sanitizename-stopnode-bypass
branch
from
November 13, 2026 18:58
2e494ea to
af295a4
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
sanitizeNameis not applied to tag and attribute names inside stopNodes — in both build modes:fxb.js(plain-object mode):buildRawContent()andbuildAttributesForStopNode()wrote names to the output without routing them throughresolveName().orderedJs2Xml.js(preserveOrdermode):getRawContent()andattr_to_str_raw()did the same, andattr_to_str()explicitly skipped name sanitization whenisStopNodewas true.So when a
sanitizeNamecallback is configured, names inside a stopNode subtree bypass sanitization entirely, allowing quote injection in attribute names and>break-out in tag names to forge document structure.Before (v1.3.2)
The same payload on a non-stopNode path is correctly sanitized (
a_href__javascript_x_), so the stopNode path is an inconsistent bypass of the security control.After
All stopNode name paths now go through
resolveName():fxb.js:
buildRawContent(obj, depth, matcher, qNameValidator)— element names are resolved before use;matcher/qNameValidatorpropagate to nested calls.buildAttributesForStopNode(obj, matcher, qNameValidator)— attribute names are resolved in both theattributesGroupNamebranch and the individual-attribute branch.orderedJs2Xml.js:
getRawContent(arr, options, depth, matcher, qNameValidator)— nested element names are resolved; parameters propagate to nested calls.attr_to_str_raw(attrMap, options, matcher, qNameValidator)— attribute names are resolved.attr_to_str()— attribute names are now always resolved for stopNodes too (raw VALUE handling is unchanged).Backwards compatibility: all new parameters default to
null, in which case behavior is unchanged (raw name), so direct callers of these internal functions keep working.Tests
8 new regression specs in
spec/sanitize_spec.js— 4 for plain-object mode, 4 forpreserveOrdermode, each covering tag-name sanitization, attribute-name sanitization (on the stopNode itself and nested), and no-op for valid names. Full suite: 178 specs, 0 failures.Fixes #34