chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
@@ -1,59 +1,99 @@
|
||||
# Security
|
||||
# Run Pi safely
|
||||
|
||||
Pi is a local coding agent. It runs with the permissions of the user account that starts it, and it treats files writable by that user as inside the same local trust boundary.
|
||||
Treat model-generated commands and code as untrusted. Pi can read, change, and execute files with the permissions of the account that started it, and it does not ask for approval before every tool call. Extensions, package installers, language servers, and other child processes run with those same permissions unless an operating-system or virtualization boundary restricts them.
|
||||
|
||||
## Project Trust
|
||||
Files, comments, instructions, command output, and model responses can steer the model through prompt injection. Project trust controls which project resources load at startup, but it does not make that content or the resulting actions safe.
|
||||
|
||||
Project trust controls whether pi loads project-local settings, resources, packages, and extensions. It is not a sandbox and it does not restrict what the model can ask tools to do after you start working in a directory.
|
||||
Safety comes from limiting the files, credentials, processes, and network services Pi can access and affect if a generated action is wrong or hostile. Watching the transcript, using project trust, and reviewing changes do not create a security boundary.
|
||||
|
||||
Pi considers a project to have resources that require trust when it finds any of these from the current working directory:
|
||||
## Choose how to run Pi
|
||||
|
||||
Different ways of running Pi place different limits on what generated commands can access:
|
||||
|
||||
| How Pi runs | What remains protected |
|
||||
|---|---|
|
||||
| Directly, with the permissions of its operating-system user | Anything that user cannot access. A dedicated user account can narrow those permissions, but Pi still shares the operating system and network with other users. |
|
||||
| Entirely inside a container, virtual machine, or sandbox | Host files and processes that you do not expose to the environment. Credentials and network services remain accessible if you make them available inside it. This is usually the strongest practical option. |
|
||||
| Outside the isolated environment, with only its built-in tools running inside | Host resources are protected from actions performed through those tools. Pi itself and other extensions remain outside the boundary, so this is a narrower form of isolation. |
|
||||
|
||||
The working folder controls resource discovery and the default location for tools, but it does not prevent commands from accessing other paths available to the Pi process.
|
||||
|
||||
Whichever option you choose, only provide the files and services required for the task. Keep credentials outside the environment where possible, or use narrowly scoped, short-lived credentials. Restrict network access when commands do not need it.
|
||||
|
||||
For setup instructions and the limitations of each isolation method, see [Run Pi in an isolated environment](containerization.md).
|
||||
|
||||
<a id="project-trust"></a>
|
||||
|
||||
## Understand project trust
|
||||
|
||||
Project trust controls whether Pi loads most settings and resources supplied by a working folder. It prevents a folder from silently loading executable extensions before you approve it.
|
||||
|
||||
Project trust is not a complete startup boundary. Pi reads the project `sessionDir` setting while selecting or creating a session, before it resolves project trust. Declining trust prevents the remaining project settings and protected resources from loading, but it cannot undo that initial session-directory lookup.
|
||||
|
||||
Project trust does not limit what tool calls can access or affect. After Pi starts, enabled tools still use the operating-system permissions of the Pi process. Instructions and other content in the folder can also influence the model.
|
||||
|
||||
### Resources protected by project trust
|
||||
|
||||
Pi requires a project-trust decision when it finds any of these resources from the current working directory:
|
||||
|
||||
- `.pi/settings.json`
|
||||
- `.pi/mcp.json`
|
||||
- `.pi/extensions`, `.pi/skills`, `.pi/prompts`, or `.pi/themes`
|
||||
- `.pi/SYSTEM.md` or `.pi/APPEND_SYSTEM.md`
|
||||
- project `.agents/skills` in the current directory or an ancestor directory
|
||||
|
||||
A bare `.pi` directory does not count as a project resource that requires trust.
|
||||
A bare `.pi` directory does not require project trust.
|
||||
|
||||
When an interactive session starts in a project with resources that require trust and no saved decision for the current directory or a parent directory, pi follows `defaultProjectTrust` from global settings. The default value is `"ask"`, which asks whether to trust the project when UI is available. Saved decisions are stored by canonical directory in `~/.pi/agent/trust.json`, and the closest saved decision on the current or parent path applies before the global default.
|
||||
Granting project trust allows Pi to load:
|
||||
|
||||
Trusting a project allows pi to load project resources that require trust, including:
|
||||
- project settings
|
||||
- project MCP servers from `.pi/mcp.json`
|
||||
- extensions, skills, prompt templates, themes, and system-prompt files under `.pi`
|
||||
- missing packages configured through project settings
|
||||
- project-local and project-package extensions
|
||||
|
||||
- `.pi/settings.json`
|
||||
- `.pi` resources such as extensions, skills, prompt templates, themes, and system prompt files
|
||||
- missing project packages configured through project settings
|
||||
- project-local extensions and project package-managed extensions
|
||||
Declining project trust skips those protected resources, except for the initial `sessionDir` lookup described above.
|
||||
|
||||
Declining trust skips protected resources. Context files such as `AGENTS.override.md`, `AGENTS.md`, and `CLAUDE.md` are loaded regardless of project trust unless context loading is disabled. Before trust is resolved, pi only loads context files, user/global extensions, and CLI `-e` extensions. User/global and CLI extensions can handle the `project_trust` event; the first extension that returns a yes/no decision owns the decision.
|
||||
Context files such as `AGENTS.override.md`, `AGENTS.md`, and `CLAUDE.md` load regardless of project trust unless you disable context loading. Treat instructions in a folder as untrusted input even when you decline project trust.
|
||||
|
||||
Non-interactive modes (`-p`, `--mode json`, and `--mode rpc`) do not show a trust prompt. Without an applicable saved trust decision, `defaultProjectTrust: "ask"` and `"never"` ignore such resources, while `"always"` trusts them. Use `--approve`/`-a` or `--no-approve`/`-na` to override project trust for one run.
|
||||
### How Pi chooses a trust decision
|
||||
|
||||
## No Built-in Sandbox
|
||||
A command-line `--approve` or `--no-approve` override applies first. When protected resources exist and there is no command-line override:
|
||||
|
||||
Pi does not include a built-in sandbox. Built-in tools can read files, write files, edit files, and run shell commands with the permissions of the pi process. Extensions are TypeScript modules that run with the same permissions. Package installs, shell commands, language servers, test commands, and other developer tools behave as ordinary local processes.
|
||||
1. User-level and command-line extensions can handle the `project_trust` event. The first extension that returns yes or no owns the decision.
|
||||
2. If no extension decides, Pi looks for a saved decision for the current directory or one of its parents. The closest decision applies.
|
||||
3. If no saved decision applies, Pi follows the global `defaultProjectTrust` setting, whose default is `"ask"`.
|
||||
|
||||
This is intentional. Pi is designed to operate on local source trees, invoke project toolchains, and integrate with the user's existing development environment. A partial in-process sandbox would be easy to misunderstand as a security boundary while still depending on the host shell, filesystem, package managers, credentials, and extension code. Real isolation needs to come from the operating system or a virtualization/container boundary.
|
||||
Saved decisions use canonical directory paths and live in:
|
||||
|
||||
Project trust is only an input-loading guard. It prevents a repository from silently changing pi's settings or extensions before you approve it. It does not make untrusted code, untrusted prompts, or untrusted model output safe. Prompt injection from repository files, comments, documentation, context files, or build output is expected local-agent risk and cannot be reliably prevented by pi.
|
||||
```text
|
||||
~/.pi/agent/trust.json
|
||||
```
|
||||
|
||||
## Running Untrusted or Unmonitored Work
|
||||
Use `/trust` to save a decision for future Pi processes.
|
||||
|
||||
For untrusted repositories, generated code you do not intend to monitor closely, or unattended automation, run pi in a contained environment. Use a container, VM, micro-VM, remote sandbox, or policy-controlled sandbox with only the files and credentials required for the task.
|
||||
### Project trust without an interactive prompt
|
||||
|
||||
Common patterns are documented in [Containerization](containerization.md):
|
||||
Print, JSON, and RPC modes cannot show the built-in trust prompt. If no command-line override, extension, or saved decision applies:
|
||||
|
||||
- run the whole `pi` process inside a container/sandbox
|
||||
- run host pi while routing built-in tool execution into a Gondolin micro-VM
|
||||
- mount only the workspace paths the agent should access
|
||||
- avoid mounting host `~/.pi/agent` unless the container should access host sessions, settings, and credentials
|
||||
- pass the minimum required API keys or use short-lived credentials
|
||||
- restrict network access when the task does not need it
|
||||
- review diffs and outputs before copying results back to trusted systems
|
||||
- `defaultProjectTrust: "always"` loads protected project resources.
|
||||
- `defaultProjectTrust: "ask"` or `"never"` skips them.
|
||||
|
||||
If you bind-mount a host workspace read/write, writes from inside the container or VM can still modify host files. Use read-only mounts or copy files into and out of the sandbox when you need stronger protection from unintended writes.
|
||||
Use `--approve` or `--no-approve` when an automated run needs an explicit one-time decision.
|
||||
|
||||
## Reporting Security Issues
|
||||
## Reduce impact and improve recovery
|
||||
|
||||
To report a security issue, follow the repository [Security Policy](https://github.com/earendil-works/pi-mono/blob/main/SECURITY.md). Do not open a public issue for security-sensitive reports.
|
||||
These practices do not replace isolation, but they reduce exposure or make recovery easier:
|
||||
|
||||
Expected local-agent behavior, lack of a built-in sandbox, prompt injection from untrusted content, and behavior of user-installed extensions or skills are generally outside the security boundary unless the report demonstrates a real privilege-boundary bypass or shows how pi grants access that the local user did not already have.
|
||||
- Give Pi access only to files and services required for the task.
|
||||
- Use snapshots, backups, or version control before substantial changes.
|
||||
- Review extensions and packages before loading them. Extensions execute inside the Pi process.
|
||||
- Prefer narrowly scoped, short-lived credentials.
|
||||
- Review diffs and generated output before applying results to another system.
|
||||
- Review sessions before exporting or sharing them. They can contain prompts, tool arguments, command output, file contents, and credentials exposed during the conversation.
|
||||
|
||||
## Report a security issue
|
||||
|
||||
Follow the repository [Security Policy](https://github.com/earendil-works/pi/blob/main/SECURITY.md). Do not open a public issue for a security-sensitive report.
|
||||
|
||||
Expected local-agent behavior, prompt injection from untrusted content, lack of a built-in sandbox, and behavior from user-installed extensions or skills are generally outside the security boundary unless the report demonstrates a privilege-boundary bypass or access that the local user did not already have.
|
||||
|
||||
Reference in New Issue
Block a user