Security scope
SAFE-TS eliminates entire classes of injection, prototype-pollution, ReDoS, and unhandled-failure bugs statically—while staying transparent about what static analysis cannot replace. It is a safety checker, not a runtime sandbox.
In short
- Strong coverage: boundary validation (
parseJson<T>), prototype-safe maps, sink proof types (Html,SafeUrl,SafePath,RegexSource, SQL/command/code/custom brand sinks), ReDoS detection, and cryptographic randomness. - Explicitly out of scope: process isolation / Spectre defenses, auditing dependency behavior beyond throws, authorization/business-logic review, and dynamic taint tracking (headers, logs, SSRF).
What it helps with
- Input that doesn't match its type:
parseJson<T>validates data at the boundary and builds fresh objects with only the declared fields, so a"__proto__"key in the input never reaches your objects. AJsonValuefield and aRecord<string, V>keep every key, but as own keys: a"__proto__"key there is data and doesn't change the prototype. - Prototype keys used as data:
no-object-dictionaryandno-for-insteer data-keyed lookups toMap, which has no inherited"constructor"or"__proto__", and no hash table an attacker can flood with colliding keys (v8.dev). - Text that reaches a sink: markup written into the page, a URL the browser follows, code run from text, a shell command, a file path, a pattern, an SQL statement. Each sink takes only a constant the source shows or a value of its brand, which only a constructor that checked it makes:
markup-sink(Html),url-sink(SafeUrl),code-sink,command-sink,path-sink(SafePath, in code a request or a message reaches),pattern-sink(RegexSource),sql-sink, and your own brands' sinks (brand-sink). Which members are sinks is data in the API maps, shown on the engines (Libraries: Sinks). - Regexes an attacker can stall:
no-redosreports patterns that backtrack exponentially, andpattern-sinka pattern made from text. V8's default engine has no time limit (v8.dev). - Guessable secrets:
no-math-random-for-secrets;Math.random()is predictable (v8.dev). - Failures nobody handles: every rule about errors, so a failure becomes a value you have to look at instead of a crash or a silently wrong state.
What it doesn't do
- Isolate code. Code in the same process can read the same memory; Spectre-style attacks make that true even across what looks like a boundary. Untrusted code belongs in a separate origin, worker process or isolate (v8.dev, v8.dev).
- Check dependencies. Library code is only analysed for what it throws or rejects (Libraries), not for what else it does.
- Replace review of authentication, authorization, escaping, or anything else that depends on what your program means.
- Follow where a value came from. A sink takes its brand whatever the value's origin: the sink rules don't track taint. They have nothing on HTTP header or log injection (a newline in a header value or a log line), prototype pollution through merges of parsed objects (std's
parseJsonbuilds fresh objects; a deep merge of your own doesn't), or which hosts a request may reach (SSRF).
Bounds checks, .at() and Option are about correct logic, not a defense against memory attacks: JavaScript was memory-safe to begin with.