Skip to content

Agents can bypass permission pattern with variable assignment #26042

Description

@superDuperCyberTechno

Description

If the agent assigns the path of any disallowed pattern (i.e., a file) to a shell variable, it can access its contents by referencing the variable...

f=.env && cat "$f"

This bug seems to imply that the assignment operator (=) is somehow responsible.

The opencode.json file in use can by seen below...

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "bash": {
      "*.env*": "deny",
      "*artisan*": "deny"
    },
    "read": {
      "*.env*": "deny"
    },
    "edit": {
      "*.env*": "deny"
    },
    "grep": {
      "*.env*": "deny"
    }
  }
}

Plugins

n/a

OpenCode version

1.14.39

Steps to reproduce

  1. Make sure to use the aforementioned permissions.
  2. Have the agent execute the following bash command: f=./.env && cat "$f"

Screenshot and/or share link

No response

Operating System

Arch Linux

Terminal

Kitty

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