Skip to content

fix: let Codex read the target on Windows (SECFOO-38) - #24

Merged
vsn411 merged 1 commit into
secfoo-com:mainfrom
karthickmk2001:fix/codex-windows-sandbox
Oct 3, 2026
Merged

vsn411 merged 1 commit into
secfoo-com:mainfrom
karthickmk2001:fix/codex-windows-sandbox

Conversation

@karthickmk2001

@karthickmk2001 karthickmk2001 commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes SECFOO-38, the open Codex item from #23: on Windows, Codex couldn't read the target at all.

Cause: with no Windows sandbox configured, codex exec --sandbox read-only rejects every shell command on Windows, reads included (exec_command failed ... rejected: blocked by policy). #23 made secfoo report those runs as failed instead of a false success, but they still couldn't succeed.

Fix: on Windows only, pass -c windows.sandbox="unelevated". Codex's restricted-token sandbox needs no admin setup, and it still enforces read-only. The elevated setup that #23's failure message suggested turned out to be unnecessary, so that hint is removed.

Verification (Windows 11, codex-cli 0.159.2)

Read-only enforcement, tested directly with codex exec --sandbox read-only -c windows.sandbox="unelevated":

Action Result
Read app.py in the workdir ✅ allowed
Write a file inside the workdir ✅ denied (Access to the path ... is denied)
Write a file outside the workdir ✅ denied
git status in the target afterwards clean

Real secfoo run -a codex on the SECFOO-10 fixture repo:

Skill Before After
sast failed: every command rejected, target never read ✅ success in about 50s: SQL injection (CWE-89, app.py:19) and command injection (CWE-78, app.py:27), parsed by extract_findings_register_rows
secret-scanning failed, same cause ✅ success: reads app.py and treats the AWS documentation example keys as placeholders, not findings

I re-ran the SAST E2E after rebasing onto current main, which includes #19 and #21 (SECFOO-37 token usage), and it still passes.

Notes for review

  • Windows only: macOS and Linux get exactly the same command as before (covered by a test).
  • Version: verified on codex-cli 0.159.2. Older Codex versions may not know the windows.sandbox key.
  • Override: a user's own windows.sandbox = "elevated" in ~/.codex/config.toml is replaced with unelevated for secfoo runs. Both are sandboxed and read-only, so this isn't a weakening, but it's worth knowing.
  • _IS_WINDOWS is a module-level flag so tests can switch it without patching os.name, which breaks pytest (see the existing note in base.py).

Test plan

  • 2 new tests: Windows gets the flag and stays read-only; other platforms don't get it
  • pytest: 730 passed, 5 failed. The 5 (test_cloud permissions and 4 architecture dashboard tests) fail the same way on main on Windows.
  • Real Codex sast and secret-scanning runs on Windows
  • Optional: Codex smoke run on macOS/Linux to confirm nothing changed there

With no Windows sandbox configured, `codex exec --sandbox read-only`
rejects every command on Windows, reads included ("blocked by policy"),
so Codex never saw the target. Pass `-c windows.sandbox="unelevated"` on
Windows: the restricted-token sandbox needs no admin setup and, verified
on codex-cli 0.159.2, allows reads while denying writes both inside and
outside the workdir.

Real `secfoo run -s secret-scanning -s sast -a codex` on Windows 11 now
succeeds with no rejected commands; SAST finds the planted SQL injection
(CWE-89) and command injection (CWE-78).

The failure message no longer suggests the elevated admin setup, which
turned out to be unnecessary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@karthickmk2001
karthickmk2001 requested a review from vsn411 October 2, 2026 13:44
@karthickmk2001

Copy link
Copy Markdown
Collaborator Author

@vsn411 friendly ping when you have a moment: this fixes the High-priority SECFOO-38 (Codex on Windows). CI is green and it's a small change (2 files). #25 (SECFOO-39) is ready too.

@vsn411
vsn411 merged commit e788a76 into secfoo-com:main Oct 3, 2026
2 checks passed
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.

2 participants