Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(proxy): close the r15 audit gaps in the Codex config error, nginx pin and doc

Alfredo Lopez8d0567f25cd1
diff --git a/codex-llm-proxy/src/config.ts b/codex-llm-proxy/src/config.ts
index 63d106ce5..43178bec3 100644
--- a/codex-llm-proxy/src/config.ts
+++ b/codex-llm-proxy/src/config.ts
@@ -87,7 +87,9 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): CodexLlmProxyC
LIMITS.maxVisualRequestBodyBytes
)
if (maxVisualBodyBytes < LIMITS.maxVisualRequestBodyBytes) {
- throw new Error('Visual Codex requests require the full shared envelope byte budget')
+ throw new Error(
+ `CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be at least ${LIMITS.maxVisualRequestBodyBytes}, the contract maxVisualRequestBodyBytes`
+ )
}
// The 1Gi memory limit was measured with two visual streams at the contract
// ceiling only (see IN_FLIGHT_BODY_BUDGET_BODIES). A larger value would admit
diff --git a/codex-llm-proxy/test/server.security.test.ts b/codex-llm-proxy/test/server.security.test.ts
index 742acfb7c..bb2d2590c 100644
--- a/codex-llm-proxy/test/server.security.test.ts
+++ b/codex-llm-proxy/test/server.security.test.ts
@@ -631,7 +631,10 @@ describe('codex-llm-proxy security surface', () => {
...required,
CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES: '1024',
})
- ).toThrow(/shared envelope byte budget/)
+ ).toThrow(
+ `CODEX_LLM_PROXY_MAX_VISUAL_BODY_BYTES must be at least ${LIMITS.maxVisualRequestBodyBytes}, the contract maxVisualRequestBodyBytes`
+ )
+ // Witness: the default (no override) loads at the contract value.
expect(loadConfig(required).maxVisualBodyBytes).toBe(24 * 1024 * 1024)
})
diff --git a/docs/architecture/codex-subscription-transport-contract.md b/docs/architecture/codex-subscription-transport-contract.md
index 00f8ac730..a1c6fdbf6 100644
--- a/docs/architecture/codex-subscription-transport-contract.md
+++ b/docs/architecture/codex-subscription-transport-contract.md
@@ -458,6 +458,22 @@ behavior changes:
`reason: visual_host_share`. The share is released together with the
visual slot: on read-deadline expiry, on client close before hand-off,
and when the handler's finally block unwinds.
+
+ **Visual body read deadline and slot lifetime.** Once the visual gate
+ grants a slot, the body must be read and parsed within
+ `BODY_READ_DEADLINE_MS` (10 s). Otherwise the proxy answers 408
+ `request_timeout` with `connection: close` (the rest of the body is never
+ read, so the connection cannot be reused) and frees the slot and the
+ principal share. After the grant, the slot is also freed when the response
+ closes for any other reason, which covers every refusal before the stream
+ starts. That close hook releases only while the slot is still held by the
+ admission code: a kept visual body hands the release to the handler, which
+ frees it in its outer `finally`, and a demoted body releases through the
+ admission path before it joins the ordinary stream gate. A visual-gate
+ refusal (queue full, wait exceeded) is answered 503 `provider_unavailable`
+ and logged as `codex_proxy_admission_refused` with `reason: visual_gate`.
+ A client that leaves while queued is not gate saturation: its place is freed
+ silently, with no log and no response.
- It requires the redeem response to carry `maxStreamDurationMs` greater
than 0. An absent value is a contract violation, not a default.
- It logs one `codex_proxy_attempt_finished` event per completion attempt,
diff --git a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh b/scripts/tests/test-grok-llm-proxy-deploy-contract.sh
index 572c498b1..90b0bd680 100755
--- a/scripts/tests/test-grok-llm-proxy-deploy-contract.sh
+++ b/scripts/tests/test-grok-llm-proxy-deploy-contract.sh
@@ -173,7 +173,12 @@ def nginx_block(text, header):
authorize_block = nginx_block(cm, "location = /api/v1/mcp-host/llm/provider-attempts/authorize {")
if authorize_block is None:
errors.append("workflow-approval gateway must keep the exact-match authorize location")
-elif 'client_max_body_size 36700160;' not in authorize_block:
+elif not re.search(
+ r"^\s*client_max_body_size\s+36700160\s*;\s*$",
+ # Inline comments are not directives: "1m; # ... 36700160;" must not pass.
+ re.sub(r"[ \t]+#.*$", "", authorize_block, flags=re.M),
+ re.M,
+):
errors.append("workflow-approval gateway authorize route must allow the 35 MiB Grok visual envelope")
wrc_disabled = re.compile(r'- name: WRC_GROK_SUBSCRIPTION_ENABLED\n\s+value: "false"\n')
if not wrc_disabled.search(active(manifest.parent / "workflow-recipes.yaml")):