[PR #6123] feat: add allow_tmpdir permission for scoped tmpdir access #11742

Closed
opened 2026-02-16 18:16:41 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6123

State: closed
Merged: No


This PR adds an allow_tmpdir permission that allows file operations in the system's temporary directory without requiring external_directory approval prompts.

The permission.allow_tmpdir: boolean (defaults to false) and is in both global/merged config and per-agent config/schemas.

specifically:

  • external_directory defaults to "ask", prompting for permission on any file operation outside the current working directory
  • In CI/CD and CLI environments, this prompt causes indefinite hangs (see #5888)
  • The existing workaround (external_directory: "allow") permits access to ALL external directories, which is overly broad
  • Requiring users to create a custom agent just to allow tmpdir access is high friction

security:

  • Symlink resolution prevents traversal attacks (critical on macOS where /tmp/private/tmp)
  • Default false maintains current security model (opt-in)
  • Only affects tmpdir; other external directories still follow external_directory settings

tests:

  • Filesystem.tmpdir(), isInTmpdir(), containsResolved() utilities tested for symlink resolution and non-existent paths
  • Bash tool tests verify allow_tmpdir: true permits tmpdir workdir while external_directory: deny is set
  • Bash tool tests verify allow_tmpdir: true does not bypass external_directory for non-tmpdir paths

usage example:

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
    "allow_tmpdir": true,
    "external_directory": "ask"
  }
}

Or per-agent:

{
  "agent": {
    "build": {
      "permission": {
        "allow_tmpdir": true
      }
    }
  }
}

related:

  • #4743 - Feature request for tmpdir access
  • #5888 - CLI mode hangs due to external_directory prompts
  • #5395 - Split external_directory into read vs write
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6123 **State:** closed **Merged:** No --- This PR adds an `allow_tmpdir` permission that allows file operations in the system's temporary directory without requiring `external_directory` approval prompts. The `permission.allow_tmpdir: boolean` (defaults to `false`) and is in both global/merged config and per-agent config/schemas. specifically: - `external_directory` defaults to `"ask"`, prompting for permission on any file operation outside the current working directory - In CI/CD and CLI environments, this prompt causes indefinite hangs (see #5888) - The existing workaround (`external_directory: "allow"`) permits access to ALL external directories, which is overly broad - Requiring users to create a custom agent just to allow tmpdir access is high friction security: - Symlink resolution prevents traversal attacks (critical on macOS where `/tmp` → `/private/tmp`) - Default `false` maintains current security model (opt-in) - Only affects tmpdir; other external directories still follow `external_directory` settings tests: - `Filesystem.tmpdir()`, `isInTmpdir()`, `containsResolved()` utilities tested for symlink resolution and non-existent paths - Bash tool tests verify `allow_tmpdir: true` permits tmpdir workdir while `external_directory: deny` is set - Bash tool tests verify `allow_tmpdir: true` does not bypass `external_directory` for non-tmpdir paths usage example: ```json { "$schema": "https://opencode.ai/config.json", "permission": { "allow_tmpdir": true, "external_directory": "ask" } } ``` Or per-agent: ```json { "agent": { "build": { "permission": { "allow_tmpdir": true } } } } ``` related: - #4743 - Feature request for tmpdir access - #5888 - CLI mode hangs due to external_directory prompts - #5395 - Split external_directory into read vs write
yindo added the pull-request label 2026-02-16 18:16:41 -05:00
yindo closed this issue 2026-02-16 18:16:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11742