Skip to content

Secret-bearing files (.env, keys, credentials) are indexed and returned to agents #2793

Open

Description

@syaifulizhan

Problem

Tracked secret-bearing files (.env, .env.local, *.pem, *.key, id_rsa*, .npmrc, credentials.json, …) are indexed like ordinary source. Their contents then reach the graph and are returned to AI agents by search_code and get_code_snippet, so indexing a repository can leak its credentials into agent context, transcripts and logs.

Repro: commit a .env containing DB_PASS=example_secret_123, index the repo, then search_code for example_secret — the value comes back verbatim.

Proposal

Skip secret-bearing files during discovery by default (in every index mode), keep templates such as .env.example / .sample / .template / .dist indexed, and add an explicit opt-in config key (index_secret_files, default false) for users who want .env in the graph (e.g. compose ${VAR} resolution or the DotEnv grammar).

I'm aware #1079 asks for richer .env support; the opt-in keeps that path open while making the default safe. If maintainers prefer the opposite default (opt-out), I'm happy to flip it.

I have a tested implementation ready (DCO signed-off) and will open a PR referencing this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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