UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

91 lines (59 loc) • 8 kB
# Security senpi 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. ## Project Trust Project trust controls whether senpi 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. senpi considers a project to have resources that require trust when it finds any of these from the current working directory: - `.senpi/settings.json` - `.senpi/extensions`, `.senpi/skills`, `.senpi/prompts`, or `.senpi/themes` - `.senpi/SYSTEM.md` or `.senpi/APPEND_SYSTEM.md` - project `.agents/skills` in the current directory or an ancestor directory A bare `.senpi` directory does not count as a project resource that requires 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, senpi 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 `~/.senpi/agent/trust.json`, and the closest saved decision on the current or parent path applies before the global default. Trusting a project allows senpi to load project resources that require trust, including: - `.senpi/settings.json` - `.senpi` 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 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, senpi 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. 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. ## No Built-in Sandbox senpi 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 senpi 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. The built-in permission system is a tool-call confirmation policy. Its default preset is `full-access`, so ordinary tool calls do not prompt. You can choose stricter presets with `permissionPreset` or `--permission-preset`: `workspace`, `read-only`, or `ask`. Explicit `permission` rules and `--permission` CLI rules can allow, ask, or deny matching tool calls. Permission presets are not an isolation boundary. They do not constrain the host process itself, user-installed extensions, package lifecycle behavior, already-started child processes, or credentials available to the process. This is intentional. senpi 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. Project trust is only an input-loading guard. It prevents a repository from silently changing senpi'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 senpi. ## Credential Injection Proxy Credentials named in the global `credentialProxy.credentials` setting (`~/.senpi/agent/settings.json`; project settings are ignored for this key) never reach a process the agent starts. Each declared variable, and any other variable holding the same value, is replaced by `senpi-credential-proxy-placeholder` in the environment of the bash tool, PTY bash sessions, monitors, the tool child, hook commands and eval kernels and their children. A declared `baseUrlEnv` points at a loopback proxy route; the proxy adds the auth header for that credential's one `origin` and nowhere else. ```json { "credentialProxy": { "credentials": [ { "env": "OPENAI_API_KEY", "origin": "https://api.openai.com", "baseUrlEnv": "OPENAI_BASE_URL" } ] } } ``` | Field | Meaning | |---|---| | `env` | Engine environment variable holding the value | | `origin` | The only upstream the value is sent to; https, or plain http for a loopback host | | `header` | Header to set (default `authorization`) | | `scheme` | Prefix before the value (default `Bearer` for `authorization`) | | `baseUrlEnv` | Child variable set to the proxy route | | `pathPrefixes` | Optional allowed request paths below `origin` | If the proxy cannot start, the declared variables stay withheld and no route is set. Your own `!` commands keep your full environment. What it does not cover: the proxy runs inside the senpi process as your OS user. A process running as the same user can still read senpi's startup environment (for example `/proc/<pid>/environ` on Linux or `ps eww` on macOS) or its memory. Only variables whose whole value equals a declared credential are replaced; a variable that embeds the value in a longer string (`Bearer <value>`, a URL carrying the key) is passed through unchanged, so declare that variable as well or remove it from the environment senpi starts with. The proxy keeps the value out of agent command environments and transcripts; it is not isolation from a same-user process. ## Running Untrusted or Unmonitored Work For untrusted repositories, generated code you do not intend to monitor closely, or unattended automation, run senpi 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. Common patterns are documented in [Containerization](containerization.md): - run the whole `senpi` process inside a container/sandbox - run host senpi while routing built-in tool execution into a Gondolin micro-VM - mount only the workspace paths the agent should access - avoid mounting host `~/.senpi/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 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. ## Reporting Security Issues To report a security issue, follow the repository [Security Policy](https://github.com/code-yeongyu/senpi/security/policy). Do not open a public issue for security-sensitive reports. 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 senpi grants access that the local user did not already have.