Skip to content

bugfix: Timer-retained coroutines dereference contexts from destroyed requests - #2554

Merged
zhuizhuhaomeng merged 2 commits into
masterfrom
codex-security/arp_b27eaed87fe1044d3d13f48693586f8c
Nov 28, 2026
Merged

zhuizhuhaomeng merged 2 commits into
masterfrom
codex-security/arp_b27eaed87fe1044d3d13f48693586f8c

Conversation

@zhuizhuhaomeng

Copy link
Copy Markdown
Contributor

The patch now validates coroutine contexts against the active request before returning request-pool metadata.

  • The exdata2 value is only an identity hint and must match active request storage and Lua state.
  • Foreign, destroyed-request, and recycled-address contexts reach existing safe outcomes before any stale read or write.
  • This closes the worker-crash and request-pool-corruption path for timer-retained or globally retained coroutines.
  • Current-request entry, ordinary, and light-thread coroutines retain existing status, resume, wait, kill, and creation behavior.
  • Regression assertions cover overlapping and post-teardown timers while preserving successful timer-local coroutine execution.

Static Verification Checks

  • Current Request Membership (Passed) — src/ngx_http_lua_util.c ngx_http_lua_get_co_ctx matches exdata2 against active request storage, blocking foreign-context metadata access.

  • Reused Address Defense (Passed) — src/ngx_http_lua_util.c additionally matches Lua state identity, rejecting stale pointers whose pool addresses were recycled.

  • Safe Coroutine Outcomes (Passed) — src/ngx_http_lua_coroutine.c handles null lookups before dereference, preserving dead status and no co ctx found errors.

  • Thread Caller Guarding (Passed) — src/ngx_http_lua_uthread.c wait and kill paths reject null lookups before accessing thread ownership or status fields.

  • Legacy Lookup Compatibility (Passed) — src/ngx_http_lua_util.c preserves the non-exdata2 request-local scan unchanged, maintaining existing coroutine lookup behavior.

  • Regression Boundary Coverage (Passed) — t/197-coroutine-request-cleanup.t expects overlapping and expired foreign coroutines rejected while newly local coroutines resume successfully.

  • Static Verification Scope (Passed) — Final git diff inspection used no runtime checks and established source-only closure of the reported attack path.

  • Finding: acf_8c793d665baac688a369fdd85d8ccc33

  • Patch: arp_b27eaed87fe1044d3d13f48693586f8c

  • Base commit: a7733460bc1052e7eedb5240dfbc1cdb98527950

  • Patch SHA-256: abaaef060dd45e66819367439f621e25545b5e3a8cac979a429129f1f62a868b

@zhuizhuhaomeng
zhuizhuhaomeng marked this pull request as ready for review November 28, 2026 06:33
@zhuizhuhaomeng zhuizhuhaomeng changed the title [Codex Security] Timer-retained coroutines dereference contexts from destroyed requests bugfix: Timer-retained coroutines dereference contexts from destroyed requests Nov 28, 2026
@zhuizhuhaomeng
zhuizhuhaomeng merged commit c686ddb into master Nov 28, 2026
6 checks passed
@zhuizhuhaomeng
zhuizhuhaomeng deleted the codex-security/arp_b27eaed87fe1044d3d13f48693586f8c branch November 28, 2026 07:13
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