Commit ca92c2e
committed
Validate synthetic ID format on inbound header and cookie values
Inbound synthetic IDs from the x-synthetic-id header and synthetic_id
cookie were accepted without validation. An attacker could inject
arbitrary strings — including very long values, special characters, or
newlines — which were then set as response headers, cookies, and
forwarded to third-party APIs.
Adds a private is_valid_synthetic_id() validator enforcing the canonical
format (64 lowercase hex chars + '.' + 6 alphanumeric chars). The length
check is O(1) and runs first to bound all downstream work. Invalid values
are silently discarded and a fresh ID is generated in their place; the
raw value is never written to logs.
Also adds a debug_assert! in generate_synthetic_id() to catch any future
regression in the generator, moves VALID_SYNTHETIC_ID to test_support so
it is shared across all test modules, and demotes synthetic ID values from
INFO to DEBUG in log output to avoid recording pseudonymous identifiers in
production log pipelines.
Closes #4121 parent e295f3a commit ca92c2e
6 files changed
Lines changed: 215 additions & 74 deletions
File tree
- crates/common/src
- integrations
- docs/guide
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1310 | 1310 | | |
1311 | 1311 | | |
1312 | 1312 | | |
1313 | | - | |
1314 | | - | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
1315 | 1322 | | |
1316 | 1323 | | |
1317 | 1324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1291 | 1291 | | |
1292 | 1292 | | |
1293 | 1293 | | |
1294 | | - | |
| 1294 | + | |
| 1295 | + | |
1295 | 1296 | | |
1296 | 1297 | | |
1297 | 1298 | | |
| |||
1309 | 1310 | | |
1310 | 1311 | | |
1311 | 1312 | | |
1312 | | - | |
| 1313 | + | |
1313 | 1314 | | |
1314 | 1315 | | |
1315 | 1316 | | |
| |||
0 commit comments