08/security-model

Security Model & Limits

What Layer 1 and Layer 2 (--aggressive) buy you, what they do not, and how synchronous attestation behaves.

Threat model

unpeek raises the cost of reading a client bundle. String literals move into 92-char zero-escape or 64-bit call-site salted vaults, local bindings take compact `minLength: 1` polymorphic names, and cold functions receive `>=4`-var Rivest MBA QNR predicates or 43-opcode Micro-VM v2 bytecode compilation under `--aggressive` / `--profile strict`.

It is not a cryptographic boundary. Any code the browser can execute can be executed by anyone who receives it. Treat the output as a deterrent against casual inspection and automated AST solvers, not as a secret store.

  • Do not ship API keys, signing salts, or private tokens in client code. The vault obfuscates and relocates them; it cannot stop a live runtime observer.
  • Keep authorization decisions on the server. A protected bundle is still not a trusted place for them.
  • Pin `--seed` in CI so repeated builds produce identical output and diffs stay reviewable.

Order-independent shield & defense tiers

The injected entry shield hashes its own source via `Function.prototype.toString()` with `Reflect.apply` descriptor checks and writes `globalThis[sym]` safely across browsers and `WorkerGlobalScope`, without poisoning async split chunks that execute early.

`--passive` dispatches `CustomEvent('unpeek:tamper')` without mutating `console`, while `deterrentMode: 'gradual'` fails closed and quiets console inspection. Add `--aggressive` or `--profile strict` when high-value `@unpeek-critical` enclaves justify Micro-VM v2 execution and singleton host-coupled WASM KDF.

Terminal: Tiers & shield modes
# Layer 1 default profile (deterministic seed)
unpeek protect --seed 0x7f4a2c

# Layer 2 aggressive profile (Micro-VM + inline WASM KDF + salted vault)
unpeek protect --aggressive --seed 0x7f4a2c

# Passive telemetry only / no runtime shield
unpeek protect --passive
unpeek protect --no-shield