Skip to content

[FEATURE]: Protect .env files in grep/glob results, not just direct read #17073

Closed as not planned

Description

@raymelon

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

Permission rules for grep and glob match the search pattern, not the matched file path. So this config:

"grep": { "*.env": "ask" },
"glob": { "*.env": "ask" },
"read": { "*.env": "ask" }

protects direct read calls, but does NOT protect against indirect exposure via grep "SOME_KEY" ., which can still return sensitive matches from .env without ever naming it.

Repro

  1. Add TEST_DB_URL=sensitive-value to .env
  2. Use the config above
  3. Run: grep "TEST_DB_URL" .
  4. OpenCode still returns matches from .env

Expected

Blocked files should be filtered from grep and glob results before the model sees them, the same way direct read protection works.

Prior art

  • opencode-env-protect redacts env values from tool output after execution (The redaction part happens on tool.execute.after, where it replaces sensitive values in tool outputs before the AI sees them.)
  • opencode-ignore already claims to filter blocked files from grep/glob results

Both plugins prove this is achievable natively.

Request

  1. Make grep/glob filter results by matched file path, not just the query pattern
  2. Or add built-in secret file protection for .env, private keys, and credential files
  3. At minimum, document that read path rules do NOT cover grep/glob

Related: #539

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 11, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 11, 2026
  3. github-actions commented on Mar 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Note: #539 (which you already reference) is the original security request that was closed — the concerns raised there appear to still be partially unresolved based on #12196 and this issue.

  4. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. abysslover commented on May 13, 2026

    @abysslover

    Surprisingly... how this could happen...

  6. Grelo4ka commented on Jun 15, 2026

    @Grelo4ka

    this feature is much needed

  7. theRoboxx commented on Jun 22, 2026

    @theRoboxx

    this feature is much needed

    Agree. Better secret management and security is a much needed feature!

  8. Mac-Moneysac commented on Jul 21, 2026

    @Mac-Moneysac

    For me, this feature would be quite nice. Especially, if this would be also true for non-env files that are denied by permission.

  9. martin-braun commented on Aug 12, 2026

    @martin-braun

    grep / webfetch / websearch all enabled makes me nervous about prompt injections due to this issue ..

  10. github-actions commented on Oct 13, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  11. Grelo4ka commented on Oct 14, 2026

    @Grelo4ka

    That's very unfortunate that these issues get closed automatically although just 2 weeks ago the same issue was referenced in another one which was marked as a duplicate

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions