Skip to content

fix(security): constrain WHIP/WHEP path params to prevent log injection - #306

Open
birme wants to merge 1 commit into
mainfrom
security/287-whip-whep-log-injection
Open

fix(security): constrain WHIP/WHEP path params to prevent log injection#306
birme wants to merge 1 commit into
mainfrom
security/287-whip-whep-log-injection

Conversation

@birme

@birme birme commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The username, lineId and productionId path params on POST /api/v1/whip/:productionId/:lineId/:username and the WHEP equivalent were URL-decoded by Fastify and interpolated directly into log messages with no sanitization, allowing newline (%0a), carriage-return (%0d) and ANSI-escape (%1b[...) injection to forge or corrupt log entries.
  • Added restrictive TypeBox pattern constraints on both routes: numeric-only ^[0-9]+$ for productionId and lineId (matching the existing convention in api_productions.ts, and correct since line/production ids are generated as numeric strings), and ^[\w .-]{1,200}$ for username.
  • Used a literal space in the username pattern instead of \s, because \s also matches \n/\r/\t — the exact control characters this fix must reject. Requests carrying control chars now fail schema validation with a 400 before anything is logged.
  • Added regression tests covering a control-char username and a non-numeric productionId.

Test plan

  • Tests pass (npm test) — 245 passed (2 new)
  • TypeScript compiles (npm run typecheck)
  • Lint clean (npm run lint) — 0 errors
  • Control-char username / non-numeric ids rejected with 400 by schema

Closes #287

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

The username, lineId and productionId path params on the WHIP/WHEP POST
routes were URL-decoded and interpolated into log messages without any
sanitization, allowing newline/CR/ANSI injection to forge log entries.

Add restrictive TypeBox patterns: numeric-only (^[0-9]+$) for productionId
and lineId (consistent with api_productions.ts), and ^[\w .-]{1,200}$ for
username. A literal space is used instead of \s so control chars such as
\n and \r are rejected. Adds regression tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Security: Log injection via unsanitized username/lineId in WHIP/WHEP log output

1 participant