Skip to content

fix(security): prevent search_code symlink path escape - #80

Closed
study8677 wants to merge 1 commit into
mainfrom
codex/fix-file-exfiltration-vulnerability
Closed

fix(security): prevent search_code symlink path escape#80
study8677 wants to merge 1 commit into
mainfrom
codex/fix-file-exfiltration-vulnerability

Conversation

@study8677

Copy link
Copy Markdown
Owner

Motivation

  • search_code walked workspace paths and read files without resolving targets or enforcing is_safe_path, allowing in-repo symlinks to disclose files outside the project.
  • The structured-agent tooling exposes these tool outputs to LLMs and persists raw outputs, increasing the severity of any disclosure.

Description

  • Resolve each candidate path in search_code and skip any target where is_safe_path(ws, resolved) is false so symlink targets outside the workspace are not read.
  • Read file contents from the resolved, validated path (resolved.read_text(...)) instead of the original fpath.
  • Add a regression test test_search_code_skips_symlink_outside_workspace that creates an in-repo symlink to an outside file and asserts search_code does not return matches from that symlink.
  • Modified files: engine/antigravity_engine/hub/ask_tools.py and engine/tests/test_ask_tools.py.

Testing

  • Ran pytest -q engine/tests/test_ask_tools.py -k "search_code", which completed successfully with 7 passed, 11 deselected.
  • The new regression test verifies symlink escapes are blocked and the existing search behavior is preserved for normal files.

Codex Task

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