Skip to content

fix(audit): CDN worker path-traversal guard + animation-blocks security JSDoc#26

Merged
whykusanagi merged 1 commit into
mainfrom
fix/audit-hardening
May 19, 2026
Merged

fix(audit): CDN worker path-traversal guard + animation-blocks security JSDoc#26
whykusanagi merged 1 commit into
mainfrom
fix/audit-hardening

Conversation

@whykusanagi
Copy link
Copy Markdown
Owner

Summary

Two non-blocking findings from the pre-publish audit (PR #25 follow-up):

1. CDN worker path-traversal guard

cdn-worker/index.js — added a guard that rejects request paths containing .. segments or percent-encoded variants (%2e%2e in any case mix) before constructing the rewritten R2 URL. Returns HTTP 400 with a "path traversal not permitted" body.

Risk assessment: Cloudflare's URL parser already normalizes .. segments at the platform level before the request reaches the Worker — the bucket only holds public content anyway — so this is genuinely defense-in-depth, not a vulnerability fix. Worker has been redeployed (Version ID 349fceb2-4eb0-4fc2-b3d0-054ef3431bfd).

2. animation-blocks security JSDoc

src/lib/animation-blocks.jsTerminalBoot and SystemDiagnostic classes both pass options.lines[i] directly into element.innerHTML. Documented as @param {string[]} (developer-supplied, trusted) but the contract wasn't explicit. Added ⚠️ SECURITY: JSDoc notes calling out that lines render as raw HTML and callers must escape HTML entities if content comes from user input.

No code behavior change — purely documentation.

Test plan

  • Worker redeployed successfully (wrangler deploy --config cdn-worker/wrangler.toml)
  • npm test — 166/166 pass (no behavior change in src/)
  • Live CDN spot-check: real @latest URLs still return 200, path-traversal probes return 404 (Cloudflare normalizes before reaching the guard — guard is defensive)

🤖 Generated with Claude Code

…warnings

From the pre-publish audit's two non-blocking notes:

1. cdn-worker/index.js — reject paths containing '..' segments or
   percent-encoded variants (%2e%2e in any case combination) before
   the R2 rewrite. Defense-in-depth: Cloudflare's URL parser already
   normalizes most '..' segments at the platform level, but the guard
   protects against edge cases where normalization behavior changes.
   Worker redeployed (Version ID: 349fceb2-4eb0-4fc2-b3d0-054ef3431bfd).

2. animation-blocks.js — add SECURITY @warning JSDoc to TerminalBoot
   and SystemDiagnostic options.lines. Both classes render lines
   directly into element.innerHTML, which is safe when lines come from
   the developer (the documented use case) but a footgun if a downstream
   consumer ever passes user-controlled input. JSDoc now states the
   contract explicitly + suggests HTML entity escaping for UGC paths.
@whykusanagi whykusanagi merged commit e4bc49a into main May 19, 2026
1 check was pending
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