GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — permission: grep shows lines from files whose read rule asks or denies · Issue #64623 · anomalyco/opencode

permission: grep shows lines from files whose read rule asks or denies #64623

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
permission: grep shows lines from files whose read rule asks or denies#64623
Copy link
Labels
area/coreAgent loop, tools and configpending closeplatform/macosmacOStriagingtype/featureNew behaviour or an improvementversion/v2OpenCode 2.x

Description

@knp-sap
knp-sap
opened on Nov 18, 2026
Issue body actions

Description

The grep tool checks its permission against the search pattern only. It then searches with --hidden and quotes the matching lines of every file, without checking the read rules for those files.

With the default agent rules, reading *.env asks, but grep is allowed. So grep shows the contents of a .env file without asking. A read deny rule is bypassed the same way.

Earlier reports of this were closed by the stale bot: #17073 and #29674.

Plugins

None needed to reproduce.

OpenCode version

2.3.0, and current dev

Steps to reproduce

  1. In a directory that is not a Git repository, create .env containing API_KEY=example-value.
  2. Ask the agent to read .env. OpenCode asks for permission.
  3. Ask the agent to grep for API_KEY. The result shows API_KEY=example-value without asking.

Operating System

macOS 27.2.1

Activity

  1. opencodejr commented on Nov 18, 2026

    @opencodejr
    opencodejrBot
    on Nov 18, 2026
    Contributor
    More actions

    Thanks for the clear report and for the reproduction steps.

    I think this is a duplicate of #64059. It reports the same gap: grep (and glob) check their permission only against the search pattern, so a read rule on *.env that asks or denies is bypassed when the agent searches file contents. The code agrees: packages/core/src/tool/plugin/grep.ts asserts resources: [input.pattern] and does not check read for the files it matches.

    The tools docs describe this as current behaviour: grep is checked "with the requested pattern, not the search path". The permissions page says the same. That is why #64059 is being tracked as a change to how these permissions work.

    Possible duplicates and related issues, ordered from most to least likely:

    • grep and glob assert their pattern as the permission resource, so path-based policy is impossible #64059: the same problem, grep/glob bypassing path-based read rules such as *.env. Its discussion also covers the directory-search case you describe, where each matched file would need to be checked.
    • bash: recursive file-reading commands (grep -r, rg, ls -R) bypass filename-pattern deny rules #56545: the same kind of gap for recursive shell commands (grep -r, rg, ls -R) and filename deny rules.
    • [FEATURE]: Protect .env files in grep/glob results, not just direct read #17073 and The Read, Glob, and Grep tools do not verify these rules before execution. #29674: the earlier reports you mentioned, closed for inactivity.

    I'm closing this issue now as a duplicate of #64059. Please add your details there, and consider linking your PR #64625 from that issue so maintainers see it together with the discussion. If you think this is a different problem, replying here reopens this issue.

  2. opencodejr
    closed this as a duplicateof grep and glob assert their pattern as the permission resource, so path-based policy is impossible #64059 on Nov 18, 2026
  3. opencodejr
    added
    area/coreAgent loop, tools and config
    platform/macosmacOS
    type/featureNew behaviour or an improvement
    version/v2OpenCode 2.x
    on Nov 18, 2026
  4. knp-sap commented on Nov 18, 2026

    @knp-sap
    knp-sap
    on Nov 18, 2026
    ContributorAuthor
    More actions

    I think this is a bug rather than a duplicate of #64059. With the default agent rules, reading *.env asks, but grep is allowed and searches hidden files, so it returns .env contents that the defaults are meant to protect. No custom configuration is needed, and your review of #64625 reproduced it on the base.

    #64059 asks for path-based rules for grep and glob in general. #64625 is the narrow fix: it leaves out matches from files that the existing read rules don't allow, and it doesn't change glob or the permission vocabulary.

  5. opencodejr
    reopened this on Nov 18, 2026
  6. opencodejr
    added
    pending close
    triaging
    on Nov 18, 2026
  7. opencodejr commented on Nov 18, 2026

    @opencodejr
    opencodejrBot
    on Nov 18, 2026
    Contributor
    More actions

    Thanks for explaining, and for the PR.

    You're right that no custom configuration is needed. By default, every agent asks before a read of *.env, but every other action is allowed, grep included, so a search can return .env lines without a prompt. Nobody disputes that this happens.

    I still think #64059 is the right place to track it. The tools docs and the permissions page describe this as current behaviour: grep is checked "with the requested pattern, not the search path". The defaults only cover read actions. So making grep respect read rules is a change to how the permission works, and #64059 is tracking that change. That issue also covers your exact case: its discussion notes that a directory search would need each matched file checked, which is what #64625 does.

    #64625 now describes itself as "the grep half" of #64059, so maintainers will see it there as the narrow option. Whether it lands as a fix to the defaults or as part of a wider change to grep and glob is their call. If a maintainer decides this is a bug in the default rules and should be tracked separately, they can reopen this issue.

    In the meantime, the shipped explore agent and any agent you set up with your own rules can deny grep or set it to ask if you want to keep it away from .env files.

  8. opencodejr
    closed this as a duplicateof grep and glob assert their pattern as the permission resource, so path-based policy is impossible #64059 on Nov 18, 2026
  9. opencodejr commented on Nov 18, 2026

    @opencodejr
    opencodejrBot
    on Nov 18, 2026
    Contributor
    More actions

    Closing this now as a duplicate of #64059, which tracks making grep (and glob) respect path-based read rules such as the default *.env ask. Your case, a directory search that returns .env lines without asking, is covered there. Your PR #64625 now describes itself as the grep half of that issue, so maintainers will consider it there.

    A correction to my last reply: the shipped explore agent allows grep, so it doesn't keep grep away from .env files. An agent with your own rules can set grep to ask or deny.

    Thanks for the clear report and the fix. If something here isn't covered by #64059, please open a new issue.

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

    area/coreAgent loop, tools and configpending closeplatform/macosmacOStriagingtype/featureNew behaviour or an improvementversion/v2OpenCode 2.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.