Skip to content

Security Issue: Arbitrary File Write Vulnerability in Code Modification Logic #1310

Open
@glmgbj233

Description

@glmgbj233

file:engineer/engineer.py

Description

In the current implementation of _edit_repo_file(), no security checks are performed on:

  1. The file path being modified
  2. The content being written to the file

This introduces potential security vulnerabilities that could result in:

  1. Malicious large language model (LLM) output writing to sensitive system files
  2. Path traversal attacks modifying files outside of the intended directory
  3. No validation of file extensions or content types

Affected Components

  1. File path handling in _find_relevant_files() — only prepends /tmp/repo/ without proper sanitization
  2. Direct file operations in _edit_repo_file() — blindly trusts the changes generated by the LLM

Steps to Reproduce

  1. Craft a malicious prompt that causes the LLM to generate harmful file modifications
  2. Observe the system executing these changes without validation

Recommended Fixes

  1. Implement path sanitization and validation
  2. Add a whitelist for allowed file extensions
  3. Validate content against dangerous patterns
  4. Introduce sandboxing for file operations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions