From baf65656d6e8ed6b7c45751b218bd4d61d67065c Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 3 Dec 2026 22:37:31 +0000 Subject: [PATCH] Add security review for a default install Read-only review of network exposure, authentication, agent execution, prompt injection, supply chain, secrets, filesystem, federation and resource limits, with a README-ready summary and a secure-by-default checklist. No code changes. Co-Authored-By: Claude Opus 5.5 --- docs/security-review.md | 777 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 777 insertions(+) create mode 100644 docs/security-review.md diff --git a/docs/security-review.md b/docs/security-review.md new file mode 100644 index 00000000..d6f218bc --- /dev/null +++ b/docs/security-review.md @@ -0,0 +1,777 @@ +# Security review: what a new user exposes by installing Pipelines + +Date: 2026-12-03. Source reviewed: commit `9436067b` (main). +Scope: a stranger clones the repository and runs `./install` with defaults +(native install, Linux or macOS), then sets up one or more harnesses. + +Method: code and configuration reading plus safe local read-only checks. The +installer was not run. No running service was touched. Nothing was sent off this +machine. Severities are the reviewer's judgement. "Likelihood" means likelihood +under a **default** install. + +An earlier review (2026-11-10, see `docs/notes/security-boundary.md`, +`docs/notes/auth-hardening.md` and `docs/notes/network-and-update-signing.md`) +already fixed DNS rebinding against the Go API, added the proxy-to-server token +and LAN sign-in refusal, and signed the update feeds. This review builds on that +work and lists what remains open. + +**No critical, remotely exploitable, zero-interaction issue was found under +defaults.** The most serious finding (H1) needs a signed-in user to open a +crafted link to a file the attacker has placed in the user's home directory. + +--- + +## 1. What you're exposing your computer to (README text) + +> **Security: read this before installing.** +> +> Pipelines lets AI coding agents run commands on your computer as **your user +> account**. There is no container or separate user around them. Agents can read +> and change anything your account can, including SSH keys, cloud credentials, +> browser downloads and other projects. Codex chats in their default mode are the +> only exception: they run in Codex's own workspace sandbox. +> +> - **Your web password is effectively your shell password.** Anyone who signs +> in can start an agent in "bypass permissions" or "full access" mode and have +> it run any command. Choose a strong, unique password, and keep the web app on +> loopback and Tailscale (the default). Don't expose it to the internet. +> - **Agents can be manipulated by what they read.** A README, a web page or an +> issue can contain instructions that an agent follows ("prompt injection"). +> Agents with shell access can then leak your secrets or change files. Prefer +> the "ask" permission modes, and give pipeline stages only the tools they need. +> - **The notification server (ntfy) is on your local network.** It listens on +> every network interface over plain HTTP on port 8090, and the phone account +> uses your web password by default. Only subscribe over a network you trust or +> over Tailscale. +> - **Agents can spend money.** Runs have step and time limits but no spending +> cap unless you set one. +> - **Install and update pull code from the internet.** The installer builds the +> newest ntfy and OpenCode releases. `pipelines update` pulls this repository +> and reinstalls without a signature check. +> +> What is protected by default: the server API is on loopback only and needs a +> secret token; the web app accepts only loopback and Tailscale connections; the +> password is stored as an scrypt hash; sign-in is rate limited; the terminal +> asks for your OS password; and app updates are signature-checked. + +--- + +## 2. Top findings + +| ID | Severity | Finding | Default likelihood | +| --- | --- | --- | --- | +| H1 | High | `GET /files` serves HTML/SVG from `$HOME` inline on the app origin with no CSP, a stored-XSS path to code execution | Low to medium (targeted, one click) | +| H2 | High | Web password = arbitrary code execution; step-up elevation is bypassed by agent permission modes | Depends on the password; reachable only from loopback/tailnet | +| H3 | High | Agents run unsandboxed as the user with the server's environment and can read every Pipelines secret (cookie HMAC key, server token, update-signing key) | High once prompt injection reaches a shell-capable agent | +| H4 | High | Pipeline stages get unrestricted shell by default (no `tools` block, or `shell` without a policy) | High for any pipeline that omits a shell policy | +| M1 | Medium | ntfy listens on all interfaces over HTTP; the phone account reuses the web password (sniffable, and guessable outside the proxy's limiter) | High that the port is LAN-reachable | +| M2 | Medium | Supply chain floats: newest OpenCode, Pi and ntfy resolved at install time; unpinned base images; unchecked SDK zip; `pipelines update` has no signature check | Low per event, wide impact | +| M3 | Medium | Docker mode (opt-in) exposes the unauthenticated API on 0.0.0.0 | Only with `--docker` | +| M4 | Medium | `show_html` previews load remote images/CSS (exfil beacons) and allow links that escape the sandbox, including to the app's own origin | Medium | +| M5 | Medium | No spending cap by default and no global concurrency cap | Medium | +| M6 | Medium | Chat transcripts and notifications are not redacted | Medium | +| L* | Low | Links open without confirmation; OSC 52 clipboard writes; ntfy click-link to any URL; `ws://` peers; TOCTOU in `/files`; debug-keystore APK signing; and more | | + +--- + +## 3. Findings in detail + +### 3.1 Network exposure + +**Safe check on this machine** (it runs a customised install, so it shows the +shapes, not a pristine default): `ss -ltnH | awk '{print $4}'` + +``` +127.0.0.1:8080 # Go server API +*:8090 # ntfy +*:8082 # web proxy (wildcard bind, filtered per connection) +``` + +#### N1. Server API `:8080`: loopback, token, Host and Origin checks (info: good) + +- **Default bind:** `127.0.0.1:8080`. This is the `-addr` default in + `cmd/pipelines-server/main.go:29`; the `--bind-address` default is in + `scripts/setup-native.py`. +- **Front door:** every route passes `guardRequests` + (`internal/server/request_boundary.go:42-63`). + - **Host:** a loopback Host is required, otherwise `421`. This defeats DNS + rebinding. + - **Origin:** `/connect` refuses any `Origin` header: + ```go + if r.URL.Path == "/connect" && r.Header.Get("Origin") != "" { + http.Error(w, "browser origins may not connect directly; use the web proxy", http.StatusForbidden) + ``` + - **Token:** `X-Pipelines-Server-Token` is required whenever `-token-file` is + set, which the native installer always does. The token file is 0600. + - **Exempt paths:** `/healthz`, and `/mcp/chat/{token}`, which has its own + 64-character per-chat token. +- **WebSocket library:** `coder/websocket` `Accept(w, r, nil)` + (`internal/server/websocket.go:210`), whose default origin policy is + Origin == Host. +- **CORS:** no `Access-Control-Allow-*` header anywhere. +- **Result:** a hostile web page cannot drive `ws://127.0.0.1:8080`. Another + local OS user cannot either, without the token. +- **Residual:** `allowedHost` skips the Host check when the listener is not + loopback (`request_boundary.go:102-104`). That only matters for Docker (M3) or + a custom `--bind-address`. + +#### N2. Web proxy `:8082`: loopback plus tailnet only (info: good) + +- **Bind:** `--host :: --allow loopback,tailnet`. +- **Filter:** every connection is dropped before any HTTP is read unless both + ends are loopback or both are tailnet (`web/src/listenPolicy.js`; + `docs/notes/network-and-update-signing.md`). +- **LAN:** opt-in (`--web-lan`). Plain-HTTP LAN sign-in needs a second opt-in + (`--web-lan-plain-login`). +- **WebSocket upgrades:** `sameOriginUpgrade` (`web/src/proxySecurity.js`) plus + the cookie. +- **POSTs:** `sameOriginRequest`. Uploads also refuse + `Sec-Fetch-Site: cross-site`. +- **Residual:** a LAN port scan sees the port open and then reset. Tailscale + subnet routes without SNAT are treated as LAN (documented). +- **Tailnet trust:** every device on your tailnet, including shared-in devices, + can reach the sign-in page. + - **Mitigation:** restrict it with Tailscale ACLs. Mention this in the README. + +#### M1. ntfy `:8090` on every interface, phone account = web password (Medium) + +- **Evidence:** + - `scripts/setup-native.py:672` + ```python + f'listen-http: ":{ntfy_port}"\n' + ``` + - `:914` `base_url = args.ntfy_url or f"http://{lan_ip}:{args.ntfy_port}"` + - `:676` `auth-default-access: "deny-all"` is good: anonymous users can read + nothing. + - `:726-730`: + ```python + def reader_password(self, web): + """The phone's ntfy password, which matches the web password: ... + ``` + - `docs/notifications.md:92-96` tells the user to add `http://:8090` + and sign in as `phone-reader` with the web password. +- **Default:** on. It ignores `web.host=tailnet`, so it contradicts "expose only + the web proxy". +- **Impact:** + 1. The web password crosses the LAN in cleartext HTTP Basic auth every time + the ntfy phone app connects. + 2. Anyone on the LAN can guess the web password against ntfy. That bypasses + the proxy's login limiter and the tailnet-only restriction. + 3. A second hash of the web password sits in ntfy's `auth.db`. + 4. Whoever holds the reader credential can read notification text (run and + chat titles, summaries). +- **Mitigation:** + - Bind ntfy to loopback plus tailnet (or put it behind `tailscale serve` + HTTPS). + - Generate a random reader password or ntfy access token instead of reusing + the web password. + - Make LAN ntfy an opt-in like `--web-lan`. + +#### N3. mDNS advertising (Low/info) + +- **Default:** on (`PIPELINES_MDNS`; `cmd/pipelines-server/main.go:41`). With + `web.host=tailnet`, `scripts/manage.py:47-58` passes `-mdns-lan=false`, so + the A records are tailnet IPs. +- **What is still announced:** the advert is multicast on the LAN. It announces + the host name, the Pipelines version (`v`), `auth=password`, and the tailnet + and public routes. +- **Impact:** fingerprinting and discovery of a tailnet address and version by + anyone on the same Wi-Fi. +- **Mitigation:** turn mDNS off by default when the LAN route is off (a tailnet + client can be given the address), or at least drop `v=`. + +### 3.2 Authentication + +#### A1. Password storage, cookies, brute force, lifetime (info: good, minor gaps) + +- **Hash:** scrypt N=2^15, r=8, p=1, 32-byte key, constant-time compare + (`scripts/password.py:26`, `docs/notes/auth-hardening.md`). +- **Files:** `web-auth.json` and `server-token` are 0600 in 0700 directories + (`scripts/setup-native.py:385-414`). The password is read with `getpass`, + never from argv. +- **Policy:** at least 16 characters, or a passphrase of 4 or more words + (`web/src/passwordPolicy.js:5`). +- **Cookie** (`web/serve.mjs:193-203`): + ```js + const bits = [`${sessionCookieName(req)}=${token}`, "Path=/", "HttpOnly", "SameSite=Lax"]; + ... + if (isHttps(req)) bits.push("Secure"); + ``` + The `__Host-` prefix is used over HTTPS. A plain `http://127.0.0.1` or + `http://100.x` session has no `Secure` flag; that is acceptable on loopback + and WireGuard. +- **Lifetime:** 12 hours, or 30 days with "Remember me", which is **checked by + default** (`web/serve.mjs:140-141`, `:299`). + - **Mitigation:** default "Remember me" to unchecked, or shorten it to 7 days + with sliding renewal. +- **Revocation:** a password change or `./password --revoke-all` rotates the + HMAC secret and the generation (`web/src/authStore.js:8-10`). This ends every + session, including forged ones. +- **Brute force:** `web/src/loginLimiter.js` gives five free failures per + client, then exponential backoff up to 15 minutes, plus a global 50 failures + per 5 minutes. Good. ntfy is outside this limiter (M1). +- **Plain-HTTP LAN sign-in:** refused unless opted in. `X-Forwarded-Proto` is + not trusted from the LAN. +- **Proxy-to-server token:** a 0600 file whose path is passed through the + environment (`PIPELINES_SERVER_TOKEN_FILE`). It is never on the command line + (`scripts/manage.py:437-445`). The proxy strips it before forwarding to peers + (`web/src/peerRelay.js:74`). But see H3: every agent inherits that + environment variable and can read the file. +- **Test switch:** `PIPELINES_WEB_AUTH=disabled` (`web/serve.mjs:66`) turns off + auth entirely. It is meant for tests. + - **Mitigation:** refuse it unless the bind is loopback. + +#### H2. Web password = code execution; elevation is bypassable (High, by design) + +- **Evidence:** + - Step-up elevation gates only these operations + (`internal/server/elevation.go:53-59`): + ```go + var elevationGated = map[string]bool{ + protocol.ChatShellRun: true, + protocol.ChatShellInput: true, + protocol.RenamePath: true, + protocol.MovePath: true, + protocol.DeletePath: true, + } + ``` + - Not gated: creating a chat in any directory, switching modes, prompting, + answering permission cards, starting runs, `GET /files`. + - Any signed-in client can pick these modes: + - `internal/claude/modes.go:24` + `{ID: "bypassPermissions", ..., Description: "Never ask. Everything runs without checks."}` + - `internal/codex/modes.go:23` + `{"full" ...}, "never", "dangerFullAccess"}` + - Elevation re-asks the **same** web password and lasts 24 hours + (`elevation.go:37` `DefaultElevationTTL = 24 * time.Hour`). +- **Default:** chats start in "ask" mode (Claude `default`, Codex + `workspace-write` + `on-request`), but switching needs nothing more than the + session. +- **What an attacker with the web password (or a session cookie) can do:** + - run any command as you, via a bypass-mode chat or by elevating with the + same password and using `!` lines; + - read any file under `$HOME` through `/files`, including `~/.ssh` and + `~/.claude/.credentials.json`; + - approve agent permission requests; + - start runs that spend model credit; + - plant `schedule_followup` prompts that persist for up to 7 days; + - register peers. +- **The one real second factor:** the terminal uses `su -l` and the OS password + (`internal/server/terminal_login.go:85`). That is a good design. +- **Mitigation, in order:** + 1. Gate mode changes into bypass/full, and answers to permission cards, behind + elevation. + 2. Make elevation a distinct factor: the OS password via `su`/PAM (as the + terminal does), TOTP, or WebAuthn. Shorten the default TTL to 15-60 + minutes. + 3. Gate `GET /files` outside the chat's project root, or deny-list secret + paths (see F2). + 4. Document plainly that the web password is equivalent to shell access. + +### 3.3 Remote code execution by design + +#### H3. Agents are unsandboxed and inherit every secret (High) + +- **Evidence:** + - Every harness runs as the server's UID with `os.Environ()`: + - `internal/stage/claude_stage.go:360` + - `internal/stage/pi.go:408` + - `internal/stage/opencode.go:141-146` (via `workenv.CommandEnv`) + - `internal/claudehost`/`hosted.go:158` + - `internal/server/chat_shell_runner.go:171-172` (`exec.Command(r.shell(), "-lc", command)` with no `cmd.Env`) + - That environment contains `PIPELINES_SERVER_TOKEN_FILE`, + `PIPELINES_NTFY_TOKEN_FILE` and `PIPELINES_WEB_AUTH_FILE` + (`scripts/manage.py:437-445`). `internal/servertoken/servertoken.go:1-10` + acknowledges that the harnesses can read the token. + - The only isolation is a git worktree per run + (`internal/server/run_worktree.go:57-69`), which is a directory, not a + boundary. +- **Default:** on, for every harness. Codex chats in `ask`/`auto` mode are the + exception: Codex's own `workspace-write` sandbox applies + (`internal/codex/chat.go:591`). +- **What a prompt-injected agent with shell can read:** + - `~/.config/pipelines/web-auth.json`, which holds the scrypt hash and the + cookie HMAC `secret` (`web/src/authStore.js:8`). With the secret it can + **forge valid session cookies**. + - the server token, which gives full API control from any local process; + - `~/.config/pipelines/update-signing-key.pem`, which can sign app update + feeds that every installed client trusts (see S2); + - the Android keystore; + - harness OAuth and API credentials, including the saved account slots in + `internal/claudeaccounts/store.go`; + - SSH keys, cloud credentials and browser data. +- **Mitigation:** + 1. Scrub `PIPELINES_*` secret paths and tokens from every child environment. + Pass an allow-listed environment. + 2. Run harnesses under a separate OS user, or in bubblewrap/`sandbox-exec`, + or in a container with only the workspace (and the harness's own + credentials) mounted. + 3. Move the cookie secret, server token and signing key to a location the + agent's user cannot read. + 4. Until then, document that any agent can read these files. + +#### H4. Stages default to unrestricted shell (High) + +- **Evidence:** + - `internal/stage/tools.go:177` + `var legacyTools = []string{"read", "glob", "grep", "edit", "shell"}` is + applied when a stage has no `tools` block. + - Claude: `internal/stage/claude_stage.go:152-156` + ```go + case "Bash": + if shell != nil { rules = append(rules, claudeShellRules(shell)...) + } else { rules = append(rules, tool) } // bare "Bash" + ``` + It runs with `--permission-mode dontAsk` (`:183`). The `Edit(/**)` + scope does not limit Bash. + - OpenCode: `tools.go:283-284` `if c.Policy.Shell == nil { allow("shell", "*") }`. + The deny rules on reading `*.env` and `pipelines.db*` (`:354-355`) are + bypassed by `cat` in the shell. + - Pi: `pi_policy.mjs:7-9` puts no restriction on bash without a policy. +- **Related defaults:** `--allow-authoring` is on for fresh installs + (`docs/install.md` flag table), so a signed-in user can also author check + stages that run `sh -c` (`internal/stage/check.go:220-222`). The starter + template's empty `tools` block is text-only (`internal/pipeline/definition.go:36`). + No stage gets `webfetch` unless it declares it. +- **Mitigation:** + - Require an explicit `permissions.shell` allow-list whenever `shell` is + granted, or at least warn loudly in the editor and at run start. + - Warn when a stage combines `webfetch` with unrestricted `shell`. + +#### R1. OpenCode chats use OpenCode's own permission defaults (Medium, to confirm) + +- **Evidence:** `internal/opencode/chat.go:535-539` deliberately sends no + permission override. +- **Risk:** OpenCode's upstream defaults are permissive (edits and bash allowed + unless the user's `opencode.json` restricts them). This was not confirmed + against the pinned OpenCode version. +- **Mitigation:** create OpenCode chat sessions with an "ask" permission set, + matching Claude and Codex. +- **Protection in place:** the OpenCode server itself binds `127.0.0.1` with a + random password (`internal/opencode/connection.go:394-397`). + +#### R2. `!` shell lines (info: gated) + +- **What they run:** `exec.Command(shell, "-lc", command)` in the chat + directory, at most 4 at a time per chat (`chat_shell_runner.go:168-172`). +- **Gate:** elevation, but see H2: same password, 24 hours. + +#### R3. Terminal (info: good) + +- **What it runs:** `su -l -c 'cd || cd; exec "$SHELL" -l'` + (`internal/server/terminal_login.go:85`). It refuses to run as root. +- **Barrier:** the OS password. + +#### R4. MCP chat tools (Low/Medium) + +- **Endpoint:** `/mcp/chat/{token}`, loopback only, not proxied, with a + 64-character token per chat. +- **Tools** (`internal/chattools/tools.go:5-14`): `show_file`/`show_diff` (any + path in `$HOME`), `show_image` (a home file or https URL; the fetcher blocks + private addresses, `chat_tools_fetch.go:54`), `show_html` (sandboxed), + `notify` (5 per minute), `show_run`, `schedule_followup`/`cancel_followup`. +- **Risk:** `schedule_followup` lets an injected instruction re-prompt the chat + up to 7 days later. That is persistence. +- **Mitigation:** list pending follow-ups prominently. In bypass/full mode, + require confirmation before a follow-up fires. + +#### R5. Chat directory can be any absolute path, including `/` (Low) + +- **Evidence:** `internal/server/chat_sessions.go:422-434` only checks + `IsAbs` + `IsDir`. +- **Minor bug:** `~/sub` resolves to home, not to `~/sub` (`:424`). +- **Mitigation:** confine to `$HOME` or configured roots, and expand `~/` + correctly. + +#### R6. direnv / mise (info: good) + +- **Behaviour:** only `.envrc` files already `direnv allow`ed and trusted mise + config are applied (`internal/workenv/workenv.go:6-8`). An edited `.envrc` + is re-blocked by direnv. `PIPELINES_DIRECTORY_ENV=off` disables it. + +### 3.4 Prompt injection and rendering + +#### H1. `GET /files` serves HTML/SVG inline on the app origin (High) + +- **Evidence:** + - `internal/server/home_files.go:68-92`: the type comes from the extension, + the disposition is `inline` by default, and only `nosniff` is set. There is + no CSP: + ```go + contentType := mime.TypeByExtension(filepath.Ext(realTarget)) + ... + disposition := "inline" + if r.URL.Query().Get("download") == "1" { disposition = "attachment" } + ``` + - `internal/server/websocket.go:196` `mux.HandleFunc("GET /files", serveHomeFile)` + has no elevation. + - `web/serve.mjs:614-616` and `:465-482`: the proxy forwards `/files` and + copies upstream headers verbatim (`res.writeHead(reply.statusCode ?? 502, reply.headers)`). + - The global header is `frame-ancestors 'self'` only + (`web/src/webSecurity.js:69`). + - By contrast, `/artifacts/` sets + `sandbox; default-src 'none'; script-src 'none'; ...` + (`internal/server/artifacts.go:294`), and the peer relay applies the same + policy to a **peer's** `/files` (`web/src/peerRelay.js:13-15`). Only the + local `/files` route lacks it. +- **Scenario:** an HTML or SVG file lands anywhere under `$HOME`, for example: + - a browser download in `~/Downloads`; + - a file in a cloned repository; + - a file written by a prompt-injected agent. + + The attacker then gets the user to open + `https://.ts.net:8443/files?path=~/Downloads/x.html`. That is a + top-level GET, so the `SameSite=Lax` cookie is sent. Other ways in are the + Files panel's "Open externally" (`app/lib/features/chat/files/files_viewer.dart:56`) + or a link inside a `show_html` preview (M4). + + The page's script runs on the app origin. It can then: + - open `/connect` (same origin, so the proxy's origin check passes); + - create a Claude chat, switch it to `bypassPermissions` and prompt it, which + is **code execution with no elevation**; + - read `/files?path=~/.ssh/id_ed25519`. +- **Default:** on. +- **Likelihood:** needs targeting and one click, so low to medium. +- **Impact:** full compromise of the user account. +- **Mitigation** (small change, highest value in this report): + - In `serveHomeFileFrom`, send the same sandbox CSP as `artifacts.go:294`. + - Force `attachment` (or `text/plain`) for `text/html`, `image/svg+xml`, + `application/xhtml+xml` and XML types. + - Defence in depth: have `proxyArtifact` add the sandbox CSP to every + `/files` and `/artifacts/` response, as `peerRelay` does. + +#### M4. `show_html` previews: remote loads and sandbox-escaping links (Medium) + +- **Evidence:** + - Web: an `srcdoc` iframe with `sandbox="allow-popups allow-popups-to-escape-sandbox"` + (`app/lib/features/artifacts/ui/artifact_html_view_web.dart:109-110`). + There are no scripts and the origin is opaque, which is good. + - The link filter `artifact_html_links.dart:37-42` allows any http(s) URL, + including the app's own `/files?path=...html`, which chains into H1. + - Remote `` and CSS `url()` loads are not blocked (`web/src/appFiles.js:17-24`). + - The tool description says "no network" (`internal/chattools/tools.go:122`). + That is inaccurate. + - Native: `JavaScriptMode.disabled` (`artifact_html_view_native.dart:78-79`), + but remote subresources still load. +- **Impact:** an injected agent can encode data in image URLs, so the data is + exfiltrated as soon as the preview renders. Links can also open + attacker-chosen pages outside the sandbox. +- **Mitigation:** + - Inject `` + into the srcdoc and native HTML, as `deliverable.go:48` already does. + - Block links to the app's own origin. + - Confirm before opening external links. + +#### P1. Chat markdown and links (Low) + +- **Markdown:** a custom parser that renders no raw HTML and no markdown + images (`app/lib/features/chat/ui/transcript/markdown_inline.dart`). +- **Links:** only `http(s)` with a host, plus `mailto` + (`chat_links.dart:35-55`). `javascript:` and `file:` are blocked. +- **Gap:** links open with `LaunchMode.externalApplication` and no confirmation + (`chat_link_launcher.dart:9-10`), and `[text](url)` can hide the target. +- **Remote images:** `show_image` with an https URL loads on its own + (`chat_shown_link_image.dart:51` `Image.network(url)`), which works as a + beacon. +- **Mitigation:** click-to-load remote images; show the target and confirm when + the link text differs from its host. + +#### P2. Terminal escape sequences (Low) + +- **OSC 52:** writes reach the system clipboard silently, with only a toast + (`app/lib/features/chat/shell/chat_shell_terminal_events.dart:52-55`). Reads + are refused (`third_party/xterm/lib/src/terminal.dart:1135-1145`). +- **Risk:** agent output can swap the clipboard for a malicious command. +- **OSC 8 links:** http(s) only and Ctrl/Cmd+click, but the target is not shown. +- **Mitigation:** confirm OSC 52 writes or put them behind a setting, and show + the link target on hover. + +#### P3. ntfy click links to arbitrary URLs (Low) + +- **Evidence:** `internal/server/notify_link.go:87-103` accepts any absolute + http(s) `link=` written by the agent into the run's `public/` directory. +- **Risk:** a phishing link delivered as a trusted notification. +- **Mitigation:** restrict to the configured web origin, or route through an + interstitial page. + +### 3.5 Supply chain + +#### M2a. Harness and ntfy versions resolve to "newest" at install time (Medium) + +- **Evidence:** + - `scripts/resolve-releases.py:1-27` picks the newest OpenCode v2 tag (GitHub + API), then its GHCR digest, and the newest Pi version from npm. + - The Dockerfile pins by digest, but the digest is whatever is newest when you + install (`Dockerfile:23 FROM ${OPENCODE_IMAGE}@${OPENCODE_DIGEST}`). + - Pi: `npm install --global --ignore-scripts ...@${PI_VERSION}` (`Dockerfile:40`) + has no integrity hash and leaves transitive dependencies unpinned. + - ntfy: `go mod download heckel.io/ntfy/v2@` + (`scripts/setup-native.py:613-614`). GOSUMDB still verifies module + integrity, since no GOPROXY/GONOSUMDB override was found. +- **Protections:** a host allow-list and a redirect guard in + `resolve-releases.py:59, 92-98`. +- **Mitigation:** commit reviewed pins (version + digest + npm integrity, and + the ntfy version) and make "resolve latest" an explicit flag. + +#### M2b. Unpinned images and an unchecked SDK download (Medium/Low) + +- **Image tags, not digests:** + - `compose.yaml:56 image: binwiederhier/ntfy:latest` (Docker mode) + - `Dockerfile:10 FROM golang:1.27-alpine` + - `app/docker/Dockerfile:7 FROM debian:bookworm-slim` +- **SDK zip:** `app/docker/Dockerfile:55` downloads the Android command-line + tools zip without a sha256 check. +- **Flutter:** cloned by tag (`--branch $FLUTTER_VERSION`, 3.44.6 from + `app/.flutter-version`) with no commit check. A tag can move. +- **Mitigation:** pin by `@sha256:` digests, verify the zip's sha256, and check + the Flutter tag's commit. + +#### M2c. `pipelines update` pulls and installs with no verification (Medium) + +- **Evidence:** `scripts/manage.py` `update` (around lines 369-397): + ```python + pulled = subprocess.run(["git", "-C", str(source), "pull", "--ff-only"], text=True) + ... + installed = subprocess.run(["sh", str(source / "install.sh"), *config.get("install_args", [])]) + ``` +- **Risk:** whatever the tracked remote serves is built and installed. + - A compromised remote compromises every user who updates. + - The install doc clones over HTTPS from a personal Git host. +- **Mitigation:** verify signed tags (`git verify-tag`), or show the incoming + commit range and ask before installing. + +#### S1. `curl | bash` advice (Low) + +- **Where:** `docs/install.md:26`, `docs/harnesses.md:38,40` and + `scripts/setup-native.py:133` recommend + `curl -fsSL https://opencode.ai/install | bash`. +- **Mitigation:** also offer package-manager installs. + +#### S2. App update feed signing (info: good, with notes) + +- **Signature first:** the Ed25519 signature is checked before the feed is + trusted (`app/lib/features/updates/app_updates_io.dart:111-118`). +- **Hash checks:** the download's sha256 is checked before the rename + (`:177-185`). The Android signer must match. +- **No redirects:** redirects are not followed (`:44`). +- **Downgrade protection:** a feed is offered only if `versionCode > installed`. + Settings uses `_installed ?? 0` (`settings_updates_section.dart:63`), so an + unreadable installed version offers anything. +- **Fails open with no key:** a build with no embedded key accepts any feed + (`update_feed_signature.dart:44`). Installer builds always embed one. +- **Key location:** the signing key lives on the same machine and account as + the feed and the agents (`~/.config/pipelines/update-signing-key.pem`, + 0600). Per H3, any agent can read it and sign a malicious update. +- **APK keystore:** APKs are signed with a keystore seeded from the Android + **debug** keystore (well-known password `android`) + (`app/android/app/build.gradle*`, `scripts/app_build.py:143-151`). +- **Extraction:** Linux uses `tar -xzf` into a staging directory beside the + install (`linux_self_update.dart:54-59`). It is hash-pinned, but members are + not filtered. +- **Mitigation:** + - Keep the signing key away from the agent user (H3). + - Fail closed in release builds without a key. + - Treat an unknown installed version as "no update". + - Add a signed expiry. + - Generate a real release keystore. + - Reject symlink, absolute and `..` tar members. + +#### S3. Dependency pinning (info: good) + +- **Go:** `go.mod` + `go.sum`. +- **Web proxy:** no npm dependencies at all (`web/package.json`). +- **Flutter:** `app/pubspec.lock` is committed, and the xterm fork is vendored + as a path dependency. +- **Gap:** `scripts/app_desktop_build.py:85` runs `pub get` without + `--enforce-lockfile`. + +### 3.6 Secrets + +- **Storage (info: good):** + - The web hash, server token, publisher token, ntfy config, install manifest, + signing key and Claude account slots are all 0600 in 0700 directories + (`setup-native.py:302-414, 683, 744`; `update_signing.py:66-85`; + `claudeaccounts/store.go:214-237`). + - No secrets on command lines or in service unit files: the launchd plist + carries only `HOME` and `PATH`. + - Inline `PIPELINES_NTFY_TOKEN` is refused (`internal/installation/service.go:224-225`). +- **Docker ntfy token (Low):** world-readable inside a 0700 directory + (`scripts/save-ntfy-token.py:16`, `mode=0o444`). Docker mode only. +- **M6. No redaction of transcripts or notifications (Medium):** + - Redaction exists only for failure evidence (`internal/stage/diagnostics.go:55-70`) + and turn-diff snapshots, which skip `.env*`, `*.pem`, `.ssh`, `.aws` and + similar (`internal/filediff/snapshot.go:249-262`). + - Anything an agent prints, such as `cat ~/.aws/credentials`, is stored in the + history DB (`~/.local/share/pipelines/data/pipelines.db`, directory 0700) + and can appear in notifications and session exports. + - **Mitigation:** scrub known secret values (the server token, the publisher + token, and patterns such as AWS keys and private-key headers) before + persisting and before notifying. +- **Harness credentials:** stay where each harness keeps them (`~/.claude`, + `~/.codex`, OpenCode's auth file). Agents can read them (H3). +- **Credential forwarding:** pipeline transfer bundles contain definitions + only (`internal/transfer/bundle.go:1`). The peer relay sends the remote + password to the peer's `/login` and allows `ws://` with only a warning + (`web/src/peerRegistry.js:6-9`). See F1. +- **Retention and uninstall:** + - Storage retention is off by default (`protocol/storage.go:18`), so history + grows without limit. Chat attachments and notifications are kept 7 days. + - `./uninstall` removes `~/.config/pipelines` and the data. It probably + leaves `~/.claude/pipelines-accounts` behind (not confirmed). + - **Mitigation:** document what uninstall leaves behind, and offer a + retention default. + +### 3.7 Filesystem + +- **Confinement (info: good):** + - `/files`, the folder picker and `show_file` resolve symlinks, then use + `filepath.Rel` against the real `$HOME` (`internal/server/directory_listing.go:104-122`). + `..` and symlinks out of home (for example to `/etc`) are refused. Kernel + pseudo-filesystems are refused. + - Artifacts use `os.OpenRoot` with Lstat checks on each component and + `O_NOFOLLOW` (`internal/server/artifacts.go:204-294`). + - Chat uploads use `os.Root` + `O_EXCL`, at most 100 MiB per file, a 1 GiB + quota and 512 files. + - `POST /files` needs elevation and uses `O_EXCL`. + - No prefix-bug `HasPrefix` path checks were found. +- **F2. All of `$HOME` is readable by a session (Medium, part of H2):** + - A symlink to `~/.ssh` stays inside home, and `~/.ssh` itself can be read + directly. + - **Mitigation:** deny-list `~/.ssh`, `~/.gnupg`, `~/.aws`, + `~/.config/pipelines`, `~/.claude*`, `~/.codex` and `.git-credentials` in + `/files`, `show_file` and the listing, or require elevation for them. +- **F3. TOCTOU (Low):** + - `home_files.go:34` resolves the path, then opens it later (`:56`) without + `os.Root`. A same-user process could swap in a symlink between the two. + - **Mitigation:** `os.OpenRoot(realHome)` + `root.Open(rel)`, as artifacts do. +- **F4. Proxy static and `/updates` paths (Low):** + - `resolve(join(...))` + `startsWith(ROOT + sep)` (`web/serve.mjs:390-412`) + is safe against `..`, but follows symlinks inside the root. + - Fine while the directories stay 0700. +- **Where agents can write:** Claude stage `Edit` is scoped to the run and + artifacts directories. Bash in every harness, and every chat agent, can write + anywhere the user can. + - Run worktrees are created at `-runs/` and removed when landed or + discarded (`run_worktree.go:57-64, 102, 149`). + +### 3.8 Multi-machine federation + +- **Model:** proxy to proxy only. The Go server has no peer concept. + - A signed-in user registers `ws(s)://host/connect` and types that remote's + web password. + - The local proxy keeps the remote session cookie in memory for that local + session (`web/src/peerRegistry.js:148,168`). +- **What a peer link grants:** relaying the browser's socket to the remote + `/connect`, which is **full control of the remote as its signed-in user** + (H2 applies there), plus fixed GET/POST paths (`web/src/peerRelay.js:60-200`). +- **What it does not grant:** the remote cannot act on the local machine. The + local server token is never forwarded. No harness credentials are pushed. +- **Remote content:** gets a sandbox CSP. Redirects become 502. SSRF and DNS + pinning protections are in `web/src/peerAddress.js`. +- **TLS:** `https.request` verifies certificates. +- **F1. Plain `ws://` peers (Low):** the remote password crosses in cleartext, + only flagged as `insecure_transport` (`web/src/peerTransport.js:84-90`). + - **Mitigation:** refuse `ws://` except for tailnet or loopback addresses. +- **Compromise blast radius:** a compromised local machine holds live sessions + to each peer while the user is signed in, so it can drive those peers as well. + +### 3.9 Resource abuse + +#### M5. No spending cap and no global concurrency limit (Medium) + +- **Limits that exist:** + - Per-stage timeout of 1 hour (`internal/stage/budget.go:16`). + - Loop limits: `maxStageVisits = 5`, `maxRunSteps = 30` (120 with grants) + (`internal/server/loop_state.go:23-29`). + - Claude chat processes are capped at 8 (`internal/claude/claude.go:40`). + - `!` commands: 4 per chat. +- **Budget off:** the run budget is off unless `DefaultBudgetUSD > 0` + (`internal/server/run_budget.go:74`). +- **No global caps:** none on concurrent runs, WebSocket connections or chats. + A runaway loop, a malicious session, or `schedule_followup` can burn API + credit. +- **DoS:** + - Body limits exist: WebSocket reads 2 MiB (`websocket.go:215`), MCP bodies + 4 MiB, proxy JSON 4 KiB. + - `ReadHeaderTimeout` is 5 seconds, but there is no `IdleTimeout` or body + deadline (`cmd/pipelines-server/main.go:196`). + - `POST /files` has no disk quota, but needs elevation. +- **Mitigation:** + - Ask for a default budget at install (or ship a modest one). + - Add a server-wide concurrent-run cap and per-session connection caps. + - Add `IdleTimeout` and a disk quota. + +### 3.10 Docker mode (opt-in): M3 + +- **Evidence:** + - `compose.yaml:26` `- "${PIPELINES_BIND_ADDRESS:-0.0.0.0}:${PIPELINES_PORT:-8080}:8080"` + - `scripts/setup-docker.py:82-84` forces `PIPELINES_BIND_ADDRESS=0.0.0.0` + - `Dockerfile:59 CMD ["-addr", "0.0.0.0:8080", ...]` + - No server token is configured. `cmd/pipelines-server/main.go:58` only logs + "no server token configured". The Host check is skipped off loopback + (`request_boundary.go:102-104`). +- **Impact:** with `./install --docker`, any LAN host using a non-browser + WebSocket client (no `Origin` header) can run agents and read the mounted home + and repositories (`compose.yaml:38-47`). That is **remote code execution from + the LAN**. Severity would be critical, but it is not the default. +- **Mitigation:** + - Bind 127.0.0.1 by default. + - Generate and mount a server token. + - Make the server refuse a non-loopback `-addr` without a token unless + `-insecure-no-token` is given. + +--- + +## 4. "Secure by default" checklist (ordered by value / effort) + +1. **Sandbox `/files`** (H1): add the artifact sandbox CSP in + `serveHomeFileFrom`, force `attachment` for HTML/SVG/XML, and add the CSP in + `proxyArtifact` too. *A few lines; closes the XSS-to-code-execution path.* +2. **Gate permissive modes behind elevation** (H2): switching a chat to Claude + `bypassPermissions` or Codex `full`, and answering permission cards. *Small.* +3. **Scrub the agent environment** (H3): drop `PIPELINES_*_FILE`, + `PIPELINES_WEB_AUTH_FILE` and token variables from every harness and `!` + child environment. *Small.* +4. **ntfy off the LAN by default** (M1): bind loopback + tailnet (or serve it + through `tailscale serve`), give the phone a random reader password or token, + and make LAN ntfy an opt-in. *Small to medium.* +5. **Docker safe defaults** (M3): bind 127.0.0.1, generate a token, and refuse a + non-loopback bind without a token. *Small.* +6. **Deny-list secret paths** in `/files`, `show_file` and listings (F2). + *Small.* +7. **Require a shell allow-list for stages** (H4), or warn at authoring and run + start, and default the starter to text-only. *Small to medium.* +8. **Block remote loads in HTML previews** (M4): inject a strict meta CSP and + refuse same-origin links. *Small.* +9. **Default a run budget and a global run cap** (M5). *Small to medium.* +10. **Pin the supply chain** (M2): commit reviewed OpenCode, Pi and ntfy + versions and digests, pin base images by digest, verify the SDK zip's + sha256, and verify signed tags in `pipelines update`. *Medium.* +11. **Make elevation a real second factor** (H2): OS password via + `su`/PAM (as the terminal does) or TOTP/WebAuthn, with a 15-60 minute TTL. + *Medium.* +12. **Isolate agents from Pipelines' own secrets** (H3): run harnesses under a + separate user or a bubblewrap/`sandbox-exec` profile, and keep the cookie + secret, server token and signing key out of their reach. *Large; biggest + long-term win.* +13. **Smaller items:** + - Default "Remember me" off. + - Disable mDNS when the LAN route is off. + - Confirm external links, OSC 52 writes and ntfy click links. + - Redact known secrets from transcripts. + - Refuse `ws://` peers off the tailnet. + - Use a real APK keystore. + - Fail closed on unsigned feeds in release builds. + - Run `pub get --enforce-lockfile`. + - Add a README security section (section 1). + +## 5. Method notes and limits + +- **Not tested at runtime:** H1 and M4 are confirmed from code paths, not + reproduced in a browser. +- **Not confirmed:** OpenCode's upstream default chat permissions (R1), and + whether uninstall leaves `~/.claude/pipelines-accounts` behind. +- **Live listener check:** `ss -ltnH` on this machine, a customised install, not + a pristine default. +- **Not covered:** the iOS build, Windows (unsupported), and the behaviour of + the third-party harness CLIs themselves.