The security model

A midad program states what it may touch, and the runtime holds it to that. This page is the reader's version of the record in docs/SECURITY.md: what is checked, what is not, and where the checks live.

The one-sentence version: the model bounds what a program can reach through the builtins, which is the case worth caring about when you run a small program you did not write. It is not a sandbox against a native library, and it is not a promise that the compiler is free of bugs.

What a program can reach

Nothing, until the frontmatter grants it. The grants are in the frontmatter: fs_read, fs_write, net, env, ffi, listen, db, ai and eval. Each names what it covers, and "*" is the only way to cover everything.

Checked twice

Every grant is checked statically against a literal argument by midad check, and again at run time against the target the call actually uses. The static check alone is not a sandbox; the runtime check is. Both are needed, and neither replaces the other.

A native build bakes the allowed paths and hosts into the binary, so it refuses a "*" grant by name rather than enforce something weaker than the interpreter does.

Properties that hold today

Each of these is a claim with a check behind it, not a hope.

property what holds
integer arithmetic + - * / % refuse to overflow on every path; overflow is R0001: integer overflow
a grant's meaning a relative grant and a relative path resolve against the program's directory, so a launcher cannot change what a program reads
HTML output {{ expr }} escapes & < > " '; raw output needs {{! expr }}, visible in the source
a bad request a body over the limit answers 413, a failing handler 500, a full pool 503, and the process keeps serving
an outbound call http_get inside a route waits no longer than the request budget, so a slow host costs one request rather than the process
a slow client a request whose headers have not arrived in 10 s is closed; past the connection ceiling a connection is answered 503 and closed rather than queued
a file read or write capped at 16 MiB, checked before the read and again on what came back
a compiled binary's http_get uses the interpreter's own client, refuses every private address before the request, pins the resolved address, and follows no redirect
crypto SHA-256 and HMAC-SHA-256 are checked against FIPS 180-4 and RFC 4231 on both paths
a native build refuses by name what it cannot do exactly, rather than compile something that behaves differently

The overflow rule, on its own:

error-1.md
---
midad: "0.1"
module: over
---

```exec
print(str(9223372036854775807 + 1));
```
midad run (exit 1)
error-1.md:7:1
  × R0001: integer overflow
   ╭─[error-1.md:7:1]
 6 │ ```exec
 7 │ print(str(9223372036854775807 + 1));
   · ──────────────────┬─────────────────
   ·                   ╰── integer overflow
 8 │ ```
   ╰────

What is not covered

  • ffi is not a boundary. A granted library runs with the process's full rights.
  • No TLS in the server. midad run speaks plain HTTP; TLS is the proxy's job.
  • No rate limiting. Per-request logging and request ids exist and are off by default, so a server started without them cannot tell you who sent what.
  • No fuzzing target yet. The fuzzers that run are deterministic seeded passes over the parser, checker and interpreter; there is no corpus-driven fuzzing aimed at the JSON reader, the template reader or the HTTP parser.
  • The dependency audit does not fail the build. An advisory in a direct dependency still arrives as a green check.
  • No memory-safety guarantee for the C backend. It is C, checked by parity suites and by ASAN during development, with no proof and no sanitizer in CI.
  • No review from outside the project.

The permission corpus

security/permissions/ holds one directory per attack on the model, each with a case.sh that exits 0 when the model held. run.sh runs them all and CI runs it on every push:

$ MIDAD=target/debug/midad ./run.sh
pass    07_fs_computed_traversal   PASS runtime canonical check refuses computed traversal

A case whose gap is known and not yet closed carries a KNOWN marker: it is reported separately, the suite stays green, and the finding stays visible. A KNOWN case that starts passing is reported as FIXED and asks for its marker to be deleted, so a marker cannot outlive the gap. The open findings, with the mechanism and a reproduction for each, are in security/permissions/FINDINGS.md and listed by release in docs/SECURITY.md.

That is the arrangement worth knowing about: the gaps are published next to the checks, and this site links to them instead of summarising them into something softer.

On this page