Skip to content

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

Closed
zhuizhuhaomeng wants to merge 1 commit into
masterfrom
codex-security/arp_a1d6db1ea7c0efdee40e8fc682073dd3
Closed

zhuizhuhaomeng wants to merge 1 commit into
masterfrom
codex-security/arp_a1d6db1ea7c0efdee40e8fc682073dd3

Conversation

@zhuizhuhaomeng

Copy link
Copy Markdown
Contributor

The patch enforces current-request coroutine ownership and makes the security regression log assertion CI-safe.

  • ngx_http_lua_get_co_ctx treats exdata2 as untrusted until its address and Lua state match current request-owned storage.
  • Foreign or expired retained threads return dead from status and no co ctx found from resume, closing stale request-pool dereferences.
  • Same-request coroutines still resolve normally, including coroutines created and resumed inside timer callbacks and the unchanged non-exdata2 path.
  • TEST 3 now extracts one lowercase value token, excluding comma-delimited nginx context while preserving wrong-value failures and the exact six-line expectation.

Static Verification Checks

  • Current request ownership (Passed) — Static inspection of ngx_http_lua_get_co_ctx confirms current-request pointer membership and Lua-state identity, closing stale and reused-address attack paths.

  • Safe foreign rejection (Passed) — Static inspection of ngx_http_lua_coroutine_status and ngx_http_lua_coroutine_resume confirms foreign threads preserve documented dead and no-context rejection behavior.

  • Local coroutine compatibility (Passed) — TEST 3 in t/197-coroutine-request-cleanup.t asserts timer-local coroutines resume successfully, protecting legitimate same-request coroutine behavior.

  • Precise log extraction (Passed) — Static inspection of t/197-coroutine-request-cleanup.t confirms token extraction excludes CI context suffixes while wrong values still violate exact expected output.

  • Fallback lookup compatibility (Passed) — Static inspection of ngx_http_lua_get_co_ctx confirms the non-exdata2 branch retains its existing request-local lookup behavior.

  • Finding: acf_8c793d665baac688a369fdd85d8ccc33

  • Patch: arp_a1d6db1ea7c0efdee40e8fc682073dd3

  • Base commit: a7733460bc1052e7eedb5240dfbc1cdb98527950

  • Patch SHA-256: e0946f8bf577433fdb4452a5d45afd97c87b34405da6488d70228d0d9e653093

@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
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