Commit f30f5e3
test(config): regression test for buf-aliasing heap overflow in zai_config_find_and_set_value
When a DD_ env var is cached as a short persistent allocation and the
corresponding OTEL fallback is invoked, the code (pre-fix) passes the
aliased buf—still pointing at that tiny allocation—directly to the
fallback. ddtrace_conf_otel_propagators then writes up to 30 bytes via
memcpy, overflowing the allocation.
The trigger: DD_TRACE_PROPAGATION_STYLE=, (a bare comma). The comma is
non-empty so PHP's proc_open passes it to the child process normally.
SET_LOWERCASE decode rejects all-separator input (zero set elements),
leaving value.len == 0, which causes the fallback to fire with the
aliased 2-byte buffer. Under ASAN this crashes the process during MINIT.
The fix (commit 433ca60) allocates a fresh ZAI_ENV_MAX_BUFSIZ buffer
for every fallback call so the aliased pointer is never used as the write
destination.
Note: DD_TRACE_PROPAGATION_STYLE= (empty string) cannot be used because
PHP's proc_open silently drops env-array entries with empty-string values.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>1 parent 433ca60 commit f30f5e3
1 file changed
Lines changed: 32 additions & 0 deletions
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments