Skip to content

[BUG] global audit scans unmanaged Codex session history for hidden Unicode #3036

Closed as duplicate

Description

Describe the bug

APM 0.31.0's global audit scans Codex session history under ~/.codex/sessions/ as deployed content. A literal U+202E RIGHT-TO-LEFT OVERRIDE in an unmanaged session file causes apm audit --ci to fail its content-integrity check and recommend apm audit --strip.

This reproduces with an empty global dependency list. APM did not install or record ownership of the session file.

To Reproduce

  1. In an isolated test home, create ~/.apm/apm.yml:

    name: global-profile
    version: 1.0.0
    targets: [codex]
    dependencies:
      apm: []
      mcp: []
  2. Create ~/.codex/sessions/unmanaged.jsonl with a JSON string containing a literal U+202E character. For example, this Python expression produces the file contents (the character must be literal, not a JSON escape):

    json.dumps({"message": "safe" + chr(0x202E) + "reversed"}, ensure_ascii=False) + "\n"
  3. Run apm lock -g, then run apm audit --ci --no-policy --no-drift from ~/.apm in that same test home.

  4. Observe exit code 1 and the content-integrity finding below.

Expected behavior

Audit excludes unrelated Codex application state such as session history. Hidden-Unicode scanning should still cover deployable primitive locations, including unrecorded files in those locations, and explicit deployment claims.

Environment (please complete the following information):

  • OS: macOS
  • Python Version: 3.14.7
  • APM Version: 0.31.0 (Homebrew); also reproduced with current main

Logs

content-integrity: 1 file(s) with critical hidden Unicode
-- run 'apm audit --strip' to clean Unicode

content-integrity details:
  - unicode: .codex/sessions/unmanaged.jsonl

[x] 1 of 8 check(s) failed

Additional context

The Codex target declares .codex as its root. install_governance includes the whole root prefix, and the audit scanner recursively scans that prefix. This brings session history into the scan despite it being outside the target's primitive locations.

Activity

  1. BrierAinz commented on Sep 20, 2026

    @BrierAinz

    A useful boundary here may be: audit should follow deployable primitive roots, not the client application's whole state root.

    For the Codex target, I would make the regression matrix distinguish these cases:

    • scan managed/deployable primitives under the target, including unrecorded files in locations APM can actually deploy to;
    • do not recursively scan volatile application state such as .codex/sessions/, caches, logs, or history when the package did not deploy there;
    • still scan an explicit package-owned file if a package manifest/lock claims a path under an otherwise excluded subtree;
    • keep apm audit --strip from rewriting unrelated app state, because that would be surprising even when the hidden-Unicode finding is technically real;
    • document the target's "owned primitive locations" separately from the broader client config root.

    That keeps the hidden-Unicode guard useful for shipped instructions/skills/hooks while avoiding a false ownership claim over Codex's runtime history.

  2. DaveMeadAdjust commented on Sep 20, 2026

    @DaveMeadAdjust
    Author

    Closing as a duplicate of #2961, which covers the same over-broad target-root scan of unmanaged Codex/Claude session history and already has a proposed fix in #2962.

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions