Public: anyone can read this; the crew can change it.
The forge runs deepsec itself: a sealed report on every pull's changed files and a weekly sweep, with the connected model and a spend ceiling #14792
Pull #15023 was closed
The workspace the 2026-11-20 sweep used, to commit as .deepsec/.
deepsec.config.ts:
import { defineConfig } from "deepsec/config";
import { generatedMatchersPlugin } from "./generated-matchers.js";
export default defineConfig({
defaultThinkingLevel: "high",
defaultAgent: "claude-agent-sdk",
ai: { mode: "direct", provider: "anthropic", apiKeyEnv: "DEEPSEC_ANTHROPIC_KEY" },
projects: [{ id: "forge", root: ".." }],
plugins: [generatedMatchersPlugin],
});
data/forge/config.json:
{
"ignorePaths": ["test/**", "bench/**", "examples/**", "docs/**", "waves/**", "**/node_modules/**", "**/*.test.ts", ".deepsec/**", "scratchpad/**", "testy/**"],
"priorityPaths": ["src/http/", "src/core/", "src/git/", "src/ssh/", "src/apps/", "src/crew/", "src/checks/", "src/spawn/", "src/origins/", "src/actions/", "src/billing/"]
}
data/forge/INFO.md:
# forge
## What this codebase does
A self-hosted, multi-tenant software forge in one Bun + TypeScript process with SQLite (`bun:sqlite`)
and no runtime dependencies. It serves git over HTTP and SSH, a web UI, a JSON API, an MCP server and a
terminal UI. It also runs a "crew" of AI coding agents against repositories, runs checks (CI) and apps
in sandboxed "cells" (bubblewrap + namespaces), and hosts child forges ("spawn") that may run their own
code. Public internet facing; anonymous strangers, guests, members, admins, AI agents and child forges
all reach it.
## Auth shape
- Repo access: `canRead` / `canWrite` / `canAdmin` in `src/core/repos.ts`; HTTP wrappers
`requireReader`, `requireWriter`, `requireRepoAdmin`, `requireUser`, `requireScope` (`src/http/respond.ts`).
- Tokens: `verifyToken` (`src/core/tokens.ts`) — sha256-stored, scoped, may be bound to ONE repository
(run, child, outside-agent "contribute" token, app). A repo-bound token must be refused on every other
repo before the handler runs. Passports `fp1.…` (`src/http/passport_edge.ts`) are short-lived, audience-bound.
- Admin: every route is marked `admin` or `open` in `src/http/route_marks.ts` / `src/http/marks/`;
`src/http/admin_gate.ts` is the single gate. Roles guest/member/admin in `src/core/roles.ts`.
- Edge identity: `X-Plat-User` is trusted only with `X-Plat-Edge-Token` == `FORGE_EDGE_TOKEN` (`src/http/edge.ts`).
Client address from socket peer; `X-Forwarded-For` only past configured trusted proxies.
- Git hooks call the forge on an internal listener with a per-boot `x-forge-hook-secret`.
Child → parent calls are HMAC-signed with a per-child key.
## Threat model
1. Cross-tenant read/write: a guest, a repo-bound token, a fork reader, or a child forge reaching another
repository's code, secrets, app variables or private objects (fork object sharing is a known hazard).
2. Escape from a crew run, check cell, app cell or child-forge cell: reaching the forge's data dir,
secret.key, other clones, the host network, private/metadata addresses (SSRF via origins, egress proxy,
mirrors, webhooks), or poisoning shared install caches.
3. Landing unapproved code: bypassing merge gates, protected default branch, pull approval of a guest
head, or the release/self-deploy path.
4. Secret leakage: tokens, sealed secrets, model credentials in logs, events, API replies, error text.
5. Account takeover: sessions, sign-in throttle, passkeys, OAuth/brokered sign-in, email verification,
Stripe webhook signature.
`docs/THREATS.md` lists every protection with its enforcing test. Lines saying `Enforced by: none yet`
are known gaps — report concrete exploitable instances of them, but prioritize places where a claimed
protection does not actually hold in code.
## Project-specific patterns to flag
- A route handler that reads a repo by owner/name and acts before `canRead`/`canWrite` or a `require*`
helper — especially API, MCP tool, terminal (tui) and SSH command paths, which are separate doors to
the same actions and can drift apart.
- A route registered without a mark, or an `open` mark on something that changes state.
- `Bun.spawn` / git invocations taking user-controlled refs, paths, config keys or URLs (option
injection like `--upload-pack`, `-c core.*`, path traversal out of a repo dir, symlinks in a cell dir).
- Outbound fetches/pushes whose host is not judged against private/loopback/link-local/tailnet/metadata
addresses at dial time (DNS rebinding, redirects).
- Raw SQL built by string interpolation instead of bound parameters.
## Known false-positives
- `test/`, `bench/`, `examples/`, `docs/` are not shipped attack surface.
- `/releases.json`, public repo reads, and stranger reads behind `src/http/strangers.ts` limits are intentionally public.
- A production app's `FORGE_TOKEN` being its owner's read-only token is documented, not a bug.
- `FORGE_SELF_SWAP` SO_REUSEPORT sharing with same-user processes is documented and accepted.
Lessons from the run:
- The default matchers miss the files that matter most here: the hand-written SSH server,
edge.ts,passport_edge.ts,egress.tsand the HTTP gates. Pass them by--files-from, or write matchers for the route-handler shape. initinsists on a Vercel login even with a direct key. Skip it withinit --scaffold-onlyand thenscanandprocess.processhas no spend cap. Bound it with--limitor a file list, and readtotalCostUsdindata/forge/runs/*.json.
🤖 Generated with Claude Code
Closed: already done on main in fbc56930 (pull #15023).
Sign in to join this conversation.
new above
offline
The 2026-11-20 security sweep ran from a laptop: deepsec 2.3.16 (open source, Apache-2.0), on claude-opus-5-5, about $160 of API credit. It processed 439 files and confirmed 78 security findings (2 critical, 23 high, 53 medium), plus 65 bugs. All are now sealed issues under P0 Trust. The forge should run this itself, on its own schedule, with whatever model is connected, so a new hole is reported the day it lands.
Change.
.deepsec/(itsdeepsec.config.ts,data/forge/INFO.mdthreat summary anddata/forge/config.jsonscope). Generated state stays ignored. The INFO.md written for the sweep names the auth primitives and points atdocs/THREATS.md.deepsec process --diff <base>on changedsrc/files. A finding posts a sealed report linked to the pull and does not block the gate until its false-positive rate is measured over two weeks.scan,processon pending files, thenrevalidate --min-severity HIGH, and files new findings through the same path. It has a spend ceiling, a setting with its reason. Measured cost: about $0.27 per file at thinkinghigh.xhighwas about 6× that.--model-auth directand no Vercel account: Sandbox mode uploads the tree to Vercel and stays off.Done when: a pull touching
src/http/gets a deepsec line in its check log, the weekly job has run once on the forge and filed or matched its findings, and the spend ceiling is a setting.🤖 Generated with Claude Code