Commit 00c0643
fix(redact-url): handle malformed percent-encoding without throwing
`decodeURIComponent` raises URIError on invalid percent sequences
(incomplete UTF-8 like `%FF`, or non-hex like `%ZZ`). pino-http
invokes `redactUrl` from its request serializer once per request,
so an unhandled URIError here would either skip the log line
entirely or — depending on pino's serializer-error fallback path —
log the raw URL, leaking the very `authkey=…` / `token=…` /
`password=…` value we're meant to redact.
Wrap the `decodeURIComponent(rawName)` call: on URIError, fall back
to lowercasing the raw (still-encoded) name. The raw bytes are
preserved either way in the output, so no value is lost; a
percent-malformed param name is almost certainly not a real
sensitive-list entry anyway.
Regression test verifies:
- malformed-name URLs don't throw (the bug)
- a sensitive param following a malformed one is still redacted
(the loop must keep going after recovery, not abort)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d40ecb6 commit 00c0643
2 files changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
48 | 61 | | |
49 | 62 | | |
50 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
72 | 87 | | |
0 commit comments