Skip to content

fix(security): harden redirect validation and sanitizer blocklist (NOJS-289)#295

Open
ErickXavier wants to merge 2 commits into
mainfrom
fix/NOJS-289-hardening
Open

fix(security): harden redirect validation and sanitizer blocklist (NOJS-289)#295
ErickXavier wants to merge 2 commits into
mainfrom
fix/NOJS-289-hardening

Conversation

@ErickXavier

Copy link
Copy Markdown
Collaborator

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).

  • H4 — _isSafeRedirect accepts protocol-relative //host: A redirect target of //evil.com was treated as safe because path.startsWith("/") matched. Browsers resolve //host to a cross-origin navigation. Fixed by rejecting values starting with //.
  • H6 — Sanitizer blocklist omits rawtext tags: noembed, noframes, and plaintext switch the HTML parser into rawtext/plaintext mode and can smuggle un-sanitized content. Added to _BLOCKED_TAGS.

Test plan

  • New router test: //evil.com redirect blocked (warns "not a relative path")
  • New router test: \\evil.com redirect blocked (already rejected, confirms backslash not accepted)
  • New sanitizer test: <plaintext> wrapping payload is stripped
  • New sanitizer test: <noembed> wrapping script payload is stripped
  • New sanitizer test: <noframes> wrapping event-handler payload is stripped
  • All 5 tests fail without the fix, pass with it (verified via git stash round-trip)
  • Full suite: 42 suites, 2200 tests, all passing
  • Build: node build.js succeeds, dist drift is only the two logic additions

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant