Chapter 16

Security model

16.1 Layers#

Layer Protection
Rendering Values drawn on canvas only; the hidden proxy is reset after every event; untrusted events ignored; autofill, autocorrect, spellcheck and password-manager heuristics disabled on the proxy.
Memory Content stored in SecureBuffer (Uint32Array, zeroed on growth, wipe(), submit, reset, idle, destroy).
Secrets Secret handle: toString/toJSON/inspect print [Secret]; plaintext only via use() or toUtf8(); equals() is constant time.
Passwords No copy/cut, no undo history, auto re-obscure, Caps Lock warning, NFKC.
Input Formatters → sanitiser → allow-list → length cap, on every insertion.
Page Strict CSP without unsafe-eval or inline scripts; no framing; PrivacyScreen.
Form Bot heuristics, client rate limit, double-submit lock, idle wipe.
Transport secureSubmit: same-origin only (or an explicit HTTPS allow-list), CSRF header, redirect: 'error', no-store, no-referrer, timeout. PFE1 encryption of secrets.
Server Host/Origin/Fetch-Metadata checks, HttpOnly + SameSite=Strict session, HMAC CSRF token, JSON-only 16 KB bodies, strict schema, rate limits, peppered scrypt, no secrets in logs or responses.

16.2 Handling Secret values#

const s = values.password as Secret;
s.length; s.isEmpty;                                // safe metadata
s.equals(other);                                    // constant time, no strings
s.count((cp) => cp >= 48 && cp <= 57);              // inspect code points, no strings
await sealSecret(s, key, 'password');               // preferred way to send it
s.use((plain) => legacyApi(plain));                 // last resort: creates an immutable string copy

Never store the argument of use(), never log it, and never put a Secret into application state.

16.3 Honest limits#