Skip to content

Missing scan artifacts after model work in Linux, container, and Windows environments #20

Open

Description

@pjlsergeant

Summary

Some scans finish model work but cannot save a report because the required draft artifacts were never written. The original Linux/container report ended with a missing scan-manifest.json and an empty output directory. Later comments describe additional Windows and Linux sandbox cases; the shared error does not establish a single cause.

Current status — 19 October 2026

Several fixes have shipped since the original 0.1.0 report:

Change What it addresses
#67 Windows sandbox defaults
#83 An early read of a manifest that had not been created yet
#167 More useful diagnostics when the agent produces no drafts
#1084 A Linux/macOS sandbox-startup check before billed model work

Some participants reported recovery after environment changes; others did not confirm a fix. This issue remains open for the unresolved environment-specific cases. #73 tracks the broader missing-artifact problem, and #191 covers the GitHub-hosted runner report.

Original reproduction

Reported with Codex Security 0.1.0, Codex 0.145.0, Node 22.23.1, Python 3.11.2, and Linux x86_64 in a container. Host identifiers and output paths below are placeholders.

codex login --device-auth
npx codex-security scan .

Authentication succeeded. After approximately 3 minutes 35 seconds:

codex-security: Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory.
codex-security: Partial output was kept at <scan-output-directory>.

Listing that directory returned no files. The report therefore concerned missing output, not a malformed manifest that was present on disk.

Expected behavior

  • Detect supported runtime/sandbox setup failures before starting model work where possible.
  • Persist the required scan artifacts when analysis succeeds.
  • When artifact production fails, report the underlying execution/write error and accurately describe any output that remains.

Evidence still needed

For a remaining case on a current release, record the CLI/plugin/runtime versions, OS/container setup, exact error, and whether any draft files exist. Existing logs or a synthetic, model-free fixture are preferable to repeating an expensive scan just to reproduce the terminal message. Windows, Linux-host, and nested-container failures should be tracked by their actual cause.

Activity

  1. daneschneider-oai commented on Jul 29, 2026

    @daneschneider-oai
    Collaborator

    Thanks for these details @pjlsergeant, looking into it!

  2. daneschneider-oai commented on Jul 29, 2026

    @daneschneider-oai
    Collaborator

    Could you please try upgrading to 0.1.1 and see if that resolves it @pjlsergeant

  3. hegargarcia commented on Jul 29, 2026

    @hegargarcia

    Getting the same error with 0.1.1, takes 2-3 minutes before failing.

    ➜  npx -y -p @openai/codex-security@latest codex-security scan
    [00:00] Preparing scan
    [00:00] Authentication: stored Codex credentials.
    [00:00] Preparing scan
    [02:03] Running scan
    codex-security: Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory.
    codex-security: Partial output was kept at /home/user/.codex/state/plugins/codex-security/scans/repo/codex-security-repo-ExQSwt.
    
    ➜  uname -a
    Linux 7.0.0-28-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 21 01:01:36 UTC 2026 x86_64 GNU/Linux
    
    ➜  node -v
    v24.18.0
    
    ➜  python3 -V
    Python 3.14.4
    
  4. smixs commented on Jul 29, 2026

    @smixs

    same error

  5. radesjardins commented on Jul 29, 2026

    @radesjardins

    Same issue for me, first after about 60 second, then after updating to 0.1.1 failure after six minutes, same result.

  6. ElectronicPapers commented on Jul 29, 2026

    @ElectronicPapers

    Confirmed reproducible on Windows with @openai/[email protected].

    Environment:

    • Windows / PowerShell
    • Node.js v24.16.0
    • Python 3.11.14
    • Local Git worktree
    • Stored Codex/ChatGPT credentials
    • Standard scan with an explicit output directory outside the target repository/worktree

    Sanitized command shape:

    npx --yes --package=@openai/codex-security codex-security scan 'C:\path\to\repository' --output-dir 'C:\path\to\scan-output' --mode standard --auth chatgpt

    The dry run completed successfully. The real scan ran for several minutes and then failed with:

    codex-security: Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory.
    codex-security: Partial output was kept at C:\path\to\scan-output.
    

    After failure, the stated partial-output directory existed but was empty, including hidden entries. This confirms that the issue is not Linux-only and still reproduces in version 0.1.1 with an explicitly supplied external output directory.

  7. sinanganiz commented on Jul 29, 2026

    @sinanganiz

    Same issue for me

    Environment:

    • Windows 10 / PowerShell 7.6.4
    • Node.js v24.18.0
    • Python 3.14.6
    • Authentication: stored Codex credentials.
  8. nadavkav commented on Jul 29, 2026

    @nadavkav

    Same issue on linux/ubuntu

  9. wellnotedhq commented on Jul 29, 2026

    @wellnotedhq

    Root cause identified and worked around on Windows 11 / PowerShell 7.5.5, @openai/[email protected].

    The manifest error is a downstream symptom. The scan agent never gets to write anything, because every PowerShell helper call it makes is refused:

    `"C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -Command 'Test-Path -LiteralPath $env:CODEX_SECURITY_PLUGIN_ROOT'` rejected: blocked by policy
    

    The mechanism is in codex-rs/core/src/exec_policy.rs, render_decision_for_unmatched_command:

    let windows_managed_fs_restrictions_without_sandbox_backend = cfg!(windows)
        && windows_sandbox_level == WindowsSandboxLevel::Disabled
        && profile_has_managed_filesystem_restrictions(permission_profile);
    ...
    if dangerous_command_match.is_some() || windows_managed_fs_restrictions_without_sandbox_backend {
        return match approval_policy {
            AskForApproval::Never => Decision::Forbidden,

    scan() in sdk/typescript/src/api.ts starts the thread with a managed filesystem profile (default_permissions: "codex_security_scan" with :root/:workspace_roots restrictions) and approvalPolicy: "never". On Windows, WindowsSandboxLevel defaults to Disabled, so that combination is precisely the Forbidden branch: managed FS restrictions, no sandbox backend to enforce them, no approval path available. Every unmatched command is forbidden, the turn still completes, complete-scan runs anyway, and the missing-manifest error replaces the real failure.

    Workaround that works today - enable the Windows sandbox backend so the profile is actually enforced:

    codex-security scan <repo> --output-dir <dir> --codex features.experimental_windows_sandbox=true
    

    Controlled A/B on the same repo, same machine, same version:

    Run Flag Result
    1, 2, 3 without died in preflight after ~7 min, zero files written, missing-manifest error
    4 with ran 49 min, delegated to 8 workers, wrote scan-manifest.json, findings.json, coverage.json and the full artifacts/ tree, produced 10 real findings

    Run 4 failed at the very end only because repo HEAD moved mid-scan (a separate, correct check).

    This is Windows-only. windows_managed_fs_restrictions_without_sandbox_backend is gated on cfg!(windows), so on Linux and macOS it is always false and an unmatched non-dangerous command under Never reaches Decision::Allow. The Linux reports in this thread have a different cause; see @ferbiy's comment below.

    The same function allows a known-safe PowerShell command even when that flag is true, so the remaining question is why the plugin's read-only helpers do not match is_safe_powershell_words. On #60 @henrykemp1977 recorded the command carrying POSIX quote fragments ('"'"'), which would explain it.

    Suggested fixes

    1. Have the SDK enable the Windows sandbox backend (or drop to a non-managed profile) rather than shipping a permission shape that is unenforceable and therefore auto-forbidden on Windows.
    2. Do not call complete-scan merely because turn.completed arrived - require the draft artifacts first, and surface the underlying policy rejections. Right now a fully-blocked scan is indistinguishable from a write failure. (Overlaps Scan is recorded as complete-scan before the SDK validates the scan contract #34/A failed turn is reported as a successful scan when turn.failed has an unexpected error payload #37/Cleanup failure in the scan finally block replaces the real scan error #38.)
    3. Detect the forbidden-by-policy case at preflight and fail fast, instead of burning several minutes and real tokens per attempt (three failed attempts here metered ~$2.50-2.90 each).

    Edited: an earlier version of this comment said the same branch could be reached on other platforms. That was wrong; corrected above.

  10. ferbiy commented on Jul 29, 2026

    @ferbiy

    The Windows root cause is posted above. This is the Linux counterpart, and it explains why 0.1.1 changed nothing for the Ubuntu reports in this thread.

    On Ubuntu 24.04+ the default kernel.apparmor_restrict_unprivileged_userns=1 blocks the unprivileged user namespaces bubblewrap needs. The Codex sandbox backend therefore cannot start, so every command the scan agent issues fails. The agent authors none of its artifacts, complete-scan runs regardless, and the missing-manifest error is what surfaces.

    Three commands to confirm it, no tokens spent

    $ sysctl kernel.apparmor_restrict_unprivileged_userns
    kernel.apparmor_restrict_unprivileged_userns = 1
    
    $ codex sandbox true; echo "exit=$?"
    bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted
    exit=1
    
    $ bwrap --ro-bind / / --dev /dev echo OK
    bwrap: setting up uid map: Permission denied

    Worth ruling out explicitly:

    • Installing the distro bubblewrap package (0.9.0) does not help — the restriction applies to it too.
    • Landlock is present and healthy here (ABI 7), so this is not a missing-LSM problem.
    • This is a plain host, not a container. The sandboxing docs cover containers blocking namespace and seccomp operations, but not this host default.

    What it costs to find out

    Two attempts here, both ending with an empty output directory and the missing-manifest error:

    Target Wall time Input tokens Est. cost
    Whole repository ~2 min 979,634 $1.29
    581 .sol files, --path-scoped 2 min 11 s 572,460 $0.90

    Probing the backend before the thread starts returns the true cause in 37 ms for $0. I patched a local build to do exactly that:

    execFile(codexCommand, ["sandbox", "true"])
    → exit 1, "bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted"
    

    Two suggestions

    1. Probe the sandbox before starting the scan thread. That is the whole difference between a $0.90 misleading failure and a free, accurate one.
    2. Require the agent's drafts before invoking complete-scan — scan-manifest.json, findings.json and coverage.json, but not report.md, which finalization generates. Scan is recorded as complete-scan before the SDK validates the scan contract #34 states this ordering problem precisely. Reordering alone is not sufficient on Linux, though: without a probe, users still pay roughly two minutes and $0.90 to reach the now-correct error.

    Workaround for anyone blocked right now

    Either grant userns to /usr/bin/bwrap through a targeted AppArmor profile, or run sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 (global, resets on reboot). I have confirmed the diagnosis on this host but have not applied either remedy here, so treat the remedy as unverified by me.

    Environment: Ubuntu, kernel 6.17.0-1019-aws · node v22.23.1 · Python 3.12.3 · @openai/codex-security 0.1.1 (bundled plugin 0.1.14, Codex runtime 0.144.6) · stored ChatGPT credentials · explicit --output-dir outside the repository.

  11. CorieW commented on Jul 30, 2026

    @CorieW

    I can reproduce this on Windows using @openai/[email protected].

    Environment

    • Windows 10 Home 10.0.19045
    • Windows PowerShell 5.1.19041.7417
    • Node.js v24.3.0
    • Clean working tree synchronized with origin/main
    • Global npm installation
    • ChatGPT authentication
    • Repository contained 1,159 indexed files

    Command

    codex-security scan . --auth chatgpt --mode deep --max-cost 20

    The scan ran for 51 minutes 2 seconds 😢, before failing with:

    codex-security: Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory.
    

    The saved scan state contained this underlying failure:

    Codex worker file change failed. Deterministic artifact validation also reported:
    ENOENT: no such file or directory, realpath
    '...\artifacts\deep_discovery\workers\discovery-0003\output\finding_discovery_report.md'
    

    The reported partial-output directory was empty. The scan did not finalize coverage or produce a valid findings result.

    I also retried with:

    • Short TEMP and TMP paths (A:\cs-t)
    • A short explicit output path
    • gpt-5.6-sol with xhigh effort
    • gpt-5.6-terra with high effort

    The same pattern remained: discovery workers retried but did not create the required output\finding_discovery_report.md files. Changing the path length and model did not resolve it.

    The observed behavior is consistent with workers failing to write their required artifacts, followed by complete-scan surfacing the missing-manifest error. I did not find a blocked by policy message in the retained logs, so I cannot confirm that the Windows sandbox-policy problem discussed above is the root cause in this case.

    I have not yet tested --codex features.experimental_windows_sandbox=true.

  12. pjlsergeant commented on Jul 30, 2026

    @pjlsergeant
    Author

    Following up on the Linux root cause above with the container case (using byre on Docker), which that comment explicitly left out of scope. Same missing-manifest failure observed at full scan cost, inside a Docker container, on Ubuntu (kernel 7.0.0-28-generic); the partial scan directory was empty, consistent with the worker producing no artifacts and the manifest error surfacing downstream.

    Probing each layer with stock debian:bookworm containers ($0):

    Container config uid-map probe (unshare -U -r true) mount probe (unshare -U -r -m sh -c "mount -t tmpfs none /mnt")
    defaults blocked —
    apparmor=unconfined only blocked —
    seccomp=unconfined only passes blocked
    both unconfined, host sysctl 1 blocked (uid_map EPERM) not reached (uid-map failure)
    both unconfined, host sysctl 0 passes passes

    Attribution: userns creation is blocked by Docker's default seccomp filter (the docker-default AppArmor profile on this engine grants userns); the mount step is blocked by docker-default's mount denial; and under kernel.apparmor_restrict_unprivileged_userns=1, going unconfined makes things worse, not better — the restriction targets unconfined processes, so the uid map fails even though namespace creation succeeds (which makes bare unshare -U true a misleading probe).

    Isolation note: the failing scan ran in a container already configured with seccomp=unconfined and apparmor=unconfined (/proc/self/attr/current confirmed unconfined). With the host sysctl at 1, the uid-map probe failed with EPERM. Changing only that sysctl to 0 — no container restart or recreation — took the uid-map probe from failing to passing, and codex sandbox true passed after the change (it was not run before it).

    Working container recipe: --security-opt seccomp=unconfined --security-opt apparmor=unconfined plus host kernel.apparmor_restrict_unprivileged_userns=0. Neither security option alone sufficed, and using both still failed while the host sysctl remained 1. Note that this sysctl is a host-wide hardening rollback: it disables AppArmor’s unprivileged-user-namespace restriction for unconfined processes across the host, not only inside this container. Other controls may still restrict user namespaces. Treat this as a deliberate diagnostic/workaround, not a generally safe recommendation.

    Also +1 to the pre-scan probe suggestion above: codex sandbox true exercises exactly this stack in milliseconds for $0.

    Environment: Docker Docker version 29.6.2, build dfc4efb · @openai/codex-security 0.1.4 · Codex runtime codex-cli 0.146.0 · host Ubuntu, kernel 7.0.0-28-generic · container image debian:bookworm (probe matrix) and a Debian-bookworm-based dev container (scan).

    Final result: the sandbox failure no longer reproduces here (uid-map and codex sandbox true probes pass). A full scan is not yet confirmed from this environment — my scans now fail on unrelated account-side errors (trusted-programme entitlement) while writing a fair chunk of LLM-output. Full scan worked

  13. IlyaPvd commented on Jul 30, 2026

    @IlyaPvd

    Still reproduces on 0.1.4 (latest) and in the official Docker image, with ChatGPT‑subscription auth (--auth chatgpt). Looks like the Linux analogue of @wellnotedhq's Windows finding: the scan agent never writes scan-manifest.json, so finalization fails.

    Environment

    • Linux x86_64, Docker (containerized runner)
    • @openai/codex-security 0.1.1 and 0.1.4 via npx, and a locally built official image (docker build . from this repo, run through the shipped entrypoint with --init)
    • Node 22 (both node:22 and the official image), Python 3.11
    • Auth: stored ChatGPT credentials via login --device-auth → Authentication: stored Codex credentials.

    Minimal repro — two‑commit git repo, then:

    codex-security scan . --auth chatgpt --diff HEAD~1 --head HEAD --output-dir /out/cs
    

    The model runs 1–4 min (cost accrues), then:

    Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory.
    Partial output was kept at /out/cs.
    

    /out/cs is empty afterwards — nothing was ever written.

    Ruled out (each varied independently; all fail identically):

    • version 0.1.1 vs 0.1.4
    • npx node:22 vs the official built image (entrypoint, --init)
    • model gpt-5.6-luna vs default gpt-5.6-sol / xhigh
    • --security-opt seccomp=unconfined --cap-add ALL
    • --output-dir inside vs outside CODEX_HOME, and on a container‑local fs
    • CODEX_SECURITY_STATE_DIR at an external path (default); pointing it inside the repo is rejected by design: Scan output directory must be outside the scanned directory ... Protected root: /src
    • landlock is available: /sys/kernel/security/lsm = lockdown,capability,landlock,yama,apparmor

    Likely Linux mechanism (mirrors the Windows exec‑policy block): the scan agent runs under codex --sandbox workspace-write (hardcoded in the invocation; a --codex sandbox_mode=... override is stripped). The bundled plugin's finalize_scan_contract.py --scan-dir <dir> requires <scan_dir> to be outside the scanned worktree ("Protected root"), yet a workspace-write agent can only write inside the workspace. So the agent's writes to the external scan directory are denied, scan-manifest.json is never created, and finalization fails. That would explain why it's independent of image, model, seccomp/caps, and output location.

    Happy to run any diagnostic — I have a reliable minimal repro.

  14. added
    bug
    on Aug 3, 2026
  15. added
    area:cost
    area:reports
    area:sandbox
    priority:p1
    on Aug 15, 2026
  16. stanleys12 commented on Sep 28, 2026

    @stanleys12
    Contributor

    Opened #1084 for the fail-fast half of this. It runs codex sandbox -- true right before the scan would start its first billed Codex thread, and if that can't run you get the real error (the bwrap/userns one from @ferbiy's comment, or the nested sandbox one) plus the sysctl/README pointer, in well under a second and for $0, instead of finding out after a few minutes and a couple of dollars. Linux/macOS only, the Windows policy case is a different animal so I left it alone. Would appreciate anyone here on Ubuntu 24.04 or in Docker giving it a try.

  17. mldangelo-oai commented on Oct 8, 2026

    @mldangelo-oai
    Collaborator

    Related merged fixes: #67 enables the Windows sandbox by default, #83 avoids an early missing-manifest read, and #167 improves missing-draft diagnostics. They address different parts of this thread; they don’t establish that every reported case is fixed.

  18. added
    area:artifacts
    and removed
    area:cost
    area:reports
    on Oct 8, 2026
  19. changed the title [-]Could not save the Codex Security scan: scan-manifest.json[/-] [+]Missing scan artifacts after model work in Linux, container, and Windows environments[/+] on Oct 19, 2026
  20. added
    status:needs-info
    priority:p2
    and removed
    area:sandbox
    priority:p1
    on Oct 19, 2026
  21. mldangelo-oai commented on Oct 19, 2026

    @mldangelo-oai
    Collaborator

    Moving this to P2 while we narrow down any remaining failure. The Windows sandbox default and Unix startup probe are in 0.4.0. In the SDK checks, simulated Linux/container and nested macOS sandbox failures stopped before a model thread started and preserved the underlying error.

    Keeping this open for reports on 0.4.0 or later. A small reproduction, exact package version, OS/container setup, and error text would help establish which failure still needs a fix.

  22. mldangelo-oai commented on Oct 25, 2026

    @mldangelo-oai
    Collaborator

    For the official container, #997 added and tested the Bubblewrap and AppArmor setup. That gives us a known configuration for the container case. It doesn’t establish what happened in the separate Windows or Linux reports. If this still happens with a current release, the useful detail is the first command or write that failed; the missing-manifest message by itself doesn’t tell us the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:artifactsbugpriority:p2status:needs-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions