Repository navigation
Description
What happened
On Linux, unlock can classify a shared codex app-server owner as a non-shared, signalable Codex process when the invoking shell exports COLUMNS.
runCommand passes the full parent environment to diagnostic commands, overriding only LC_ALL and LANG. Owner arguments are read with ps -p <pid> -o args= without -ww. procps-ng honours COLUMNS even when stdout is a pipe and truncates the args column to that width. The shared-service regex is then evaluated against the truncated string, so an app-server, remote-control, or daemon token beyond column COLUMNS is silently lost while identityComplete remains true.
Because revalidation samples args the same way, the truncated value is also stable across the before/after comparison, so revalidation does not catch it either.
Reproduced with procps-ng 4.0.4 (Ubuntu 24.04, aarch64), using a same-user dummy process renamed to a long path:
$ ps -p $PID -o args= | cat
/very/long/path/aaaa…aaaa/codex app-server --x
$ COLUMNS=80 ps -p $PID -o args= | cat
/very/long/path/aaaa…aaaa
A real-world trigger is an editor-bundled Codex binary (for example under ~/.vscode*/extensions/openai.chatgpt-*/bin/...) whose absolute path alone is close to or longer than 80 columns, run from a shell that exports COLUMNS.
macOS ps did not truncate piped output in the same test.
What you expected
A shared app-server owner is refused with lock_owner_is_shared_service regardless of the caller's terminal width variables, as required by the repository safety invariants ("Refuse shared app-server, Remote Control, daemon, ambiguous, or changing owners"). If the full argument vector cannot be obtained, the owner identity should be unknown.
Environment
codex-unlock0.4.0 at6227e6c- Ubuntu 24.04.5 LTS aarch64, procps-ng 4.0.4 (affected)
- macOS 27.0 arm64 (not reproduced)
Source evidence
- Environment is inherited by diagnostic commands:
Lines 47 to 51 in 6227e6c
const isolatedProcessGroup = process.platform !== "win32"; const child = spawn(executable, args, { detached: isolatedProcessGroup, env: { ...process.env, LC_ALL: "C", LANG: "C" }, stdio: ["ignore", "pipe", "pipe"], ps -o <field>=without-ww:Lines 102 to 103 in 6227e6c
async function psField(pid: number, field: string): Promise<ProcessFieldObservation> { const result = await runCommand("ps", ["-p", String(pid), "-o", `${field}=`]); argssampled via that helper:Line 218 in 6227e6c
psField(candidate.pid, "args"), - Shared-service classification on the possibly truncated value:
Line 234 in 6227e6c
const isSharedService = /\b(?:app-server|remote-control|daemon)\b/i.test(args ?? "");
Acceptance criteria
- Diagnostic commands do not inherit
COLUMNS,LINES,PS_FORMAT, orPS_PERSONALITY(or run with an explicit minimal environment). - Owner arguments are read without width truncation (for example
ps -ww, or/proc/<pid>/cmdlineon Linux). - A regression test sets
COLUMNS=40and still yieldslock_owner_is_shared_servicefor an owner whoseapp-servertoken appears after column 40. - Width-limited or otherwise incomplete argument evidence fails closed as
unknown.
Scope and limitations
- Not exploitable by another user: it depends on the invoking user's own environment and on the owner being a same-user process that otherwise passes every unlock gate (single lock, stable transcript ending in
task_complete). - Reproduced with
pson a dummy process; no real Codex app-server was signaled. - Related hardening, not a separate finding: there is no final start-time/lock re-check immediately before
process.kill, after the full transcript hash in revalidation (,Lines 269 to 300 in 6227e6c
if (finalInspection.transcript.path && beforeHash !== null) { try { const finalHash = await stableFileHash(finalInspection.transcript.path); if ( finalHash.hash !== beforeHash || !sameSnapshot(finalHash.snapshot, finalInspection.transcript.snapshot) ) { revalidationReasons.push("transcript_changed_during_revalidation"); } } catch (error) { revalidationReasons.push(`transcript_revalidation_hash_failed:${errorText(error)}`); } } if (revalidationReasons.length > 0) { return unlockResult(inspection, { outcome: "refused", changed: false, pid: owner.pid, signalSent: null, processExited: null, processObservation: null, lockReleased: false, transcriptUnchanged: null, reasons: unique(revalidationReasons), }); } return await terminateRevalidatedOwner( { inspection, owner: { ...owner, startTime: owner.startTime! }, transcriptPath, transcriptHash: beforeHash!, ). Checking start time immediately before signaling would further shrink the PID-reuse window.Lines 66 to 72 in 6227e6c
async function terminateRevalidatedOwner( evidence: RevalidatedUnlockEvidence, options: DoctorOptions, ): Promise<UnlockResult> { const { inspection, owner, transcriptPath, transcriptHash } = evidence; try { process.kill(owner.pid, "SIGTERM");
Checked
- Existing issues security: revalidate every unlock invariant immediately before SIGTERM #9, security: distinguish process exit from process inspection failure #12, and security: bound external command execution time and output #13 cover revalidation, process-inspection failures, and command time/output bounds, but not output width truncation.
npm run check,npm run lint,npm test(84/84), andnpm run smoke:packagepass at6227e6c.
Activity
fix: harden diagnostic command execution