Practical technical guides / Recent development: openai/codex PR 59291 (merged 2026-11-04)

Skill Discovery Must Run Inside the Turn Sandbox: Codex PR 59291 and Access-Keyed Caches

Codex PR 59291 (4 November 2026) runs skill discovery through the turn permissions and keys the catalog cache by access. A model of the leak and a test to add.

By Sandeep Belgavi · Published 2026-11-04

Codex PR 59291 (4 November 2026) runs skill discovery through the turn permissions and keys the catalog cache by access. A model of the leak and a test to add.

What changed

On 4 November 2026 the Codex repository merged pull request 59291, "Respect turn filesystem permissions during executor skill discovery". Its description states the problem in one sentence: "Direct executor skill discovery used unrestricted filesystem access, bypassing the turn's permission context." It adds a second: "Cached catalogs also needed to account for changes in filesystem access within a turn." The pull request does not name a release, so this guide treats it as a change on the main branch.

A skill is a folder of instructions, and sometimes scripts, that an agent can load when a task matches. Discovering skills means walking configured folders and reading their descriptions. If that walk can see folders the current turn is not allowed to read, a sandboxed turn can still be handed instructions from outside its sandbox. That is the gap the change closes, and the same gap is easy to build into any agent runtime.

How discovery bypassed the sandbox

From the diff, the old executor skill provider looked up the execution environment itself and used an accessor that was not limited by the turn's grants. The fix removes that lookup. Instead, the session builds one filesystem accessor per environment from the permissions the turn was granted, binds each selected skill root to that accessor in a new type, AccessedSelectedCapabilityRoot, and passes those bound roots into skill preparation and discovery. Discovery can now only see what the turn can see.

The second half of the change is the cache. Codex caches the skill catalog for a turn so that it does not walk the filesystem on every step. Before the change, the cache key matched on the turn and the selected roots. After it, each root is paired with an EnvironmentAccessKey, and a cached catalog is reused only if every root's access key still equals the current accessor's key. The tests named in the pull request check exactly the three cases that matter: restricted discovery returns no skills when sandbox access is unavailable, restoring access restores discovery, and changing or restoring access invalidates the catalog cache.

Why the cache key is half of the fix

Bounding the walk is not enough on its own. Suppose discovery runs through the turn's accessor, finds three skills while the turn may read two folders, and caches the result under the turn and the roots. The user then revokes one folder for the rest of the turn. Nothing about the turn id or the root list changed, so the cache hit returns all three skills, including the one the turn can no longer read. The permission check ran once, at a moment that no longer describes the turn.

The general rule: any cache of something derived under a permission must include that permission in its key, or must be invalidated when the permission changes. Codex chose the key. That also gives the cheap path back: when access returns to an earlier state, the earlier catalog is valid again and can be reused.

A model of the three designs

The companion example, an original model in Python and not Codex code, builds a synthetic workspace with an allowed project folder holding two skills and a downloads folder holding an unreviewed one. It compares three discovery designs over four steps.

StepUnrestricted walkRestricted walk, cache by turn and rootsRestricted walk, cache key includes access
1 turn may read project and downloadswalk: 3 skillswalk: 3 skillswalk: 3 skills
2 user revokes downloads mid-turncache: 3 skills, leakcache: 3 skills, leakwalk: 2 skills
3 user restores downloadscache: 3 skillscache: 3 skillscache: 3 skills
4 new turn granted project onlywalk: 3 skills, leakwalk: 2 skillswalk: 2 skills

The unrestricted design leaks in a brand-new turn because the walk ignores the grants. The restricted design with the old cache key leaks only inside a turn, after a permission change, which makes it far harder to notice in testing. The access-keyed design never shows the unreviewed skill when it should not, and at step 3 it reuses the step 1 catalog because the access key is the same again.

The accessor in the example also refuses the two classic path tricks: a sibling folder whose name starts with an allowed prefix, such as project-evil next to project, and a path that climbs out through ... Both raise a permission error because the check resolves the path and compares whole path components.

class Accessor:
    def __init__(self, granted):
        self.granted = sorted(str(Path(g).resolve()) for g in granted)

    def allowed(self, path):
        p = str(Path(path).resolve())
        return any(p == g or p.startswith(g + os.sep) for g in self.granted)

    def cache_key(self):
        return hashlib.sha256('\n'.join(self.granted).encode()).hexdigest()[:12]

key = (turn_id, tuple(roots), fs.cache_key())   # the access fingerprint is part of the key

Audit your own agent runtime

The pattern is not specific to Codex. Any runtime that loads instructions from disk or from a registry has a discovery step, and it is easy for that step to run with the host process's permissions rather than the task's. Questions to ask:

  • Which identity performs discovery? If tools run in a sandbox but skills, prompt templates, hooks or MCP server lists are loaded by the host, the sandbox does not bound what instructions the agent receives.
  • When is the permission evaluated? Once per session, once per turn, or on every access? A grant that can change mid-turn needs either a check on every use or a cache keyed by the grant.
  • What does a cache hit skip? List every check that runs only on a miss. Each one is a check that a stale entry bypasses.
  • Can access come back? Revoking and restoring access should be tested both ways, as the pull request's tests do, because invalidation bugs often hide in the restore path.
  • Do path checks compare components? Prefix string comparison without a separator lets project-evil pass as project.

What belongs in the access key

The key must change whenever the set of things discovery could read changes, and should not change otherwise. In the example it is a hash of the resolved granted roots, sorted, so the same grants in a different order produce the same key. A runtime with richer permissions should include whatever affects reads: the environment or machine the accessor points at, read versus write mode if discovery checks it, and any deny rules inside an allowed root. It should not include raw configuration text, because two spellings of one path would then miss the cache, and it must be computed from the accessor discovery actually uses, not from a separate copy of the configuration that could drift from it. Codex takes the key from the accessor itself, through cache_key(), which ties the two together.

A test to add

Write the three pull request tests in your own runtime's terms. Create two skill folders, grant one, and assert discovery returns only its skills. Revoke the grant within the same turn and assert the next discovery returns nothing from it, even though the turn and roots are unchanged. Restore it and assert the skills return. Then repeat with the cache warm, because the cold path usually works first.

What remains uncertain

The pull request does not say whether any user's turn actually loaded a skill from outside its grants, and it names no release. The table above comes from a model of the design, not from running Codex.

Primary references and authorship

Sources dated on or before 4 November 2026. Original explanation and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/access_keyed_skill_catalog. Views are my own and do not represent any employer, past or present.