Skip to content

fix(static): add missing enum sentinel to ngx_http_zstd_static[]#74

Merged
eilandert merged 1 commit into
masterfrom
fix/enum-sentinel
Jul 7, 2026
Merged

fix(static): add missing enum sentinel to ngx_http_zstd_static[]#74
eilandert merged 1 commit into
masterfrom
fix/enum-sentinel

Conversation

@eilandert

Copy link
Copy Markdown
Member

BLOCKER from module audit.

Problem

ngx_http_zstd_static[] (the off/on/always ngx_conf_enum_t array) is missing the terminating { ngx_null_string, 0 } sentinel. ngx_conf_set_enum_slot() scans with for (i = 0; e[i].name.len != 0; i++), so an unmatched value such as zstd_static maybe; walks off the array end — an out-of-bounds read, after which ngx_strcasecmp() dereferences a wild pointer (possible crash / ASAN abort at config load).

Fix

Add the sentinel. Every stock nginx enum carries it. Unknown values now produce a clean invalid value config error.

Tests

  • t/02-conf-warn.t TEST 3 — zstd_static maybe; -> must_die with invalid value "maybe" (the ASAN CI job aborts here if the OOB read returns).
  • TEST 4 — always (last real entry) still parses/loads.

Local: prove t/02-conf-warn.t = 11/11 PASS.

The ngx_http_zstd_static[] ngx_conf_enum_t array (off/on/always) lacked
the terminating { ngx_null_string, 0 } sentinel. ngx_conf_set_enum_slot()
scans the array with `for (i = 0; e[i].name.len != 0; i++)`, so an
unmatched directive value (e.g. `zstd_static maybe;`) walks off the end
of the array reading garbage name.len/name.data — an out-of-bounds read,
and ngx_strcasecmp() then dereferences a wild pointer (possible crash /
ASAN abort). Every stock nginx enum terminates with the sentinel; add it.

With the sentinel an unknown value is a clean "invalid value" config
error instead of undefined behaviour.

Tests (t/02-conf-warn.t): TEST 3 asserts an invalid enum value is
rejected with `invalid value "maybe"` (must_die); TEST 4 asserts the
last real entry "always" still parses. The ASAN CI job runs this binary,
so a re-introduced OOB read aborts on TEST 3.
@eilandert
eilandert merged commit 08ef190 into master Jul 7, 2026
12 checks passed
@eilandert
eilandert deleted the fix/enum-sentinel branch July 7, 2026 19:35
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.

1 participant