Commit bd7457f
committed
admin: reject NUL-byte payload smuggling (Codex P2)
decodeCreateTableRequest used dec.More() to enforce a single JSON
document per request, but goccy/go-json treats a raw NUL as
end-of-input — a body like `{"table_name":...}\x00{"extra":1}`
parsed cleanly, dec.More() returned false, and the trailing
content was silently dropped. Codex P2 on PR #634 flagged this
as a payload-smuggling vector.
Fix: read the body once, scan for NUL before decoding. JSON has
no need for raw NUL (control characters must be \u-escaped per
RFC 8259), so any NUL is a strong signal of either tooling
misconfiguration or deliberate smuggling. Reject with 400.
The existing dec.More() check stays — it catches the well-formed
trailing-token cases (a second `{...}` or trailing `42`) that
would otherwise pass NUL-validation but still violate the
strict-body contract.
Tests: extend TestDynamoHandler_CreateTable_RejectsBadJSON with
two NUL vectors — the trailing `{"extra":1}` from the Codex
report, and a bare trailing NUL with no extra payload.1 parent c13dc49 commit bd7457f
2 files changed
Lines changed: 25 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
358 | 359 | | |
359 | 360 | | |
360 | 361 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 362 | + | |
| 363 | + | |
365 | 364 | | |
366 | 365 | | |
367 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
368 | 383 | | |
369 | 384 | | |
370 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
505 | 511 | | |
506 | 512 | | |
507 | 513 | | |
| |||
0 commit comments