Security
kōjō runs code it cannot trust: the repository’s code and what a model writes. This page describes the controls as they are built, and where they stop. It is for whoever decides whether and how to deploy kōjō.
The trust boundary
kōjō has two sides.
Core (kojo serve) |
Sandbox | |
|---|---|---|
| Holds | Forge credentials, Slack tokens, model keys, the database connection | A checkout of the repository, toolchains, a shell |
| Runs | The orchestrator, the goal critic, the merge policy, the forge API calls | Repository commands, tests, model-written code |
| Trust | Trusted | Untrusted |
| Credentials | All of them | None. It sees placeholders. |
| Network | As deployed | Only through a proxy, to allowlisted hosts |
The rules that keep the two apart:
- The core never runs a repository command and never shells out to git. Everything untrusted happens through the sandbox driver’s
Execand copy calls. - Pushes, pull requests, comments and merges are made by the core through the forge API. The forge adapters refuse to create a branch that is not
kojo/*, and to commit to one, with one exception: the branch of a person’s open pull request in the same repository, when its author asked or thekojo:commitlabel was added by someone withtrigger_permission(see commits on a person’s pull request). For that write the core names the pull request and the head it cloned, and the adapter reads the pull request itself and refuses unless it is open, its head is exactly that branch, it is not from a fork, and the branch is not the default branch. They write regular files only and refuse paths inside.git. No git hook runs in the core. - A follow-up adds a commit to an existing branch, and only to the
kojo/*branch of a pull request kōjō’s store recorded as opened by one of its sessions and the forge still reports open on that branch. The commit is pinned to the head the session cloned: the adapters write it only while the branch points there, so nothing a person pushed in the meantime is overwritten (see forge credentials for how each forge enforces it). - What the core reads back from a sandbox is bounded: 1 MiB per file, 2 MiB per diff, and at most 500 files and 16 MiB per published change.
- A session’s change is its own repository’s. Reference repositories a request names are cloned into
.kojo/refs/of the workspace, and the core leaves that directory out of every diff it takes, whatever a subagent stages: nothing under it is judged, committed or pushed. - Values a model produced do not become shell syntax in the core’s own commands: they travel as environment variables or are quoted. The one exception is a goal check whose whole command is a recorded value; it runs in the same sandbox the subagent already has a shell in.
Concepts has a diagram of the boundary.
Credentials
Where secrets live
Secrets are in kojo.yaml and its environment, and nowhere else. They are never stored in Postgres, never shown in the dashboard and never part of the runtime config. When kōjō prints its config, these values are masked: API tokens, the session secret, the OIDC client secret, the database password, the GitHub private key, forge tokens and webhook secrets, Slack tokens and the signing secret, issue trackers’ API keys, tokens and webhook secrets, model provider keys, the gateway key and the proxy admin token.
Skill kits and the runtime config name credentials; they do not hold them. A credential name resolves only when it is the name of a configured forge (github, gitlab, forgejo, bitbucket), and only for a session whose repository, or one of whose reference repositories, is on that forge. A kit cannot name its way to another secret. Which names a kit may use at all is limited by the admin’s settings/egress object; see Runtime config objects.
Forge credentials
| Forge | What the core uses | What a sandbox’s proxy injects for cloning |
|---|---|---|
| GitHub | A GitHub App. Installation tokens last about an hour, are cached per installation and renewed five minutes before they expire. | A separate installation token per request, limited to the session’s repository with contents: read and metadata: read. Read-only twice: by its scope, and at the proxy. |
| GitLab | The configured project or group access token, with the api scope |
The same configured token. It is not short-lived and not scoped down. kojo-proxy sets it only on git’s fetch. |
| Forgejo and Gitea | The configured access token of the bot user | The same configured token. It does not expire and is not scoped down. kojo-proxy sets it only on git’s fetch. |
| Bitbucket Cloud | The configured API token of the bot account, with the scopes listed on Bitbucket | The same configured token, for bitbucket.org and api.bitbucket.org. It lasts until the expiry date chosen when it was created and is not scoped down to the repository. kojo-proxy sets it only on git’s fetch on bitbucket.org, and only on reads on api.bitbucket.org. |
Every forge’s clone credential is marked read-only, and each forge marks the host it serves git from (github.com or the Enterprise Server host, the GitLab and Forgejo hosts, bitbucket.org); api.github.com and api.bitbucket.org serve only an API. On a git host kojo-proxy sets a read-only credential on git’s fetch and nothing else: its ref discovery, GET …/info/refs?service=git-upload-pack, and the POST …/git-upload-pack that follows, each on a clean path with no percent-escapes, after at least one other segment, outside the forges’ API routes such as /api/v4, /api/2.0 and /!api (the proxy page has the exact rule). Every other request to that host goes out without it, the API’s reads included: a token that can read a repository’s settings reads its secrets there, such as a GitLab project’s CI/CD variables (GET /api/v4/projects/:id/variables) and runners token (in GET /api/v4/projects/:id) for a Maintainer, or a Forgejo repository’s Actions variables and webhooks for an administrator. Nothing kōjō runs in a sandbox reads a forge’s API, and kōjō does not clone with Git LFS. On a host that serves only an API, which the core never adds to a sandbox (a kit has to name it), the credential is set on GET, HEAD and OPTIONS. A push is a POST to git-receive-pack, and a writing API call is a POST, PUT, PATCH or DELETE: like every request the rule leaves out, they still go out, but without the credential, so the forge treats them as anonymous.
On any host, and before the rule above, reads that answer with a token that can write are left out:
- GitLab’s
GET /jwt/authand Forgejo’s and Gitea’sGET /v2/tokenanswer with a container registry token, which can push when the request asks for that scope. GET …/conan/<version>/users/authenticate(GitLab, Forgejo, Gitea) answers with a Conan registry token, which uploads packages.- Forgejo’s and Gitea’s
GET …/actions/runners/registration-token(of a repository, an organization, a user or the instance) creates a runner registration token if there is none and answers with it. A runner registered with it is sent the repository’s jobs, each with a token that can push and with the workflow’s secrets. Forgejo answers it to a repository administrator, which the bot is.
None of them gets the clone credential, so a sandbox cannot use it to reach the forge’s registries or to register a runner.
GitLab, Forgejo and Bitbucket have no equivalent of an installation token, so on those forges the credential behind the proxy is the configured token itself: not short-lived, and able to write. With kojo-proxy (the k8s, e2b and docker drivers) a sandbox cannot use it to write, nor to read the forge’s API. It can still fetch with it: any repository that token can read on the forge host.
With the sbx driver, Docker Sandboxes’ own proxy sets the credential, on every request to its host. There the driver adds sandbox-scoped deny rules for each host of a read-only credential, before the credential’s value is stored: on a host that serves only an API every POST, PUT, PATCH and DELETE; on a git host everything but git’s fetch (HEAD, OPTIONS, PUT, PATCH and DELETE, every GET whose path does not end in /info/refs, every POST whose last segment does not start with git-u, and both under the API routes). sbx’s proxy answers a request they match with its own 403 and does not send it: where kojo-proxy sends a request without the credential, sbx refuses it, so on sbx a sandbox reaches a forge’s git host for git’s fetch only. sbx matches the path after decoding its escapes and cleaning it, and refuses a path with a .. segment outright. It cannot express kojo-proxy’s exact rule (a deny always beats an allow, its path globs cannot say “not this suffix”, and its rules match no query), so its rules are a little wider: they let through git’s ref discovery with another query, git’s own paths written another way, and API versions no forge uses, where no forge writes or hands out a secret. The sbx page lists them.
What each driver does with a read-only credential:
flowchart TD
R["Request from a sandbox to a forge host with a read-only clone credential"] --> H{"What the host serves"}
H -- "an API only: api.github.com, api.bitbucket.org" --> AM{"Method"}
AM -- "GET, HEAD, OPTIONS" --> SET["Credential set, kojo-proxy and sbx"]
AM -- "POST, PUT, PATCH, DELETE" --> NO["kojo-proxy: sent without the credential. sbx: refused with its 403"]
H -- git --> A{"Under an API route: /api/ then v1, v4, 2.0 or another version, graphql, forgejo, packages; or /!api?"}
A -- yes --> NO
A -- no --> M{"Method and path, after another segment"}
M -- "GET …/info/refs" --> Q{"Query exactly service=git-upload-pack?"}
Q -- "no: a push's discovery, git's older protocol" --> W["kojo-proxy: sent without the credential. sbx: credential set"]
Q -- yes --> C{"Exactly git's path: clean, no percent-escapes?"}
M -- "POST whose last segment starts with git-u" --> C
M -- "anything else: API reads, web pages, archives, HEAD, OPTIONS, writes, git-receive-pack, LFS" --> NO
C -- yes --> SET
C -- "no: another case, a longer last segment, a path sbx cleans or decodes into one" --> W
The kojo/* branch rule, and its exception for a person’s pull request, are enforced by the core’s forge adapters, not by the proxy; they do not bind a request a sandbox sends through a proxy.
When a follow-up adds a commit to one of kōjō’s pull requests, the core names the commit the session cloned, and each adapter refuses to write when the branch is somewhere else:
| Forge | How the commit stays on top of what the session cloned |
|---|---|
| GitHub | The branch is read first and must point at that commit; the new commit’s parent is that commit, and the branch is moved without force, so a push that lands in between makes GitHub refuse the move. |
| GitLab | The branch is read first and must point at that commit. Each updated or deleted file names the last commit that changed it there (last_commit_id), so a push that lands in between and changes one of those files makes GitLab refuse the commit; one that changed other files stays, under the new commit. |
| Forgejo and Gitea | The branch is read first and must point at that commit. Each updated or deleted file names its blob in that commit, so a push that lands in between and changes one of those files makes the forge refuse the commit; one that changed other files stays, under the new commit. |
| Bitbucket | The branch is read first and must point at that commit, and the new commit names it as its parent. Bitbucket refuses a commit whose parent is no longer the branch’s head, so a push that lands in between, whatever it changed, makes it refuse the commit. |
The core adds the repository’s forge host, and the forge’s clone credential for it, to every sandbox policy of a session. That is how the clone works. The clone URL itself carries no credential. A scope written on a credential in a kit is documentation only: the clone credential is read-only whatever the kit says.
A reference repository is cloned with its own clone credential, issued by its forge adapter in the same way and read-only in the same way. It is in the sandbox’s policy only while the core’s clone of that repository runs: for that time the policy is the reference’s git host and its credential and nothing else, and before the first skill starts it is the skill’s policy again, with the credential of the session’s own repository. On GitHub, where each token is limited to one repository, code in a sandbox therefore never has a credential for the reference repository. What it has is the checkout. Who may name a reference repository is decided at intake; see below.
The proxy and credential injection
A sandbox reaches the network only through a proxy that sits outside it.
With the k8s, e2b and docker drivers this is kojo-proxy, part of the kōjō binary. It runs inside kojo serve (embedded mode) or as its own deployment (kojo proxy, remote mode, the default for k8s).
- A sandbox authenticates to the proxy with its sandbox ID and a token of its own. The token selects that sandbox’s policy and is not a credential for anything else. A request without valid proxy credentials gets 407.
- A request to a host that is not on the sandbox’s allowlist gets 403, and so does one to a port its entry does not name: an entry without a port allows 443 and 80,
host:portallows that port. An empty allowlist denies everything. - An allowlisted host that resolves to a loopback, link-local, private or otherwise non-public address gets 403, unless
sandbox.proxy.private_hostsnames it (a forge on a private network) orsandbox.proxy.allow_privateis set (every host). The proxy resolves the name itself and connects to the address it checked, so DNS rebinding does not get past the check. This stops a sandbox from reaching the cloud metadata service or the network kōjō runs in. - For a host that has a credential, the proxy terminates TLS with a certificate signed by its own CA and sets the credential header. The sandbox trusts that CA; the CA’s private key stays with the proxy.
- Every other allowlisted host gets a blind tunnel that the proxy cannot read.
- The header is set when the request has none, or when it carries the placeholder (plainly, or inside a Basic value, which is how git sends tokens). A header the sandbox filled with something else is left alone. An expired credential is not injected.
- A credential marked read-only, which every forge clone credential is, is set only on
GET,HEADandOPTIONSrequests (except the two registry token reads) and, on a host that serves git, on git’s fetchPOST. Other requests to that host go out without it. - The proxy never logs a header value or a token. It does not chain through another proxy from its environment.
- In remote mode the core drives the proxy through an admin API protected by
sandbox.proxy.admin_token. The admin API does not start without a token. - In remote mode the core also keeps, in its own memory, the last policy it sent for each sandbox it has not destroyed, credential values included, so that it can send it again to a proxy replica that restarted, appeared or missed it. It resolves the credentials again before it does, and never sends a value that has expired. Nothing of it is written to disk, the database or a log.
- With several proxy replicas, every replica holds every sandbox’s policy, and the core sends every policy and every delete to each. A new or restarted replica reports not ready, and takes no sandbox traffic on Kubernetes, until a kōjō server has sent it the policies, or until
sandbox.proxy.sync_timeouthas passed; a replica no kōjō server reached holds no policy and refuses every sandbox. Every replica signs with the same CA: kōjō refuses several replicas withoutca_cert_fileandca_key_file, and refuses to start a sandbox while two replicas advertise different CAs.
Inside the sandbox, a credential appears as a placeholder: the environment variable KOJO_CRED_<NAME> with the value kojo-placeholder-<name>.
With the sbx driver kojo-proxy is not involved. Docker Sandboxes has its own host-side proxy; kōjō hands credential values to it on standard input, generates a kit with the allowlist, and adds deny rules that keep read-only credentials to git’s fetch.
The proxy’s deployment and settings are covered in kojo-proxy.
Egress allowlists and limits
Egress is deny by default. What a sandbox may reach is the result of three layers:
- The admin’s limits.
settings/egresslists the hosts and credential names any kit may ask for. Hosts are hostnames or*.domainpatterns, for ports 443 and 80, or with:portfor that port; a bare*is refused. A skill whose kit asks for more is dropped when skills are resolved, and a draft that asks for more cannot be activated or tested. Built-in skills are exempt, because their kits are part of the release. - The skill’s kit.
egress.allowandcredentialsinkit.yamlsay what that skill needs. - The session’s repository. The core adds the forge host and its clone credential.
Before every skill run the sandbox’s policy is applied again, which narrows the allowlist to that skill’s kit and refreshes short-lived tokens.
Whether a sandbox can bypass the proxy depends on the driver; see the next section. kojo doctor tests it.
Sandbox isolation per driver
A driver reports its isolation level. Only a microVM or gVisor counts as secure; kojo doctor fails otherwise.
| Driver | Isolation | Egress enforcement | Own Docker daemon |
|---|---|---|---|
sbx |
A microVM per sandbox, with its own kernel (Docker Sandboxes) | The sbx host proxy, outside the VM | Yes, inside the VM |
k8s with a Kata RuntimeClass |
A microVM per pod | A NetworkPolicy or CiliumNetworkPolicy that only lets sandbox pods reach kojo-proxy | Yes |
k8s with a gVisor RuntimeClass |
A user-space kernel | The same | No |
e2b |
A microVM per sandbox, at an E2B-compatible service | The service’s firewall, set per sandbox: all outbound traffic denied except to kojo-proxy’s address | No |
docker |
A plain container on the host’s kernel. Development only. | A Docker network created with --internal, on which the host has no address |
No |
A skill’s needs_docker is honoured where the driver can provide a Docker daemon. Where it cannot, the skill runs without Docker and its subagent is told so. On k8s it takes a Kata RuntimeClass and a privileged container, whose privilege is the VM’s as long as the container runtime keeps the node’s devices out of the VM (privileged_without_host_devices = true; see the k8s driver).
sbx
- The driver drives the
sbxCLI on the host, so kōjō must run on the same host as sbx. Postgres can run in compose. - The host needs hardware virtualization, a signed-in sbx (
sbx login) and the deny-all network preset (sbx policy init deny-all). Under another preset every sandbox can also reach that preset’s hosts; underallow-allthe driver reports that egress is not enforced. - sbx fixes a sandbox’s credential routes when the sandbox is created. kōjō therefore creates a sandbox with every credential the session’s usable skills on that image declare.
*.example.commatches one label in sbx, not any depth.- An allowlist entry without a port allows every port of its host in sbx, where kojo-proxy allows 443 and 80. An entry with a port allows that port in both.
- Everything the driver assumes beyond Docker’s documentation is listed in assumptions.go.
k8s
The k8s driver passed the driver conformance suite on kind with gVisor and with runc.
- The driver refuses a RuntimeClass that is neither Kata nor gVisor. The exception is development mode with a RuntimeClass labelled
kojo.dev/insecure-dev=true, which is how runc is used on kind. - No credential is written to the cluster. The pod spec, the claim and the ConfigMap hold the proxy’s CA certificate and placeholders.
- Sandbox pods do not mount a service account token. Their containers run without capabilities or privilege escalation, under the
RuntimeDefaultseccomp profile, except the privileged container of a kit that needs Docker on Kata. - With the Helm chart, sandboxes run in a namespace of their own,
<release namespace>-sandboxes, and kōjō’s Role is there only: it may run commands in the pods of that namespace, never in its own, kojo-proxy’s or Postgres’s. The Role grants what the driver calls and nothing more (no Secrets, no pod creation or deletion, no logs or events). - That namespace enforces Pod Security
baseline(privilegedon Kata), and a ValidatingAdmissionPolicy refuses pods, SandboxTemplates and Sandboxes that use the node’s namespaces, a hostPath, a privileged container (except on Kata), another RuntimeClass or ServiceAccount, or a mounted ServiceAccount token. So a compromised kōjō cannot use its Role to write a template that starts a pod on the node. A LimitRange bounds containers that name no resources. - The proxy environment variables direct traffic; they do not force it. What forces it is the network policy. The Helm chart ships one. The driver reports that egress is not enforced when no policy selects the sandbox pods.
- The proxy settings are set per command, not in the pod spec. A daemon that the image starts by itself does not get them.
e2b
With the e2b driver the sandboxes run at an E2B-compatible service, which is someone else’s infrastructure unless you host it yourself.
- The service runs your repositories’ code and holds a copy of each repository while its sandbox lives. It never gets a credential: a sandbox holds placeholders, and the real values stay in kojo-proxy, which you run.
- Every sandbox is created with all outbound traffic denied and one exception, the address of kojo-proxy, and with its public URLs closed to requests without the sandbox’s access token. The driver reads the sandbox back from the service and, outside development mode, removes one whose restriction the service does not report instead of using it.
Healthreports egress as enforced on the same evidence, and the egress probe ofkojo doctortries it from inside a sandbox. - The service’s allow list is by address: a sandbox can connect to every port of kojo-proxy’s address. Nothing else should listen there.
- kojo-proxy must accept connections from the service’s sandboxes, which for a hosted service means from the internet. Every request to it needs a sandbox’s ID and its token. The token travels in the HTTP proxy protocol, which is not encrypted, across the network between the service and the proxy. Someone who reads it there can use the proxy as that sandbox until the session ends: reach the hosts on its allowlist, with the credentials of its policy set on them (on a forge host, the read-only clone credential). Limit who can connect to the proxy’s port to the service’s addresses where the service publishes them.
- The service’s API key can run commands in every sandbox of its team and read their metadata, which includes each sandbox’s proxy token. Keep it out of
kojo.yamlwith a${VARIABLE}. - Everything the driver assumes beyond the service’s documentation is listed in assumptions.go.
docker
The docker driver needs dev: true in kojo.yaml. A container shares the host’s kernel, so this driver is not a boundary for code you do not trust. It keeps the rest of the model so that a development setup behaves like a real one: credentials stay outside, egress goes through kojo-proxy on an internal network on which the host has no address, and containers run with no-new-privileges, without NET_RAW and with a PID limit. Sandboxes on the same network can open connections to each other.
Prompt injection
Issue text, pull request text, comments, chat messages, file contents and command output can all contain instructions aimed at the model. kōjō does not try to detect them. It limits what a session can do whatever the model was told.
Who decides, before any model reads anything
Whether a request may change code is decided at intake, from who sent it, not from what it says:
- A forge mention starts work only when its author has the repository’s
trigger_permission(defaultwrite). - An automatic event runs only the skill an operator configured for it, and may change code only when the event’s author has that permission.
- In chat, only users with the
operatorrole may trigger write actions. - On an issue tracker (Linear, Jira, Asana), only people with the
operatorrole may trigger write actions, looked up in therbacobject by an email the tracker’s adapter vouches for. On Linear that is the address Linear reports for the user, which is the account’s sign-in identity. Jira and Asana give a bot no address it can rely on (Jira leaves it out of webhooks and hides it unless the person shows it; Asana does not say whether it was verified), so there onlyusersinkojo.yaml, which maps an account ID to an email, gives a person a role. Changes made by automations and apps have no email and are read-only. A ticket becomes work only on the one enabled repository thereposobject maps it to; one that maps to none or to several starts nothing. See Issue trackers. - A production alert from Sentry starts work only on the one enabled repository whose
alertsentry maps its project. Whoever can send an event to the project’s DSN (public in a browser or mobile application) chooses the error’s message, its environment, which frames arein_appand their source lines. Such a session may change code in that repository and nothing more: team memory is read-only to it, it cannot propose a schedule, its linked repositories are read-only, and its pull request is always a draft that kōjō never merges, whatever the merge policy, follow-ups included. Its commit is named after the Sentry issue only, and in its title and description a zero-width space breaks each closing or reopening keyword that a reference follows (#12,owner/repo#12, an address, a tracker key such asENG-12; the full list of forms is checked by tests of the pattern, not against live forges). The title still starts with the Sentry short ID, which a tracker that links pull requests by a key in the title can take for one of its own issues. An entry withmode: reportruns it read-only. The event’s user, request, contexts and breadcrumbs are never read. See Sentry. - A production alert from Datadog is held to the same rules, with the issue’s service in place of the project: whoever can make the service report an error chooses its message, its stack and, through its tags, the scope the monitor’s group names. Before answering the delivery, kōjō reads the issue with Datadog’s API and starts nothing when the issue belongs to another service than the scope’s (
alert_mismatch), or when the API refuses the request or answers about another issue (alert_unread), since the webhook carries no error of its own. When the API fails in a way that may pass, the delivery is answered503for Datadog to send again. A sample’s RUM session, trace, user and event are never read. See Datadog. - A merged pull request starts work on another repository only where an operator listed that repository and a skill under the merged one’s
on_merge. Those sessions are trusted: the operator asked for them, and the forge let the merge happen. The same holds whenon_mergenames the repository itself; a pull request such a session opened starts noon_mergesession when it merges, so a repository does not follow itself in a loop. - A failed check on one of kōjō’s own open pull requests starts a follow-up only where the repository opts in (
follow_up.checks), and only with the trust of whoever asked for the pull request, read again when the check fails: their forge permission, or their operator role in therbacobject. When that cannot be read again (a schedule, an API token, a role a chat surface vouched for), nothing runs. Review comments without a mention never start one. See Follow-ups. - A failed check on a person’s pull request starts a round only where the repository opts in (
follow_up.checks) and the pull request carries thekojo:commitlabel, with the trust of whoever added the label, read again at each round. A label added by someone withouttrigger_permission(on GitHub triage access, on GitLab a Reporter, can add labels) counts for nothing. See commits on a person’s pull request. - A failed check on the head of the default branch starts work only where an operator turned on
follow_up.default_branch. The repository’s build and tests wrote the request’s text, so it reaches models only as fenced data. Like an alert’s fix, the session may change code in that repository and nothing more, and its pull request is always a draft that kōjō never merges; failed checks on that draft start no round, because nobody’s trust is there to borrow. See a red default branch. - A message to a session at work is decided the same way: a mention on the session’s issue or pull request reaches it only when its author has
trigger_permission, a message in its chat thread or a comment on its ticket only when its sender has theoperatorrole, and the dashboard, API, MCP and CLI only take one from an operator. Anyone else’s mention is rejected as before, and anyone else’s chat message or ticket comment is a read-only request of its own. A message cannot make a session more trusted than its request, and a read-only session takes no messages. See Talking to a session at work. - A reference repository is read with kōjō’s access, so only a trusted request may name one, and only a repository that is enabled. The author of a mention must also be able to read the repository they name; when they cannot, the mention is handled without it. A private repository is not attached to a session that can publish on one that is not private.
For an event that a forge delivers, intake decides like this:
flowchart TD
E["Verified forge event"] --> EN{"Repository enabled?"}
EN -- no --> RJ["Rejected and audited"]
EN -- yes --> K{"Kind of event"}
K -- "push to the default branch" --> SY["The .factory files are read again, no session"]
K -- mention --> PM{"Author has trigger_permission?"}
PM -- no --> RJ
PM -- yes --> AW{"A session at work on the same issue or pull request?"}
AW -- yes --> MS["Message to that session"]
AW -- no --> OW{"An open pull request kōjō opened?"}
OW -- no --> TR["Session, trusted"]
OW -- yes --> FU["Follow-up on its branch, trusted, within its rounds"]
K -- "check failed on an open pull request kōjō opened, follow_up.checks on" --> BT{"Requester of the pull request still trusted?"}
BT -- no --> RJ
BT -- yes --> FC["Follow-up with the requester's trust, within its rounds"]
K -- "issue opened, pull request opened or updated, check failed" --> AU{"Skill configured for the event?"}
AU -- no --> IG["Ignored"]
AU -- yes --> PA{"Author has trigger_permission?"}
PA -- yes --> TA["Session with that skill, trusted"]
PA -- no --> UA["Session with that skill, untrusted"]
A request from anyone else is untrusted. The orchestrator is told so, and the limits are enforced in code:
- It only reaches skills that cannot change the workspace. Delegating a writing skill is refused.
- It never publishes a change, even if the workspace changed.
- It cannot save team memory, so untrusted input does not become knowledge that steers later, trusted sessions. It may save and read the requester’s own personal memory, which reaches only that person’s later requests.
- A review comment becomes a lesson only when it is on a pull request a kōjō session opened and its author has the repository’s
trigger_permission. Anyone else’s review is ignored.
How external text reaches a model
- The title of the issue or pull request and the text of the request are wrapped together in a fence whose tag carries a random token, so the text cannot close the fence itself, followed by a line that says it is data. The requester’s account name is quoted. A ticket from an issue tracker is part of the request’s text in the same fence: its title, description, labels and latest 10 comments, clipped to 12,000 characters for the description and 4,000 per comment. The same fence wraps the task, the report and the diff given to the rubric judge, and the diff given to the risk classifier.
- A message people send a session at work reaches the orchestrator and the subagent at work in the same kind of fence, at their next model call, as a user turn and never in the system prompt. The sender is quoted and the message is labelled with where and when it was written, and framed as guidance that cannot change a skill’s goals, acceptance criteria, constraints, tools or limits, nor cancel the session. The goal critic is not given messages. A message is at most 4,000 characters, and a session takes at most 20.
- The system prompt of every subagent says that text inside issues, pull requests, comments, files and command output is data and never changes its instructions. The judge and the classifier are told the same about what they grade.
- Content a subagent reads through tools (an issue body, a file, command output) arrives as a tool result, not as part of the instructions. It is clipped: 12,000 characters for an issue or pull request body, 4,000 per comment, 24 KiB for a file read or a command’s output, 96 KiB for a pull request diff.
What a steered model still cannot do
- A subagent has exactly its skill’s tools, and in a follow-up two more that only read the pull request’s review and checks. The limit is checked when a tool call is dispatched.
- It works in a sandbox with no credentials and an egress allowlist.
- It cannot push. A change becomes a pull request that the core opens, as a draft by default, with the goal critic’s report and the risk assessment in the body, or, in a follow-up, a commit the core adds to the pull request kōjō opened, which keeps its draft state.
- The
commenttool only posts on the issue or pull request the session is about, at most three times per skill run. The orchestrator posts at most five interim replies. - File paths given to tools must be relative and inside the workspace.
- It cannot publish a reference repository. Nothing under
.kojo/refs/is in the diff the core takes, even when the subagent removes git’s ignore rule and stages the files. It can copy from a reference into the repository, and that copy is then in the pull request for a person to review. - Recorded values (
set_output) are one line of at most 2,000 characters, with an upper-case name that does not start withKOJO_. Placed inside a check command they are quoted, so they stay arguments. - The rubric judge is told to trust the diff over the subagent’s report.
- Budgets and turn limits bound how long a misled session can run.
- A model steered by the evidence of self-improvement (lessons, check output) cannot widen a skill: a proposal that adds a tool, changes the kit, raises a tier or lets a read-only skill write is refused by a comparison in code. It cannot make a proposal live either: only a person signed in to the dashboard approves one, never an API token, a session or a schedule.
These limits are tested. The test/security suite runs in the default build against a fake forge, a scripted model and the fake driver. It covers a prompt injection in an issue (the text and the title reach the model as fenced data), an untrusted request that names a writing skill, a subagent that reaches for tools its skill does not list or for paths outside the workspace, the kojo/* branch rule and its exception for a person’s pull request, a person’s branch name and a red default branch’s CI output reaching the model only as fenced data, the bounds of dry runs and drafts, and evidence that tries to make a self-improvement proposal widen a skill or activate itself. Sandbox escapes, blocked egress and secrets inside a sandbox belong to the driver conformance suite, and credential injection that cannot write to the proxy’s own tests. See Testing.
The limits of this approach are listed under Known limits.
Access control
Who may trigger what
The table of sources and conditions is in Concepts. The setup of each surface is in Surfaces.
Roles and the dashboard
kōjō has four roles: viewer, skill:edit, operator and admin. Every API route requires one. What decides how far the factory may go on its own (merge policy, egress and credential limits, RBAC, the skills source, the activation gate, auto-merge on a repository) needs admin. The full tables are in Managing kōjō.
- Sign-in is OpenID Connect: authorization code flow with PKCE, state and nonce, a verified ID token, and an optional list of allowed email domains. The token must say its email address is verified (
email_verified: true); a provider that never sends the claim is accepted only withserver.auth.oidc.trust_unverified_email, whichkojo doctorwarns about. Earlier versions accepted a token without the claim. Details: verified email addresses. The session cookie is signed with HMAC-SHA256, lasts 12 hours, and isHttpOnlyandSameSite=Lax; with an https public URL it isSecureand named with the__Host-prefix, so no other host can set it. The sign-in flow’s cookie carries its 10-minute expiry inside its signed value. Details: sign-in. - Roles are read on every request from the
rbacobject, so removing a role applies at once. - Unknown users get nothing by default. A signed-in user whom the access settings do not name has no role and every API call answers 403. Only when
server.auth.oidc.allowed_domainsrestricts sign-in to your own email domains does such a user getviewer. - CSRF: a state-changing request made with the session cookie must carry the
X-Kojo-Csrfheader. Details: CSRF. - API tokens are static bearer tokens from
kojo.yaml, at least 16 characters, each with one role. They are compared in constant time. - Response headers: the web UI is served with a Content-Security-Policy that allows only same-origin scripts,
X-Frame-Options: DENY,X-Content-Type-Options: nosniffandReferrer-Policy: same-origin. API responses are sent withCache-Control: no-store. - Changes are gated: skill drafts never run in real sessions, activation can require an eval and a second reviewer, and every config change is a revision that can be rolled back.
- Repositories need branch protection. Enabling a repository is refused unless its default branch is protected on the forge, because a draft pull request is a safeguard only where nothing can be pushed past it.
dev: trueskips the check. - The last admin stays. A change to the access settings that would leave no admin is refused. An API token with the
adminrole counts as one.
MCP clients use the same API with an API token, so an MCP client can do what its token’s role allows.
Webhook verification
Every inbound webhook is verified before its body is decoded. A request that fails gets 401. A surface without a configured secret rejects every delivery.
| Surface | Endpoint | Verification |
|---|---|---|
| GitHub | POST /webhooks/github |
HMAC-SHA256 of the body in X-Hub-Signature-256, keyed with forges.github.webhook_secret, compared in constant time |
| GitLab | POST /webhooks/gitlab |
The secret token in X-Gitlab-Token, compared in constant time with forges.gitlab.webhook_secret |
| Forgejo and Gitea | POST /webhooks/forgejo |
Hex HMAC-SHA256 of the body in X-Forgejo-Signature or X-Gitea-Signature, keyed with forges.forgejo.webhook_secret, compared in constant time |
| Bitbucket | POST /webhooks/bitbucket |
sha256= and the hex HMAC-SHA256 of the body in X-Hub-Signature, keyed with forges.bitbucket.webhook_secret, compared in constant time |
Slack, http mode |
/slack/events, /slack/interactive |
Slack’s v0 scheme: HMAC-SHA256 of v0:<timestamp>:<body> in X-Slack-Signature, keyed with chat.slack.signing_secret. The timestamp must be within 5 minutes. |
Slack, socket mode |
None | No inbound HTTP. kōjō opens a WebSocket to Slack with the app-level token. |
| Linear | POST /webhooks/linear |
Hex HMAC-SHA256 of the body in Linear-Signature, keyed with trackers.linear.webhook_secret, compared in constant time. The body’s webhookTimestamp must be within a minute, and a delivery from another workspace than the API key’s is ignored. |
| Jira Cloud | POST /webhooks/jira |
sha256= and the hex HMAC-SHA256 of the body in X-Hub-Signature, keyed with trackers.jira.webhook_secret, compared in constant time. An unsigned delivery is refused. |
| Asana | POST /webhooks/asana |
Hex HMAC-SHA256 of the body in X-Hook-Signature, compared in constant time with each secret in trackers.asana.webhook_secrets. A handshake (X-Hook-Secret) is answered with its own secret and carries no events; kōjō does not keep that secret, so a webhook someone else creates to kōjō’s address delivers nothing. |
| Sentry | POST /webhooks/sentry |
Hex HMAC-SHA256 of the body in Sentry-Hook-Signature, keyed with alerts.sentry.client_secret, compared in constant time. Sentry signs no timestamp, so a captured delivery can be sent again: a delivery whose ID is kept with a session it started starts nothing more, a delivery that started nothing (turned down, for example while the issue had a session open) can start one when sent again later, and the per-issue bounds (one session at a time, one open pull request, three sessions, max_per_day) limit what any of them can start. An event of another organization than alerts.sentry.org is ignored. |
| Datadog | POST /webhooks/datadog |
Datadog signs no webhook. The webhook sends alerts.datadog.webhook_secret (at least 32 bytes) in X-Kojo-Webhook-Secret, from a custom variable hidden from view, compared in constant time before the body is read; a body larger than 64 KiB is refused. A captured delivery can be sent again: its event ID is kept only with a session it started, so such a delivery starts nothing more, while one that started nothing (turned down, for example while the issue had a session open) can start one when sent again later. The per-issue bounds limit what any of them can start. Anyone who may edit Datadog’s Webhooks integration can use the hidden variable in another webhook. The keys pin the organization: an issue of another one cannot be read, and then nothing starts. |
A webhook body may be at most 25 MiB, and the routes above read it before they can check its signature. So that a sender without the secret cannot hold the server with slow or large bodies, each of these routes, Teams’ included, gives a body 30 seconds to arrive and then closes the connection, and at most 64 deliveries across them are read or handled at once: one more is answered 503 with Retry-After straight away, without being read. The dashboard, the API and /mcp are not behind either bound. A forge delivery is processed once: its delivery ID is the request’s deduplication key.
Shareable session reports
One page is public by design: a shareable report at <server.public_url>/r/<token>, which anyone with the link can read without signing in. It exists so that reviewers without a dashboard account can follow the links of a pull request’s description. What makes it safe to publish:
- Only where an admin allows it.
settings/reportsispublic_reposby default: sessions on a repository that was public when they ran, whose code, change and pull request are public already. A private repository gets reports only withall, set by an admin. A session that is confidential (a GitLab confidential issue or internal note, or a skill markedconfidentialsuch assecurity-audit) never gets one. The rules are applied again each time a link is opened. - Redacted by an allow-list. The page shows the tool calls with their purpose and output, commands, the goal critic, the risk and the change. It leaves out prompts and model text, memory, messages people sent, a request’s text and author when they came from a private place, sandbox details, kit setup, unknown tools, GitLab issue and comment contents, config revisions and error detail, and it removes URL passwords (a sandbox’s proxy token) and credential placeholder names from what it shows. The full list and the reasons are on the page’s own documentation.
- Unguessable, signed, bounded links. A token is signed with a key derived from
server.auth.session_secretand carries its session, its expiry (30 days by default) and its session’s revocation count. kōjō stores no token, logs none and audits none. An admin revokes all of a session’s links at once; changing the session secret ends every link. - A page that runs nothing. No script, a CSP that allows only the page’s own style by its hash,
Referrer-Policy: no-referrerso the token is not handed on,noindex,no-store, no framing. Every piece of text from outside or from a model is HTML-escaped and no link a model wrote is clickable.
Making a link needs the operator role and is audited as report.link; revoking needs admin (report.revoke); saving the page as a file needs operator (report.export).
The audit log
Actions are recorded in the audit_log table with a time, an actor, the session and a dotted action name: session.start, session.end, session.cancel, request.reject, skill.run, sandbox.create, sandbox.destroy, merge.decide, pr.open, pr.merge, comment.post, approval.ask, approval.decide, approval.expire, memory.save, memory.read, memory.delete, memory.erase, memory.learn, pr.edit, pr.close, reference.refuse, config.activate, config.rollback, skill.activate, auth.login, proxy.deny and others.
The table is append-only, enforced by the database. Two triggers raise an exception: audit_log_append_only on every UPDATE and DELETE of a row, and audit_log_no_truncate on TRUNCATE. kōjō has no code path that rewrites an entry.
Read and export the log as described in Audit log.
Secrets in kojo.yaml
kojo.yaml takes secrets from the environment by interpolation.
| Form | Meaning |
|---|---|
${VAR} |
The value of the environment variable VAR |
${VAR:-default} |
The value of VAR, or default when VAR is unset or empty |
$$ |
A literal $ |
The rules:
- Substitution happens on the parsed YAML, in scalar values only. Keys and comments are never touched, so a commented-out block does not demand its variables.
- A value is always one YAML scalar, whatever it contains: a PEM key with newlines, a password with
#or:. - A variable that is unset or empty and has no default is an error. All missing variables are reported in one message and kōjō does not start.
- An unquoted value keeps YAML’s typing after substitution (
workers: ${N}is a number), but a substituted value never becomes null. - A
${VAR}reference inside{ }or[ ]must be quoted, because the braces are YAML syntax there. - Unknown keys in
kojo.yamlare errors.
database:
url: "${DATABASE_URL}"
forges:
github:
app_id: "${GITHUB_APP_ID}"
private_key_file: /secrets/github-app.pem
webhook_secret: "${GITHUB_WEBHOOK_SECRET}"
Every key is listed in the kojo.yaml reference. How to supply the environment in compose and Helm is in Deploy.
What kojo doctor checks
kojo doctor builds the checks from the local kojo.yaml, or asks a running server with --remote. It runs every check, never stops at the first failure, and exits 1 when one fails. --skip-probe leaves out the check that creates a sandbox; --json prints the report as JSON.
| Check | Fails when | Warns when |
|---|---|---|
mode |
dev: true is set |
|
database |
Postgres is unreachable, or migrations are pending | The store is not Postgres |
team memory |
pgvector is not installed: memory search uses full-text search only | |
sandbox driver |
The driver’s backend is not usable | |
sandbox isolation |
The isolation is not a microVM or gVisor | |
sandbox egress |
The driver reports that sandboxes can bypass the proxy | |
sandbox docker |
Sandboxes cannot run their own Docker daemon | |
egress probe |
A test sandbox with an empty allowlist reached example.com, through the proxy or around it; or the probe could not run |
The image has neither curl nor wget; or the probe was blocked but the driver does not claim to enforce egress |
forges |
No forge is configured | |
forge <name> |
The forge is unreachable or the app or token lacks permissions | |
repositories |
No repository is enabled | |
trigger permissions <repo> |
kōjō cannot read user permissions on an enabled repository, so no mention can be authorized. On Forgejo, Gitea and Bitbucket the bot account must be an admin of the repository. | |
branch protection <repo> |
The default branch of an enabled repository is not protected; or the repository uses auto_merge and the branch has no required checks |
|
skill activation |
Skill changes can be activated without an eval | |
budgets |
No per-session and no per-day budget is set | A tier has no price, so its calls cost 0 and are not capped |
model gateway |
Recorded responses are replayed: no real model is called | |
model provider <name> |
A provider that a tier, a fallback or the embedder uses is not set up, its credentials do not resolve, or its first model does not answer within 60 seconds | A provider that kojo.yaml configures and nothing uses has credentials that do not resolve |
model tier <name> |
The tier’s model does not answer within 60 seconds | |
chat <name> |
The chat tokens do not work | |
dashboard sign-in |
Neither OIDC nor an API token is configured | OIDC is not configured; or server.auth.session_secret is not set |
session reports |
server.auth.session_secret is not set, so no link to a shareable report is made |
|
dashboard admins |
OIDC is configured and nobody has the admin role |
|
public URL |
server.public_url is not HTTPS |
|
network policies |
The Helm chart runs with networkPolicy.enabled: false (server.network_policy: false), so any pod in the cluster can reach Postgres, kojo-proxy’s admin port and the metrics port. Installs that do not set server.network_policy get no line. |
The egress probe is skipped when sandbox.image is not set, because there is no image to create the probe sandbox from.
Run doctor after every change to kojo.yaml and in your deployment pipeline. Install and first-run steps are in Install.
Known limits
These are the places where the build is weaker than the model above reads.
Limits of the sandbox drivers
- The
dockerdriver does not isolate and is for development. - On Kubernetes, egress is only as strong as the network policy and the CNI that enforces it.
- The sandbox namespace’s admission policy needs Kubernetes 1.30 or later. Without it, Pod Security alone checks the sandbox pods, nothing checks the SandboxTemplates kōjō writes, and on Kata, where the level is
privileged, nothing besides the driver’s own pod spec keeps a sandbox off the node’s namespaces. - With the
e2bdriver, egress is only as strong as the service’s firewall. The driver checks what the service reports about each sandbox; it cannot see the firewall itself. A sandbox’s proxy token crosses the network between the service and kojo-proxy unencrypted. - The egress probe needs
curlorwgetin the sandbox image.
Limits of the forge credentials
- GitLab, Forgejo and Bitbucket clone credentials are the configured token: not short-lived and not scoped to one repository. kojo-proxy sets it only on git’s fetch, so with the
k8s,e2banddockerdrivers a sandbox cannot push, call a writing API or read the forge’s API with it; withsbx, deny rules refuse everything else on the forge’s git host. Code in a sandbox can still fetch with it: any repository that token can read on the forge host, not only the session’s repository. This includes code from a pull request by an untrusted author, when a skill that runs commands is configured to run automatically on pull requests. Give that token the narrowest role and scope that works. - With the
sbxdriver the read-only rule is a set of deny rules in sbx’s proxy, not kojo-proxy’s exact match. On a git host aGETof…/info/refscarries the credential there whatever its query (sbx’s rules match none): a push’s ref discovery and git’s older protocol list the same refs as a fetch’s. So does a request whose path sbx reads as git’s written another way (another case, a longer last segment of aPOSTthat starts withgit-u, empty or.segments, a trailing slash or percent-escapes, which sbx cleans and decodes), and one under an API version no forge uses (/api/v2,/api/3.0); no forge has a writing endpoint or a secret at such a path. A method other thanGET,HEAD,OPTIONS,POST,PUT,PATCHandDELETEalso carries it. The rules are per host, so a credential that may write, set on the same host as a read-only one, is held to them too. sbx refuses what kojo-proxy would send without the credential, so a request to the forge’s git host that works anonymously, such as a public repository’s API, its pages and archives, or Git LFS, fails there. Each rule takes about 0.4 seconds to add: a sandbox with a forge’s clone credential (one git host, 38 rules) takes about 15 seconds longer to create. - A fetch from a GitLab subgroup path that looks like an API route,
…/api/<v1|v4|2.0|graphql|packages|forgejo>/…(a subgroupapiwith such a subgroup under it), goes out without the credential on kojo-proxy and is refused on sbx, so a private project there cannot be cloned from a sandbox. - The forge’s container and Conan registries cannot be used with the clone credential from a sandbox, and no runner can be registered with it, on any driver: GitLab’s
/jwt/auth, Forgejo’s/v2/token,…/conan/<version>/users/authenticateand…/runners/registration-tokennever get it. - kojo-proxy keeps sandbox policies in memory. A restarted replica holds none until the kōjō server that set a policy sends it again, a few seconds; with several replicas it is not ready until then, and a single replica answers 407 meanwhile. If that kōjō server restarted as well, the sandbox gets 407 from a restarted replica until its session runs its next skill, which applies the policy again.
- A proxy replica that kōjō cannot reach, while sandboxes still can, keeps its policies as they were until kōjō reaches it again: a policy replaced or deleted in the meantime still applies there, so a deleted sandbox’s token still selects its policy on that replica. kōjō retries every 2 seconds, gives up on a replica only when it restarts or is no longer discovered, and
kojo doctorfails on a ready replica that lacks policies or deletes. A singleadmin_urlwith a load balancer in front of several replicas would leave all but one behind: kōjō logs it at error level andkojo doctorfails. - Branch protection is read when a repository is enabled, by
kojo doctor, and before an auto-merge. It is not watched in between: protection removed on the forge later is found by the next doctor run, not at once.
Limits of reference repositories
- The contents of a reference repository are in the sandbox while skills run, and a skill’s change is made from them. kōjō refuses the one case it can decide, a private reference for a session that publishes on a repository that is not private. Between two private repositories with different readers, what may flow from one to the other is decided by which repositories are enabled and who has the trigger permission.
- A reference repository’s code, comments, diff and pull request description are untrusted text like any file. A trusted session that reads them can be steered by them, within the limits above.
- On GitLab, Forgejo and Bitbucket the clone credential of a reference repository is the same configured token as the session’s own, so the rule that it is only in the policy during the clone changes nothing there.
.kojo/refs/at the root of a workspace is reserved. Changes a session makes to files a repository tracks under that path are not published.
Limits of the prompt-injection defence
- kōjō does not scan or filter content. The defence is the limits on what a session can do.
- A maintainer’s mention makes a session trusted, and the issue or pull request it then works on may have been written by anyone. A model steered by that text can still write a wrong or malicious change inside the sandbox. It arrives as a pull request for a person to review, which is why draft pull requests are the default and why auto-merge is opt-in.
- A trusted session can save team memory, and what it saves may be influenced by untrusted text it read.
- A lesson is distilled from a maintainer’s review comment, but the model that distils it also sees the pull request’s title, body and diff, which may derive from an issue anyone wrote. They are fenced, and the model is told that only the comment teaches. A bad lesson can be found and deleted on the Memory screen, which shows the review each lesson came from.
- What a person saved to their personal memory can appear in the replay of their sessions (tool inputs and results), which anyone with the
viewerrole can read. - A repository’s
AGENTS.mdand.factory/memoryfiles, read from the default branch, become part of a subagent’s system prompt. Whoever can change the default branch controls them. - A skill marked
confidentialonly keeps the session’s closing comment off a repository that is not private, and the session from having a shareable report. It does not stop that skill’s subagent from posting with thecommenttool.
Limits of the dashboard and API
- The session cookie is stateless. Signing out clears it in the browser; there is no server-side revocation. A person removed from the access settings loses their roles at once. Where
allowed_domainsis set they stay avieweruntil the cookie expires, at most 12 hours later. - API tokens are static and do not expire. Rotating one means editing
kojo.yamland restarting. - A shareable report link is a bearer link: it is tied to no person, so whoever has it, a forwarded copy included, can read the report until it expires or an admin revokes the session’s links.
/healthzand/readyzare served without authentication on the main port./metricsis served without authentication on a port of its own (server.metrics_listen, loopback by default), so keep that port off public networks. The Helm chart serves it on:9090; withnetworkPolicy.enabledonly the peers innetworkPolicy.metricsFromreach it, and with none named, no pod does.
Limits of the audit log and budgets
- The audit triggers refuse
UPDATE,DELETEandTRUNCATE. A database role that owns the table can still drop them. Restrict who can connect to the database with such a role. - A failed audit write is logged and does not stop the work.
proxy.denyentries are written by the embedded proxy only. A standalonekojo proxyhas no database: it logs every refusal as anegress refusedline with the sandbox, the host, the port, the method and the reason, and it has no audit entries and no metrics endpoint.- kōjō ships no model price table. A tier without a configured price costs 0, so the USD budgets do not bound it.
Reporting a vulnerability
Report vulnerabilities privately. Do not open a public issue or pull request for a security problem.
Use GitHub’s private vulnerability reporting for the repository: report a vulnerability. The policy, what to include, the scope and what to expect are in SECURITY.md.