Commit 737a5e9
fix: inject OPENAI_API_KEY/CODEX_API_KEY placeholders for Codex api-proxy routing (#2136)
* fix: inject OPENAI_API_KEY/CODEX_API_KEY placeholders for api-proxy credential isolation
Codex v0.121.0 introduced a CODEX_API_KEY-based WebSocket auth flow. When neither
CODEX_API_KEY nor OPENAI_API_KEY is present in the agent environment, Codex bypasses
OPENAI_BASE_URL and connects directly to wss://api.openai.com/v1/responses for OAuth
authentication, getting a 401 because AWF holds the real keys in the api-proxy sidecar.
Fix: inject placeholder values for OPENAI_API_KEY and CODEX_API_KEY when api-proxy is
active (same pattern as ANTHROPIC_AUTH_TOKEN for credential isolation). With a key
present, Codex routes API calls through OPENAI_BASE_URL=http://172.30.0.30:10000. The
api-proxy sidecar then replaces the placeholder Authorization header with the real key
via Object.assign(forwardHeaders, injectHeaders) before forwarding to api.openai.com.
The real keys are never present in the agent container; the placeholders are intercepted
by the api-proxy WebSocket upgrade handler (proxyWebSocket() in server.js:689) and
replaced with the real credentials. The one-shot-token LD_PRELOAD library caches and
clears placeholders from /proc/self/environ as normal.
Update tests to assert placeholder is set and real key is not leaked.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update src/docker-manager.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* fix: update api-proxy health check to allow OpenAI/Codex placeholder keys
The health check was blocking startup when OPENAI_API_KEY or CODEX_API_KEY
contained the placeholder value 'sk-placeholder-for-api-proxy', treating it
as a credential isolation failure.
Update the check to allow the known placeholder value while still rejecting
any real (non-placeholder) keys. This mirrors the Anthropic pattern where
ANTHROPIC_AUTH_TOKEN is allowed to hold its placeholder value.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 92f9578 commit 737a5e9
3 files changed
Lines changed: 52 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
68 | 83 | | |
69 | 84 | | |
70 | 85 | | |
71 | 86 | | |
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
75 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
76 | 96 | | |
77 | 97 | | |
78 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2526 | 2526 | | |
2527 | 2527 | | |
2528 | 2528 | | |
2529 | | - | |
2530 | | - | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
2531 | 2534 | | |
2532 | 2535 | | |
2533 | 2536 | | |
| |||
2540 | 2543 | | |
2541 | 2544 | | |
2542 | 2545 | | |
2543 | | - | |
2544 | | - | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
2545 | 2549 | | |
2546 | 2550 | | |
2547 | 2551 | | |
2548 | 2552 | | |
2549 | 2553 | | |
2550 | 2554 | | |
2551 | 2555 | | |
2552 | | - | |
2553 | | - | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
2554 | 2559 | | |
2555 | 2560 | | |
2556 | 2561 | | |
| |||
2563 | 2568 | | |
2564 | 2569 | | |
2565 | 2570 | | |
2566 | | - | |
| 2571 | + | |
| 2572 | + | |
2567 | 2573 | | |
2568 | 2574 | | |
2569 | 2575 | | |
2570 | 2576 | | |
2571 | 2577 | | |
2572 | 2578 | | |
2573 | 2579 | | |
2574 | | - | |
2575 | | - | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
2576 | 2583 | | |
2577 | 2584 | | |
2578 | 2585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1821 | 1821 | | |
1822 | 1822 | | |
1823 | 1823 | | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
1824 | 1837 | | |
1825 | 1838 | | |
1826 | 1839 | | |
| |||
0 commit comments