# Security

This page is the product half of security: what the platform holds, how it keeps one organization from another, and how to report a weakness. The SDK's own doors and residual risks are on [the threat model](https://durablesdk.com/docs/security/threat-model.md); the subprocessor sentence, the scanner pattern and `security.txt` are on [/security](https://durablesdk.com/security).

## The tenant boundary

- Every table that holds an organization's rows carries its id, and the database enforces row-level security on every one: a read or a write runs inside a transaction that names the organization first, and a read outside one sees nothing. The runtime role cannot bypass the policy.
- The organization is resolved by the gate alone, from the key or the signed-in session, never from a body or a query. An app looked up by its slug is then checked against the organization; a miss is a 404, never a 403, so a slug tells nothing about another organization.
- Every mutation is a keyed, ledgered run under the scope `tenant:<id>`; `GET /runs/:runId` answers 404 unless the run's scope is yours.
- An app's own runs, inputs, outputs and images stay in the app's database. The platform reads them through the Console tab's proxy at request time and stores nothing of them.

## What the platform holds, sealed

The platform keeps a short list of credentials for an app, each sealed under AES-256-GCM with a versioned key, a fresh nonce per seal, and the row's identity (its kind, organization, app, environment, database and id) bound as associated data, so a ciphertext moved to another row or organization opens to nothing:

- the app's operator API bearer pair and its cron secret (the Console tab and the production check need them);
- the database's owner password (rotation, the preview branch's rename and a schema down need it; it never leaves the platform and never reaches your laptop);
- the read role's password behind [the read string](https://durablesdk.com/docs/hosting/database.md);
- a secret's value in flight for the seconds between `PUT /apps/:slug/secrets/:name` and the write to the build's variables, deleted in the same step;
- a key minted by the browser hand-off, between the approval and the CLI's one poll.

A seal key is rotated by re-wrapping while both versions stand; a row whose key version the environment lacks is refused `plane.seal.key_missing` (503), never a crash. The platform's redaction policy names the shapes (a key, a connection string with userinfo, a bearer) and the field names (`password`, `token`, `secret`, `value`, `pollSecret`, `apiKey`, among others) so none reaches a step's output, a ledger image or a log line; a test on every run asserts it.

## The key at rest

An API key is forty uniformly random characters (about 238 bits) behind `dsk_live_`; the platform stores its SHA-256 and compares the presented key's digest in constant time, also when no row matches. A key has one scope, expires, and is minted by a person alone (`plane.key.mint_by_person`), so a leaked key cannot mint a wider one. The whole of it is on [accounts and keys](https://durablesdk.com/docs/operate/accounts-and-keys.md).

## The secrets you set

`PUT /apps/:slug/secrets/:name` carries the value in the JSON body over TLS; `durable-sdk secrets set NAME` reads it from stdin or `--value-file`, never from an argument, so a shell history holds none. The value lands in the build's variables as a sensitive variable and is never read back: `GET /apps/:slug/secrets` answers names, targets and stamps. The platform's own variable names are reserved and refused by name ([secrets](https://durablesdk.com/docs/hosting/secrets.md)).

## The upload's bounds

An upload belongs to one app and one principal and expires in an hour. Its size is judged at the open against your tier's `upload_mb` and at every part (every part but the last exactly `partBytes`, each with its `Content-SHA256`); the whole's SHA-256 is judged at `complete`. The tarball is inflated and walked as a stream, each bound refused at the entry that crosses it: 10 000 entries (`plane.upload.too_many_files`), 100 MB unpacked (`plane.upload.too_large`), a file over 10 MB (`plane.upload.file_too_large`); an entry that is not a regular file or a directory, a path that normalises outside the root, or a path that repeats is refused by name. Nothing is written to the platform's filesystem; the parts are deleted once the deployment is made, a failed upload's a day later. The CLI never packs `node_modules`, `.git` or `.env*` ([deploy](https://durablesdk.com/docs/hosting/deploy.md)).

## The app's doors

- An app's handlers answer only for the hostnames the platform gave it (`DURABLE_HOSTNAMES`); a request under any other host is a 404.
- A Console session is signed by the platform's own key for five minutes, for one audience (`durable-app:<slug>:production`), and spent once; a session minted for production opens nothing on a preview.
- The build's and the runtime's lines are your own output. At read they pass the redaction shapes first and a masking filter second, and are cut at 4 KB a line; they are stored raw for the platform's operator and filtered on the way out, never the other way round.
- A production build is checked on a hostname of its own before it is promoted; a red check stays off your hostname ([hosting](https://durablesdk.com/docs/hosting.md)).

## The cookie note

Your apps live at `<app>.durablesdk.com`, beside the dashboard at `durablesdk.com`: one site in a browser's eyes. The platform answers this in four ways: a session-authenticated API request is admitted only from the dashboard's own origin with `X-Durable-Org` and a JSON content type (anything else is 403 `plane.auth.origin_refused`), the dashboard's own cookies are host-only, a request that carries the session cookie twice is refused before sign-in runs (`plane.auth.cookie_tossed`), and every response forbids framing. The effect that remains: a sibling app can at most sign you out of the dashboard, never in. The apps' root is one variable, and moves to a root on the Public Suffix List the day that effect is not acceptable.

## Disclosure

Report a weakness to the address in `https://durablesdk.com/.well-known/security.txt`. Say what you found, where, and how to reproduce it; a first answer within two business days, a fix or a plan within thirty days for a confirmed finding, and your name in the changelog if you want it there. Do not test against another organization's app or data; make your own on the Free tier.

## Coming

A penetration test before general availability, a status page with a published SLO, per-app database keys (DS-037) and the rotation of an app's bearer pair (DS-038) are on [the roadmap](https://durablesdk.com/docs/roadmap.md).

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/operate/security.md, then apply what it says to this app; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
