fix(security): harden redirect validation and sanitizer blocklist (NOJS-289)#295
Open
ErickXavier wants to merge 2 commits into
Open
fix(security): harden redirect validation and sanitizer blocklist (NOJS-289)#295ErickXavier wants to merge 2 commits into
ErickXavier wants to merge 2 commits into
Conversation
A redirect value of "//evil.com" was accepted as safe because it starts with "/". Browsers resolve protocol-relative URLs to a cross-origin navigation. Add an explicit check to reject values starting with "//". Defense-in-depth fix from the 2026-07 security audit (NOJS-289 H4).
These always-rawtext tags switch the HTML parser into rawtext/plaintext mode and can smuggle un-sanitized content past the DOMParser sanitizer. Add them to _BLOCKED_TAGS. Includes rebuilt dist/. Defense-in-depth fix from the 2026-07 security audit (NOJS-289 H6).
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
Two defense-in-depth fixes from the 2026-07 security audit (NOJS-289, PR #294 report). Both are confirmed non-exploitable but worth shipping as v1.20.1 hardening (EPIC NOJS-283).
_isSafeRedirectaccepts protocol-relative//host: A redirect target of//evil.comwas treated as safe becausepath.startsWith("/")matched. Browsers resolve//hostto a cross-origin navigation. Fixed by rejecting values starting with//.noembed,noframes, andplaintextswitch the HTML parser into rawtext/plaintext mode and can smuggle un-sanitized content. Added to_BLOCKED_TAGS.Test plan
//evil.comredirect blocked (warns "not a relative path")\\evil.comredirect blocked (already rejected, confirms backslash not accepted)<plaintext>wrapping payload is stripped<noembed>wrapping script payload is stripped<noframes>wrapping event-handler payload is strippednode build.jssucceeds, dist drift is only the two logic additions