Skip to content

fix(security): CodeAgent write tools missing blocklist/guardrails #955

@kovtcharov-amd

Description

@kovtcharov-amd

Problem

write_python_file, edit_python_file, write_markdown_file, and replace_function in src/gaia/agents/code/tools/file_io.py only call self.path_validator.is_path_allowed() — they have no blocklist check, no sensitive-file protection, no size limit, no audit logging, and no backup.

The PR #495 fixes for write_file and edit_file added full validate_write / is_write_blocked guardrails, but these four tools were missed.

Impact

  • ChatAgent: Not affected (strips these tools from the registry)
  • CodeAgent: An LLM could use write_python_file to write to a blocked path if it's within the allowlist

Fix

Apply the same PathValidator.validate_write() + is_write_blocked() pattern used in write_file (line 530) and edit_file (line 622) to all four tools.

Files

  • src/gaia/agents/code/tools/file_io.py — lines 224-244, 268-343, 502-527, 874-978

Found during code review of #495.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions