AILANG Security Model
AILANG enforces explicit authority at the language and runtime boundary: side effects must appear in function types (! {IO, FS, ...}), and capabilities must be granted when running a program. However, AILANG is not an OS sandbox — capabilities like FS, Process, and Env grant broad host access unless narrowed by AILANG_FS_SANDBOX, --policy (Experimental), or OS-level isolation (containers, VMs, seccomp).
Capabilities (--caps)
Every value accepted by ailang run --caps corresponds to a runtime capability. Capabilities marked Stable belong to Stable stdlib modules; Experimental capabilities belong to Experimental modules and may evolve in 1.x minors (see Stability Promise).
| Capability | Tier | What it grants at runtime |
|---|---|---|
IO | Stable | Console stdout/stderr/stdin (print, println, readLine, readLineOpt, exit) and std/terminal TTY control |
FS | Stable | Read, write, mkdir, rename, walk, and delete across every host path the OS user can reach, unless narrowed by AILANG_FS_SANDBOX or --policy (fs_sandbox / fs_deny_write) |
Env | Stable | Read every environment variable in the process snapshot (including credentials stored in env vars) and CLI arguments (getArgs), unless restricted via --allow-env / --env-snapshot |
Clock | Stable | Monotonic/wall-clock timestamps (now) and sleep (supports deterministic virtual time with --virtual-time) |
Rand | Stable | Random number generation (randInt, randFloat, randBool, randSeed; accepted by --caps and auto-grant, though omitted from run --help's short --caps summary) |
Net | Experimental | Outbound HTTP/HTTPS via std/net and std/web. Enforces HTTPS-only and blocks localhost, private IPs, and cloud metadata (169.254.169.254) by default unless widened with --net-allow-http, --net-allow-localhost, --net-allow-metadata, or --net-allow-domains; 30s timeout and 5 MB body cap by default |
Process | Experimental | Spawns host commands (std/process). Treat as full host access: Process is not confined by AILANG_FS_SANDBOX alone (use --process-allowlist or --policy restricted mode) |
AI | Experimental | Invokes configured LLM providers (std/ai), spending provider quota/credits (supports --ai-stub for offline testing) |
Stream | Experimental | Opens bidirectional WebSocket and SSE connections (std/stream; WSS-only and private-IP blocking by default, 1 MB message cap) |
Secret | Experimental | Resolves gated secrets (std/secret, e.g. op://...) into IFC-tainted values |
Trace | Experimental | Emits OpenTelemetry-compatible custom spans and events (std/trace) |
SharedMem | Experimental | Reads and writes shared key-value memory (std/sharedmem, std/sem) |
SharedIndex | Experimental | Queries and upserts similarity-search indexes (std/sharedindex) |
DOM | Experimental | Emits replayable DOM patches in browser/Cognitive-OS hosts (std/dom) |
Msg | Experimental | Sends and receives Lamport-clocked fabric messages (std/cognition) |
Cog | Experimental | Accesses Cognitive-OS event-log sinks (std/cognition) |
(Note: Debug is a compile-time ghost effect with no runtime capability flag; --release erases it. Declassify is a compile-time IFC authority checked in effect rows and package [effects].max ceilings.)
Granting Authority (--caps, --caps auto, and [bin] Shims)
- Explicit grant (
--caps IO,FS): Only listed capabilities are granted, and the list is authoritative: it may be narrower than the entrypoint's declared effects.runprints oneNote:line on stderr naming the declared-but-ungranted effects (suppressed by an explicit--quiet), then runs; the first call to an ungranted effect fails at runtime. A multi-mode CLI can grant each mode only what it needs. --caps autoand[bin]shims: Passing--caps autogrants every capability declared in the entrypoint's signature. Installed package[bin]shims (ailang pkg install) default tocaps = "auto"when[bin].capsis omitted inailang.toml.- Pre-flight for grants nobody chose at the command line:
--caps auto,[bin]shims,--policyruns, and a run with no--capsrefuse to start (E_CAPS_MISSING, before any user code runs) when the grant does not cover the entrypoint's declared effects. A--capsvalue that grants nothing once blank entries and the always-grantedDebugare dropped (--caps ,,--caps Debug) counts as no--caps. --package-dirruns are always pre-flighted: the runner recognises a shim by the--package-dirit passes, so anyailang run --package-dir ..., including one a person types, keeps the refusal: there, an explicit--capsmust still cover the entry's whole declared row.- Runtime hint: an ungranted effect fails at its first use with
effect 'FS' requires capability, but none providedandHint: Run with --caps FS,IO. The hint lists what the run was granted plus the missing effect, so following it does not drop an effect you already had. - Rule for untrusted code: Always inspect a module or package before running it with
--caps autoor installing its[bin]shims — useailang inspect <file>,ailang iface <module>, orailang pkg info <pkg>to review declared effects and[effects].maxceilings.
Confinement with --policy (Experimental)
For untrusted or agent-submitted programs, run with an operator-owned TOML policy file:
ailang run --policy /etc/ailang/agent-policy.toml untrusted.ail
- Supervised execution: The parent process resolves the policy, starts a child worker in its own process group, enforces
timeout_ms, byte/output caps (max_source_bytes,max_output_bytes,max_fs_transfer_bytes),allowed_caps,fs_sandbox,fs_deny_write(read-only protected globs such as.github/**,.git/**),net_allow, and[budgets]. - Fail-closed flag refusal: Widening CLI flags (
--caps,--entry,--env*,--net-*,--stream-*,--stdlib-path,--ai*,--fs-max-bytes, etc.) are refused by name when--policyis set. - Modes:
security_mode = "restricted"(default) permits only effects with confined adapters;trusted_hostis an explicit operator opt-in for host integrations with no confinement claim. - See the Agent Tool Policy guide for the full policy schema.
Package & Registry Confinement
When AILANG_AGENT_POLICY is set, all ailang pkg commands and the module loader refuse registry network fetches, git clone/fetch, and writes under ~/.ailang. Operators can provision a read-only AILANG_PACKAGE_ROOT (<vendor>/<name>/<version>). Registry and git dependencies are verified against ailang.lock's content_hash before compilation (content verification checks integrity against the lockfile, so protect the lockfile and package root from untrusted writes). See SECURITY.md.
Information-Flow Control (IFC) Labels (Experimental)
IFC labels (T<label>, sink refinements T{not LABEL}, and ! {Declassify}) track explicit data flow in the type system at zero runtime cost and cross module boundaries (#1134).
What IFC does NOT cover:
- Explicit flows only: Labels do not track implicit control-flow channels (branching on a secret value to choose an unlabelled constant).
- No runtime / storage persistence: Labels erase at compile time and do not survive
FS,Net, orIOround-trips. - Export annotation boundary: Within one module, sink constraints are inferred for unannotated helper parameters (
#1719); across module boundaries, an importer sees only what the exported signature explicitly annotates.
See the IFC Labels guide for examples and rules.
Contracts & Z3 Static Verification
Functions may carry requires { ... } and ensures { ... } clauses checked statically by Z3 (ailang verify / ailang check --verify) or dynamically on the evaluator (ailang run --verify-contracts).
- Bounded & model-scoped proofs: Recursive functions and
map/filter/foldllambdas are unrolled to bounded depth unless bounded byrequires;intis encoded as unbounded SMTInt(potential 64-bit runtime wraps surface asint_overflowcaveats, or violations under--int-model=int64), andfloatinputs are assumed non-NaN. - Precondition trust:
requiresis assumed when proving a function's ownensuresand checked at calls made by verified callers; unverified callers and ordinaryailang runwithout--verify-contractsdo not checkrequires. - Bytecode VM restriction:
--verify-contractsis evaluator-only and is refused alongside--bytecode/--strict-bytecode(CTR004, exit 2). - Exit codes:
0forverified,no_obligations, orpartial(unless--strict);1forunproved,inconclusive(unless--allow-inconclusive),counterexample,error, or missing Z3 (unavailable);2for usage errors. See Contracts & Verification.
Determinism Is Not Isolation
Program determinism — byte-identical outputs across the evaluator and bytecode VM for pure code and virtualized Clock/Rand — enables replay and auditability, not host isolation. A deterministic program granted FS, Net, Env, or Process still reads or modifies external host state unless confined by --policy, AILANG_FS_SANDBOX, or an OS sandbox.
Supply Chain & Provenance
- Release artifacts: GitHub Releases (
v0.14.1+) are keyless-signed with Sigstore cosign (.sig+.pemlogged in Rekor) and carry SLSA Build Level 3 provenance (multiple.intoto.jsonl,v0.15.x+) alongsideSHA256SUMS. See SECURITY.md for verification commands. - Dependencies:
ailang.lock(ailang.lock/v1) pins exact versions,content_hash,interface_hash, and declared effects, checked before compilation (ailang lock --check). Note that published registry packages are hash-verified viaailang.lock, not yet publisher-signed.
Reporting Vulnerabilities
Please do not open public GitHub issues for security vulnerabilities. Report privately via GitHub Security Advisories:
See SECURITY.md for response SLAs and scope.