Skip to content

Security: theninjadojo/software-factory

SECURITY.md

Security model

Shikumi runs AI agents on text written by other people (ticket bodies, comments, repo contents). Any of that text can try to take over the agent. The design goal is not to detect that, it is to make a taken-over agent unable to do anything that matters.

What is protected, and how

Boundary Control Tested in
Who can start work A trigger label counts only if a user with write access applied it (read from the issue timeline, fail closed) tests/test_core.py, tests/test_roles.py
What the classifier decides Typed answers validated against fixed sets; a fixed table turns them into a model and effort. Ticket text cannot name a model, a command or a path tests/test_jev.py
Fallback models The fallback chain is admin configuration (fallback_models, same harness, at most 3); ticket text and the classifier cannot select, add or reorder it tests/test_fallback.py
What the agent can reach Sandbox: no network (only a unix socket to an allowlist proxy), read-only root, no capabilities, non-root, memory/CPU/pid limits, no GitHub credentials, per-task workspace copies tests/test_runner.py
What the agent can send out The proxy tunnels TLS only to allowlisted host names on 443 tests/test_runner.py
What the agent's output can do It is data. Patches are size- and file-count-limited, must not touch protected paths (.git, .github, .claude, .githooks, .agents, .husky, .mcp.json, CODEOWNERS ...) or add symlinks/submodules, and are applied by the orchestrator to pristine clones. Git is never run on the agent's own .git, and hooks are disabled tests/test_runner.py
What the factory may write to GitHub Only factory/* branches (code-enforced), PRs, issue comments and labels, plus (opt-in, [subtasks] enabled) step sub-issues with a fixed [factory] title prefix and a body built only from factory fields (no ticket text, agent output, labels or assignees). No Workflows or Administration permission tests/test_runner.py, tests/test_subtasks.py
Documents posted to tickets Sanitized: no @mentions (they ping people), no images (a rendered URL can leak data), no active HTML, length-capped tests/test_roles.py
Earlier stage outputs fed to later agents Trusted only if authored by the factory's own account; a forged comment with the marker is ignored tests/test_roles.py
A local ticket ([local] enabled) A trigger label counts only if its last labeled event was written by the admin UI or the factory (local_events); labels and comments copied from GitHub carry the actor imported, which never counts, and only factory-authored comments keep the factory's authorship. A GitHub issue that was moved is never polled again, and PRs name a local ticket as L-N, never as repo#100000012 tests/test_tracker.py
Automatic import ([local] auto_import, off by default) Runs only with GitHub issues off and local tickets on, not in dry run, without a token or while paused. Lists only configured repositories with a query fixed in code. Queues an issue only if its author is a User whose permission is in trusted_permissions; anything else, none included (any GitHub error), is skipped and never copied or closed. The copy is the same as Import: untrusted text with the actor imported, no trigger labels, no labels created tests/test_tracker.py
Prompt structure Untrusted text cannot close the prompt's wrapper tags tests/test_runner.py
Operator prompts ([prompts]) Trusted config only (config.toml or the authenticated UI), never ticket, comment or repository text; placed before the built-in rules, which say they win; each agent gets only all plus its own entry; length- and character-checked; changing one in the UI needs the confirmation box tests/test_prompts.py
Telegram Only the configured user id; a fixed set of commands; strict callback parsing; plain-text messages tests/test_telegram.py
Slack Only the configured member id (buttons also only from the configured channel); a fixed set of /factory commands; the same strict callback parsing as Telegram; plain-text messages; no message events are subscribed to, so free text never reaches the factory; the Socket Mode client refuses masked, oversized, reserved-bit and non-text frames; other people are recorded by id, display name and channel only; until a member id is set (the app connects as soon as both tokens are saved, so set-up can be finished from the UI) nobody is obeyed and nothing is sent tests/test_slack.py, tests/test_wsclient.py
Multi-repo changes All patches validated before anything is pushed tests/test_runner.py
Design mockups written by the designer Only brand-new design/factory-<ticket>-<slug>.dc.html files (at most 3, 150 KB each); the patch must add nothing else. Each file is parsed against a tag allowlist: no scripts except the fixed support.js include, no event handlers, forms, iframes, images or url(), links are # only, the only external resource is Google Fonts. A failing file is dropped and the document still posts. Published on a draft PR from a factory/* branch, linked by commit SHA. The orchestrator records each file per run, and the admin UI links it (to GitHub, new tab) only after re-checking it with designfiles.link_ok; the UI never renders these designer files. With the designer's design_pr = false nothing is committed or pushed: the validated canvas is kept in the database and the UI serves it only as an attachment (application/octet-stream, nosniff, sandbox CSP, behind the login, names re-checked with designfiles.record_ok), and the rendered image only as a re-checked PNG. A designer run with no mockups gets a fixed line on the ticket tests/test_designfiles.py, tests/test_designer_files.py, tests/test_design_local.py, tests/test_ui.py
Rendered previews of design canvases After a canvas passes the design-file checks, a second container renders it to a PNG: no network, read-only root, no capabilities, no credentials or proxy, only that validated file mounted read-only and one output folder. The PNG is untrusted: it must be a real PNG within size limits, and the orchestrator commits it under a fixed name next to the canvas (previews/factory-<n>-<slug>.png) on the same draft-PR branch. A missing image, crash or timeout only means no preview tests/test_render.py
Design exports linked in a ticket ([design_links], off by default) The orchestrator, not the sandbox, fetches links from the issue body: https on port 443 only, no credentials sent, a host the admin listed (plain names, no wildcards), every redirect re-checked (at most 3), only public IP addresses (the connection goes to the address that was checked), a size cap, text/html or text/plain, UTF-8 without NUL. Never committed and never satisfies the mockup gate. The content is untrusted: rendered to a PNG in the sealed container, handed to agents under factory-chosen names (/task/design/import-<n>.html) in a <design_imports> wrapper as intent only, and served by the UI under a CSP sandbox (opaque origin, no scripts, no network, no forms) from the database by integer id. Backups blank the content tests/test_designlinks.py, tests/test_runner.py
Google Sheets client (factory/sheets.py; the sync that uses it is not built yet) The orchestrator, not the sandbox, calls Google: https only to oauth2.googleapis.com and sheets.googleapis.com (fixed in code, never from the key file, whose token_uri is ignored), no redirects followed, an 8 MB answer cap, a spreadsheet id checked against a fixed pattern before it goes into a URL. The service-account key is read from a file path (size-capped, only client_email and private_key kept) and reaches openssl through a pipe as /dev/fd/N, never on disk or a command line; openssl's output and Google's answers are never recorded, errors are fixed texts. The access token is cached in memory only. Every write uses valueInputOption=RAW, so nothing written is evaluated as a formula tests/test_sheets.py
Screen verification of built pages Screens come from trusted config, not the repo. After the patch is validated, the page code runs in one sealed container (no network, read-only root, no capabilities, no credentials, repo copy without .git mounted read-only); a second sealed container sees only PNGs. Every PNG must pass png_ok and match its baseline's size (no symlinks); the verdict is strict JSON of pixel counts that the orchestrator re-judges. Fails closed (missing image, baseline or screenshot fails the run, nothing is pushed). A patch changing baselines gives a labelled draft PR, and is rejected in a fix round tests/test_screens.py
Verification workers Checks and recipe names are trusted config on each side; a job carries a recipe name, never a command, so ticket text, the classifier and the agent cannot choose what runs. The patch is validated before it is queued. Workers authenticate with per-worker bearer tokens (constant-time compare) and can only touch jobs they claimed. Results are untrusted: a fixed status set, capped and control-stripped logs, PNGs that pass png_ok, names [a-z0-9-]; an invalid result fails the job. The gate fails closed (no worker, timeout or bad result = failed check) unless set to warn. A check that really fails gets at most fix_rounds agent retries (log text wrapped as untrusted tool output; never for infrastructure failures); advisory checks never block. The Workers settings need a confirmation to enable, weaken or change checks. On the worker, the patch is applied with plain git apply into a fresh clone with hooks disabled, and the recipe runs with a scrubbed environment, a timeout and a process-group kill tests/test_jobs.py, tests/test_workerapi.py, tests/test_verify.py, tests/test_verify_runtask.py, tests/test_verify_fix.py, tests/test_recipes.py, tests/test_worker.py
The code reviewer Read-only role: it posts a sanitized comment and nothing else (its optional follow-up proposals are a separate row below). The GitHub client has no approve / request-changes call, it only checks out branches the factory created, and a reviewer failure cannot undo a build tests/test_review.py
The project manager Read-only role. Its factory-priorities block is data, validated entry by entry: only tickets of the backlog it was given, a priority from a fixed set, at most 5 blockers that are open issues of the same repository; anything else is dropped, and a missing or malformed block changes nothing. Its only GitHub writes are adding or removing the fixed priority: high / priority: low labels it applied itself (a person's priority label is never touched) and a sanitized comment built from validated values. A priority only orders tickets that are already eligible; a blocker only holds a build back (never starts, stops or fails work), counts only while the blocker is open, and a trusted factory:unblocked label overrides it. Milestones, short names and categories in the same block are validated the same way (fixed lengths, one line, no ticket refs, paths, code or version numbers, at most 6 milestones and 8 categories, tickets of the backlog only) and written only to the factory's database, never to GitHub; anything a person made, worded or placed is never changed by it tests/test_pm.py, tests/test_pm_milestones.py
The review follow-ups Off unless review.follow_actions is set. The reviewer's factory-review-actions block is data, validated entry by entry: a label only from review.follow_labels (the loader rejects factory: and stage: labels and any trigger label, so an agent cannot start work), a send-back only to a configured stage, a one-line sanitized reason, at most 5 entries; anything else is dropped and the block is cut out of the PR comment. A proposal changes nothing. Only proposals a signed-in person picks on the ticket page (at most 25, ids checked against the database and the ticket) are applied, by the orchestrator: the ticket and its open PRs are re-checked first (closed, or PRs changed since the review, is marked stale), then a fixed comment and the label on the ticket, or the existing redirect:<stage> approval. PRs are never touched, and a dismissed proposal is not proposed again for the same PRs tests/test_reviewactions.py
The ticket review Read-only role, started only by a signed-in person in the admin UI (repository and sources come from fixed sets). Its factory-ticket-review block is data, validated entry by entry: only tickets of the snapshot it was given, a verdict of built or duplicate, built needs 1 to 5 evidence items that are repository paths or commit hashes (shown as code, never as links), a duplicate names another ticket of the snapshot (chains collapse, cycles and duplicates of a ticket proposed as built are dropped); anything else is dropped and a missing or malformed block changes nothing. A proposal changes no ticket. Only proposals a person picks (at most 25 at a time, ids checked against the database) are applied, by the orchestrator: the ticket is re-read first (one edited or closed since the review, or whose ticket to keep is closed, is marked stale and left alone), then a comment built from validated values and a sanitized one-line reason, the trigger labels come off, and the ticket is closed. Nothing is copied between tickets, and a dismissed proposal is not proposed again tests/test_ticketreview.py
Splitting a large ticket The analyst (read-only) may end its document with a factory-split block. It is data from untrusted ticket text: 2 to 10 items, one-line sanitized titles, sanitized bodies with length caps, a repository from the parent's project, and after positions that point only at earlier items; anything else, or a malformed block, drops the whole proposal and changes nothing. The block is removed from the posted document. Nothing is created until a person approves in the admin UI (CSRF-checked; the start action is looked up in the server's start options) or the chat buttons (split:<id>, matched strictly and checked against the ticket). Children carry no label unless the approver chose one start action, are created one recorded step at a time (a retry never duplicates one), and a build waits for the items it comes after whether or not the PM is on (only the trusted unblock label overrides). The umbrella closes only when every child is read as closed tests/test_split.py
Merge-conflict resolution Only open PRs on factory/* branches in the same repository (the label alone is not enough). The orchestrator merges the base branch into the branch on its pristine clone with no repository-defined merge drivers or hooks; the agent's patch may touch only the repos with conflicts, is checked against the merged tree (so protected paths and limits apply to the agent's own changes), and is refused if any conflict marker remains or a design canvas fails its checks. Conflicts in protected paths or binary files, and merges that change .github/workflows/, go to a person. The result is a normal merge commit pushed as a fast-forward: no rebase, no force-push. At most max_attempts runs per PR tests/test_conflicts.py
The admin UI Password (scrypt), CSRF on every POST, HttpOnly/SameSite=Strict cookies, login throttling, Host allowlist, strict CSP, read-only database access, escaped output, GitHub-only links tests/test_ui.py
The UI's Floor page Read-only picture of the orchestrator's database; the "Needs you" tray reads open tickets from GitHub with the server-side token (cached 20s, fixed error messages) and its buttons post to the same validated /tickets/start and /tickets/answer actions as the Tickets page. Questions are answered through /tickets/answer (several at once, validated against the questions on GitHub) and /tickets/answer-all (a fixed list of configured tickets, each re-read). Build and the stage buttons queue the same approval row the Telegram buttons write (the UI's only database write; repo, issue and action are validated first), because a label would send the ticket back through the classifier. All text is escaped; the CSP forbids inline styles, so positions live in the stylesheet. A signed-in admin can rearrange the floor at /floor/edit: the layout is a JSON document of grid positions and belt points (never markup), checked on the server on save (known keys and buildings only, whole numbers inside the floor, no overlaps, every hop of the route on a belt, 16 KB at most) and again on every render, where anything that does not fit falls back to the default picture. Save and reset are CSRF-checked POSTs with a revision check against a stale tab; the layout is the UI's second write, a file (floor-layout.json, mode 0600, written atomically) in the state directory, not the database. The editor script sets SVG attributes only tests/test_floor.py, tests/test_floorplan.py
The UI's Tickets page (start buttons, label editing, new and close ticket) Acts as the factory's GitHub account, server-side only: the repo must be configured, the issue number is validated, only labels that already exist can be added, search text is free text (no qualifiers), a new ticket has a title, body and at most one start action (length-limited; the browser names a choice from a fixed list of Auto and the read-only stages, never Build or a label, and an unknown choice is refused; no choice means no labels, so it does not start work; no assignees; repeats within 10s are refused), Close re-reads the ticket, refuses one already closed, then posts a fixed comment, removes its trigger labels and closes it (never a permanent delete); a ticket with work in progress can be closed, and the orchestrator (not the UI) sees the closed issue and kills that job's container, so nothing is pushed, errors are fixed messages tests/test_ui_admin.py, tests/test_close_stops_work.py, tests/test_ci.py
Backup and restore in the UI Download is a POST (session, Host allowlist, CSRF) of a sanitised copy made with SQLite online backup: no credential files, UI password, run output, logs, patches or queued work. Restore is untrusted input: a multipart upload spooled to state/.restore-tmp (512 MiB cap, CSRF checked before the body is read, work files always removed), a zip with known member names only and checksums, rows copied into a fresh database built by db.connect (no triggers, views or unknown tables; excluded columns blanked again), config validated with parse and the same db_path, then swapped in by the orchestrator at start-up with the old database kept; the factory stays paused tests/test_backup.py
The UI's Tests page (scenario register) Signed-in users only, CSRF on every POST. Scenario, comment and CSV text is untrusted and reaches tickets agents read: a ticket body is rebuilt on the server from stored rows, quoted, and cleaned with sanitize_markdown (no mentions, images or HTML); the start action comes from the start_options allow-list and nothing starts by default; a ticket is made only on a click. Export prefixes formula-like cells with an apostrophe. Import is size- and row-capped (1 MB, 2,000 rows), validated row by row, staged in memory per session, and written in one transaction only after a confirm; edits use a revision check tests/test_scenarios.py
Credentials in the UI Write-only: stored 0600, never rendered back, scrubbed from error messages tests/test_ui_admin.py
The UI's JSON API (/api/v1/, for the shikumi command-line client) A bearer token only: the session cookie is never read on /api/, so no CSRF field is needed and a signed-in browser cannot be made to call it; writes must be application/json (a page on another site cannot send that without the browser asking first) and the API sends no CORS headers. Tokens are made with ctl tokens add or on the Credentials page after the UI password is given again, shown once, stored as SHA-256 only in state/api-tokens.json (0600, written atomically under a lock), compared in constant time, revocable at once; read-only tokens are refused on every write. Wrong tokens are throttled per client address (20 in 5 minutes). The Host allowlist applies as for the pages. Every action runs the same function as its page (same checks, same messages, same GitHub writes as the factory's account); settings are not part of the API. Responses are JSON built from named fields only; ticket text is returned as stored (untrusted), and the client strips control characters before printing it tests/test_api.py, tests/test_apitokens.py
Settings changes Validated by loading the merged config before writing; confirmation for going live, widening the sandbox hosts, changing a harness, or changing an agent prompt tests/test_ui_admin.py, tests/test_ui_harness.py
Which hosts a sandbox can reach The proxy allowlist follows config, and keeps the last good list if a reload fails tests/test_harness.py

Residual risks (read these)

  • Linked design exports are third-party content. With [design_links] on, a person's link on an allowed host is fetched and read by agents (prompt injection is possible) and shown in the UI in a sandboxed tab. Keep the host list to services you trust.
  • Prompt injection can still produce bad output: harmful code in a PR, or a misleading analysis. The control is human review of every PR and branch protection on your default branch. The factory never merges.
  • Model credentials are inside the sandbox environment. Egress is limited to the model API host, so they cannot be sent elsewhere, but a hijacked agent can spend your quota or rate limit.
  • The engine socket (Docker mode). Mounting it into the orchestrator is root-equivalent on a rootful Docker. Use rootless Docker, or the native Podman install, which shares no socket.
  • Data leaves your machine to the model provider, and (if Jev is enabled) ticket titles, bodies and comments go to OpenRouter and TypeSafe for classification. Do not use free or logging tiers for private text without reading their terms.
  • Local ticket attachments are read by agents. Files attached to a local ticket (png, jpg, gif, pdf, txt, md, log, json, csv) are copied into the agent's /task/attachments/ and so go to the model provider. They are untrusted input in the prompt, are stored in the database (and so in backups), and the UI only ever serves them as downloads with a name and type the server chose.
  • CI runs your repos' code on factory PRs with whatever secrets your workflows expose to pull requests. That is your repos' configuration, not the factory's, but protected paths stop the agent editing workflows.
  • The admin UI is an admin surface. Anyone who can sign in can replace credentials and change what the factory does. Keep it on loopback or behind a VPN/TLS proxy, with a strong password.
  • An API token is as strong as the UI for tickets. Anyone holding a write token can start, close and answer tickets and merge a passed PR on that factory (not change settings). Keep it like a password: one per computer, revoke one you lose, and reach the factory over an SSH tunnel, a VPN or TLS (plain HTTP on a LAN exposes the token as it does the password). Behind a reverse proxy every client shares the proxy's address, so the token throttle counts them together.
  • The UI can start work. Its Tickets page applies labels as the factory's GitHub account, which the write-access check accepts, so a signed-in UI admin can trigger builds exactly as if they had applied the label on GitHub. The UI therefore also holds the GitHub token.
  • A worker runs agent-written code on a networked machine. (The Android recipe confines it to a throwaway container and the iOS recipe to a throwaway macOS VM; the web recipe does not.) Unlike the sandbox, a recipe can reach the network and anything its account can read. Use a dedicated unprivileged account or a throwaway VM, keep signing identities and other credentials off it, and give it only a read-only token for the repos it verifies. See docs/workers.md.
  • Harness commands are shell commands you configure, run inside the sandbox. They come from config, never from ticket text, but a bad one weakens the agent's behaviour (not the sandbox).
  • Token scope. The GitHub token can write branches and PRs in every repo it is installed on. Scope it narrowly and prefer a dedicated bot account.

Hardening checklist

  • Branch protection or rulesets on the default branch of every repo (required review, no force-push, no bypass).
  • A dedicated GitHub bot account; a fine-grained token limited to the repos you need; short expiry.
  • Model credentials with a spend limit (an API key in its own workspace).
  • allow_hosts contains only the model API host unless tasks truly need a registry.
  • Secrets are files with mode 0600 owned by the factory user, outside any repo.
  • The orchestrator runs as an unprivileged user with no sudo.
  • Only people you trust have write access to the repos (they decide what gets labeled).

Reporting a vulnerability

Please use GitHub's private vulnerability reporting (Security tab → Report a vulnerability) rather than a public issue.

There aren't any published security advisories