Skip to content

Restrict worker follow-up artifact writes#98

Merged
pmbstyle merged 2 commits into
mainfrom
codex/fix-worker-follow-up-file-overwrite-vulnerability
May 17, 2026
Merged

Restrict worker follow-up artifact writes#98
pmbstyle merged 2 commits into
mainfrom
codex/fix-worker-follow-up-file-overwrite-vulnerability

Conversation

@pmbstyle
Copy link
Copy Markdown
Owner

Motivation

  • Fix a security regression where worker-result follow-up could invoke fs_write against arbitrary workspace-relative paths based on untrusted worker output, allowing overwrites of sensitive workspace files.
  • Limit automatic persistence of worker-returned content to durable artifact roots to prevent prompt-injected worker output from corrupting runtime configuration or templates.
  • Preserve existing worker-local and explicitly shared-path behavior for normal worker operations while narrowing the follow-up route surface.

Description

  • Narrow the worker-followup guidance so the follow-up model is told to use fs_write only for paths under the durable roots (reports/ and artifacts/).
  • Change the worker-followup tool context so ctx includes workspace_root, allowed_paths=list(_DURABLE_WORKSPACE_ROOTS), and restrict_to_allowed_paths=True when resolving follow-up tool calls.
  • Hardening of filesystem helpers by introducing a _FilesystemPaths helper and a restrict_to_allowed_paths flag in _resolve_tool_path so callers can force enforcement of allowed_paths checks.
  • Add unit tests that assert fs_write under a restricted context can write to reports/ but is blocked from overwriting sensitive workspace files, and a test that the follow-up tool context is configured with the restricted paths.

Testing

  • Ran static checks with uv run ruff check which passed for the modified files.
  • Ran formatting checks with uv run black --check which passed for the changed files.
  • Performed smoke validations via uv run python small scripts that exercised fs_write under a restricted context and exercised _get_worker_followup_tools, confirming allowed writes succeed and disallowed writes are blocked.
  • Attempted to run uv run python -m pytest for the new tests but pytest could not be executed in the current environment because pytest is not installed in the active venv and dev-dependency installation was blocked by network/package fetch errors.

Codex Task

@pmbstyle pmbstyle self-assigned this May 17, 2026
@pmbstyle pmbstyle merged commit cfe3287 into main May 17, 2026
4 checks passed
@pmbstyle pmbstyle deleted the codex/fix-worker-follow-up-file-overwrite-vulnerability branch May 17, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant