|
| 1 | +# 001 — Verified findings |
| 2 | + |
| 3 | +Every entry below was reproduced against the working tree at `474584bcd` on |
| 4 | +2026-08-17. Line numbers are from that tree. Findings the audits raised that |
| 5 | +could not be reproduced are listed at the bottom under "Not carried". |
| 6 | + |
| 7 | +Ranked by user impact. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## F1 — `src/service.ts:2361` uses the exact PowerShell argv the codebase forbids |
| 12 | + |
| 13 | +`killWindowsServiceWrapperProcesses()` in `src/service.ts` spawns: |
| 14 | + |
| 15 | +```ts |
| 16 | +// src/service.ts:2360-2363 |
| 17 | +spawnSync(resolveTrustedWindowsPowerShellExe(), [ |
| 18 | + "-NoProfile", "-NoLogo", "-NonInteractive", "-WindowStyle", "Hidden", |
| 19 | + "-Command", ps, |
| 20 | +], { stdio: "ignore", timeout: 5000, windowsHide: true }); |
| 21 | +``` |
| 22 | + |
| 23 | +The codebase already knows this is wrong. `src/codex/user-identity.ts:222-224`: |
| 24 | + |
| 25 | +> Do not add PowerShell's `-WindowStyle Hidden` here: Bun 1.3.14 can fail that |
| 26 | +> direct CLI combination before the SID command executes (#1589); the |
| 27 | +> process-level `windowsHide` flag is sufficient. |
| 28 | +
|
| 29 | +**Why it survived.** The regression test is scoped to one file: |
| 30 | + |
| 31 | +```ts |
| 32 | +// tests/windows-deploy-close-regressions.test.ts:43 |
| 33 | +expect(src).not.toContain('["-NoProfile", "-NoLogo", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", ps]'); |
| 34 | +``` |
| 35 | + |
| 36 | +`src` there is `read("src/update/job.ts")` (line 13). `src/service.ts` is never |
| 37 | +checked. A search of `src/` finds exactly one surviving production occurrence |
| 38 | +of that CLI pair: `src/service.ts:2361`. |
| 39 | + |
| 40 | +**User-visible consequence.** `stopServiceIfInstalled()` calls this function |
| 41 | +because `schtasks /end` can leave the `wscript.exe`/`cmd.exe` wrapper alive, |
| 42 | +which then respawns the proxy. The call ignores `spawnSync`'s exit status and |
| 43 | +swallows errors, so under #1589 wrapper termination silently does nothing: |
| 44 | +`ocx stop`, restart, and update appear to succeed and do not stick. |
| 45 | + |
| 46 | +Severity: high. Fix cost: one line. Phase 010. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## F2 — The wrapper killer exists twice and the copies have drifted apart |
| 51 | + |
| 52 | +Two implementations of the same operation: |
| 53 | + |
| 54 | +```ts |
| 55 | +// src/service.ts:2337-2358 — canonical token matching scoped to THIS home |
| 56 | +// (paths built 2340-2341; token boundaries enforced 2350-2355) |
| 57 | +// src/update/job.ts:1377-1383 (the bare -like match is line 1383) |
| 58 | +"$pats = @('opencodex-service.cmd','opencodex-service-launcher.vbs');" |
| 59 | +... |
| 60 | +"foreach ($p in $pats) { if ($c -like ('*' + $p + '*')) { return $true } };" |
| 61 | +``` |
| 62 | + |
| 63 | +The updater copy matches a bare filename anywhere in a command line. Two |
| 64 | +OpenCodex homes under one Windows account means a dashboard update for home A |
| 65 | +can terminate home B's scheduler wrapper. Any unrelated process whose command |
| 66 | +line contains either filename also matches. |
| 67 | + |
| 68 | +Cited precisely: the updater's bare match is `src/update/job.ts:1383`; the service copy builds canonical paths at `src/service.ts:2340-2341` and enforces token boundaries at `:2350-2355`. |
| 69 | + |
| 70 | +The drift is already measurable and runs in both directions: `update/job.ts` |
| 71 | +received the #1589 argv cleanup that `service.ts` missed (F1); `service.ts` |
| 72 | +received canonical path scoping that `update/job.ts` missed. Two copies, two |
| 73 | +different half-fixes. |
| 74 | + |
| 75 | +Severity: high (cross-installation process kill). Phase 020. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## F3 — Windows is not a gate, and the release gate cannot see that |
| 80 | + |
| 81 | +```yaml |
| 82 | +# .github/workflows/ci.yml:547-552 |
| 83 | +if: github.event_name == 'workflow_dispatch' |
| 84 | +``` |
| 85 | +
|
| 86 | +The aggregation job accepts `skipped` (`ci.yml:769-772` — the jq filter keeps |
| 87 | +only jobs that are neither `success` nor `skipped`). The release preflight |
| 88 | +(`release.yml:181-201`) demands a successful **push-event** `ci.yml` run — |
| 89 | +deliberately narrower than "any successful run for this SHA" — but |
| 90 | +`platform-windows` never runs on push. So the general release preflight does not require `platform-windows`, and a |
| 91 | +release can publish without it having run. |
| 92 | + |
| 93 | +One qualification, because the stronger claim is not true: releases that touch |
| 94 | +`src/service.ts`, `src/cli/index.ts`, `package.json` and a few others separately |
| 95 | +require a green `service-lifecycle.yml` (`release.yml:224-241`, enforced at |
| 96 | +235-239), and that |
| 97 | +workflow does include a Windows job. Windows is therefore not entirely absent |
| 98 | +from release gating - it is absent from the *suite* gate, and present only as a |
| 99 | +lifecycle smoke test for service-shaped changes. |
| 100 | + |
| 101 | +Severity: high, and it is the multiplier on every other finding — without it, |
| 102 | +each fix below is one careless merge away from regressing. Phases 060 and 070. |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## F4 — Durable publishers do not share the Windows retry primitive |
| 107 | + |
| 108 | +`src/config.ts:102-123` knows about Windows sharing violations: |
| 109 | + |
| 110 | +```ts |
| 111 | +const transientWindowsError = io.platform === "win32" |
| 112 | + && (code === "EBUSY" || code === "EPERM" || code === "EACCES"); |
| 113 | +if (!transientWindowsError || attempt >= 2) throw error; |
| 114 | +io.sleep(25 * (attempt + 1)); |
| 115 | +``` |
| 116 | + |
| 117 | +Two retries, 25ms then 50ms: about 75ms of total tolerance. Other durable |
| 118 | +publishers do not call it at all and use raw `renameSync`: |
| 119 | + |
| 120 | +- `src/codex/prompt-journal.ts` — publishes a journal holding full |
| 121 | + `config.toml` bytes |
| 122 | +- `src/lib/config-ownership.ts` — publishes the uninstall ownership manifest |
| 123 | + |
| 124 | +These are fail-safe, not corrupting: they throw rather than publish a partial |
| 125 | +file. But under a real-time scanner or a sync client holding the target, they |
| 126 | +turn a recoverable hiccup into a user-visible operational failure. |
| 127 | + |
| 128 | +The 75ms envelope is itself a watch item, not yet a defect — we have no field |
| 129 | +telemetry showing Defender or OneDrive holding files longer. Instrument before |
| 130 | +widening. Phase 030 makes the primitive shared; Phase 031 adds the counters. |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## F5 — `chmod` is load-bearing where it does nothing |
| 135 | + |
| 136 | +`src/config.ts` calls `chmodSync(target, 0o600)` at lines 221, 316, 450, 1713, |
| 137 | +2683 and 3942, and `chmodSync(dir, 0o700)` at 1704, 2632, each wrapped in |
| 138 | +`catch { /* platform may ignore chmod */ }`. The 3942 site sits inside |
| 139 | +`backupInvalidConfig` (declared at 3937), which copies the whole config |
| 140 | +including whatever secrets it held. On Windows the call is a no-op: |
| 141 | +the ACL is what protects the file, and `src/lib/windows-secret-acl.ts` is what |
| 142 | +sets it. |
| 143 | + |
| 144 | +Where both run, the file is protected. The audit work needed here is an |
| 145 | +inventory: every path that writes a credential, token, or OAuth refresh token, |
| 146 | +and whether the Windows ACL path is reached on that specific write or only the |
| 147 | +`chmod`. `src/service.ts:1983` states the ACL is authoritative, but says so about an |
| 148 | +elevation staging directory specifically. That is evidence for the principle, |
| 149 | +not evidence about any credential writer's coverage - each inventory row needs |
| 150 | +its own citation. |
| 151 | + |
| 152 | +Treated as **unproven** until the inventory is done. Phase 040. Per AGENTS.md, |
| 153 | +if that inventory turns up a live exposure the writeup goes to scratch space, |
| 154 | +not into this directory. |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +## F6 — The service wrapper retries a deterministic crash forever |
| 159 | + |
| 160 | +```bat |
| 161 | +:: src/service.ts:1556-1563 |
| 162 | +"%OCX_BUN%" "%OCX_CLI%" start ... |
| 163 | +if %ERRORLEVEL% NEQ 0 ( |
| 164 | + ... restarting in 5s |
| 165 | + ping -n 6 127.0.0.1 >nul |
| 166 | + goto loop |
| 167 | +) |
| 168 | +``` |
| 169 | + |
| 170 | +A proxy that starts successfully and then crashes deterministically is |
| 171 | +relaunched every five seconds indefinitely. #1877 deliberately fixed only the |
| 172 | +missing-executable case, on the reasoning that a flat "N failures then stop" |
| 173 | +ceiling would break recovery from intermittent faults. That reasoning is sound; |
| 174 | +the conclusion does not have to be an unbounded fixed-interval loop. |
| 175 | + |
| 176 | +Capped exponential backoff with a health-reset — 5s, 15s, 30s, 60s, reset after |
| 177 | +sustained uptime — preserves recovery and stops the log storm. Phase 050. |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +## F7 — Windows CI never proves crash-restart |
| 182 | + |
| 183 | +`.github/workflows/service-lifecycle.yml:104-135` kills the systemd MainPID, |
| 184 | +waits for a different PID, and asserts `/healthz`. The Windows job |
| 185 | +(`windows-schtasks`, line 239) only covers install, health, clean `ocx stop`, |
| 186 | +uninstall. The restart path F6 describes has no coverage on the platform where |
| 187 | +it is implemented in batch. Phase 051. |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## Not carried |
| 192 | + |
| 193 | +Raised by the audits, deliberately excluded: |
| 194 | + |
| 195 | +- **#1843 elevated `Start-Process` argv** — already fixed; PR #1860 merged and |
| 196 | + present in the tree. |
| 197 | +- **#31 passthrough SSE segfault** — fixed via `body.tee()`. |
| 198 | +- **Bun replacing its own running executable during update** — |
| 199 | + `src/update/index.ts:152-155` documents that the plain-Node launcher handles |
| 200 | + npm self-update before Bun starts. |
| 201 | +- **Synchronous `icacls`/CIM on the request path (#1852, #1298; PR #1876)** — |
| 202 | + both P1 and P3 rate this their top runtime issue and the reasoning is |
| 203 | + persuasive, but it is a latency property this session did not measure. It |
| 204 | + belongs to the open PR, not to this unit. Recorded here so the next cycle |
| 205 | + starts from it rather than rediscovering it. |
0 commit comments