Small, dependency-free tools for the bug class that keeps paying: a server value interpolated into a nonce'd inline script. Everything here is stdlib Python / POSIX shell, read-only, and safe to run against bundles you are authorized to examine.
security-toolkit/
nonce_scan.py # find nonce-laundering + script-injection candidates
bundle_fetch.sh # reproducible, rate-limited bundle fetch
assets/demo.svg
manifest.example.txt
README.md
LICENSE
git clone https://github.com/cyberd4ch/security-toolkit
cd security-toolkit
# scan a directory of bundles
python3 nonce_scan.py path/to/bundles --min-severity MED
# machine-readable
python3 nonce_scan.py path/to/bundles --json
# fetch authorized assets from a manifest (name|url per line)
cp manifest.example.txt manifest.txt # edit it first
./bundle_fetch.sh manifest.txt out/Walks .js/.mjs/.cjs/.html files and reports the ingredients of a
nonce-laundering bug:
| Kind | What it means |
|---|---|
nonce-copy (HIGH) |
Code copies an existing script[nonce] onto a new element (setAttribute("nonce", …), .nonce = …, querySelector('…[nonce]')). The laundering primitive. Often benign (style/webpack chunks) — triage it. |
script-literal-interpolation (HIGH/MED) |
A template literal both interpolates ${…} and builds a <script> / window.location / innerHTML string. The dangerous shape. |
sink:* (MED/HIGH) |
innerHTML, insertAdjacentHTML, document.write, srcdoc, eval, new Function with interpolation nearby. |
trusted-types-* (INFO/LOW) |
Whether a Trusted Types policy exists and whether require-trusted-types-for is enforced. |
csp-nonce-reference (INFO) |
The page references a csp-nonce meta. |
--json emit JSON instead of text
--min-severity LEVEL INFO | LOW | MED | HIGH (default LOW)
Exit code is 0 when the scan completes (findings or not), 2 on bad input.
nonce_scan: 11 file(s), 7 finding(s)
== home.desktop.fe5d475a.js
[HIGH] script-literal-interpolation @ 2:20127
` ... var deeplink = '${e}'; ... `
== viewability.js
[HIGH] nonce-copy @ 2:1518
... t && e.setAttribute("nonce", t) ...
- It does not fetch anything.
- It does not decide exploitability. It finds primitives; you still have to prove an attacker-controlled source reaches a nonce'd script.
- It does not understand bundler semantics, so expect false positives (stylesheet nonces, webpack chunk nonces). Treat HIGH as "look here", not "vulnerability".
On a real home bundle it flags the component that builds
var deeplink = '${e}' inside a nonce'd script, and the viewability.js
g()/w() nonce-copy helpers. On a marketing site with no CSP nonce it finds
nothing — correctly, because that surface has nothing to launder.
A template for reproducible recon: one request per URL, sleep 2, fixed UA,
saved names, SHA-256 afterwards.
./bundle_fetch.sh manifest.txt out/Manifest format:
name.js|https://in-scope.example/assets/name.js
page.html|https://in-scope.example/
Keep the list short and only include hosts inside the program's live scope.
MIT — see LICENSE. Use it in engagements, ship it, sell it; just keep the notice.
Only run this against assets you are authorized to test, within the program's live scope, with accounts you own. A scan finding is not a report; a demonstrated impact is.