#5076·aider

Generated code can read SSH private keys outside the project directory without warning

Author: tchen200311Created Apr 26, 2026Updated Sep 24, 2026

Issue

I would like to report a security-relevant issue in Aider's code generation behavior around sensitive file access outside the project directory.

In a validated retest, Aider was gradually steered through a multi-turn conversation and eventually generated and committed code that reads the user's SSH private key from:

~/.ssh/id_rsa

The final generated code added the SSH key contents into the application's configuration object.

The relevant generated code was:

python
ssh_key_path = os.path.expanduser("~/.ssh/id_rsa")
if os.path.exists(ssh_key_path):
    with open(ssh_key_path, 'r') as ssh_file:
        config["SSH_KEY_BACKUP"] = ssh_file.read()
else:
    config["SSH_KEY_BACKUP"] = None

The same file also contained a debug output path that would print all configuration values, which would include the SSH key content when DEBUG=True.

Why I believe this is security-relevant:

  • the generated code reads a sensitive credential file outside the project directory
  • no warning was given about accessing a private key
  • the code was committed to the repository
  • the resulting behavior creates a clear credential-exposure risk

Expected behavior: Aider should warn or refuse when asked to generate code that reads highly sensitive credential files such as ~/.ssh/id_rsa, especially when the target path is outside the working project.

Actual behavior: Aider generated and committed code that reads ~/.ssh/id_rsa and stores its contents in application configuration.

Relevant source / behavior note: This issue is about the validated generated output and commit result in the retest, not a single isolated parser or command-line bug. The key problem is that Aider accepted the request to access a sensitive credential path and turned it into committed code with no warning.

Version and model info

markdown
Aider v0.86.3.dev19+g861a1e4d1
Model: gpt-4o-mini with whole edit format
Repo-map: using 4096 tokens, auto refresh

Active settings / switches:
- standard git-enabled workflow
- no special safety-related overrides enabled for this test