/

CVE-2026-133309

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-94) in @scalar/typebox TypeCompiler

CVE-2026-133309

Received

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary JavaScript execution in the host Node.js process

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

@scalar/typebox has a code injection vulnerability in TypeCompiler: crafted schema strings can cause attacker-controlled JavaScript to run during compilation or checking. The risk arises when untrusted schema values reach these operations and are incorporated into generated or evaluated code without adequate safeguards.

Affected context

The issue affects applications using @scalar/typebox where schema strings are supplied by an untrusted or modifiable source and passed to TypeCompiler's Compile() or Check() operations. Risk depends on whether an attacker can control values such as string formats, Kind names, property keys, or Literal values that the compiler processes.

Exploit preconditions

  • Attack surface: Application code that processes schemas with TypeCompiler
  • Required access: Ability to provide or influence schema strings
  • Trigger point: Affected Compile() or Check() processing of the crafted schema
  • Why exploitation is possible: Certain schema values can break out of string contexts and be interpreted as JavaScript by the host process

Why this happens

The underlying issue is unsafe handling of schema-derived strings when TypeCompiler processes or generates code. If values such as format names, Kind names, property keys, or Literal values are embedded in executable JavaScript without context-appropriate encoding or safe construction, crafted input may escape its intended string context and inject code. This is a code injection flaw mapped to CWE-94: Improper Control of Generation of Code.

Potential impact

  • Arbitrary JavaScript may execute in the host Node.js process
  • Application data or secrets accessible to that process could be exposed
  • The running application or its dependent services could be disrupted or altered
  • An attacker may gain additional capabilities consistent with the process's permissions

General mitigation guidance

Mitigation generally focuses on preventing untrusted schema data from becoming executable code.

Common defensive patterns include:

  • Prefer safe compiler designs that avoid generating or evaluating code from schema strings
  • Use structured APIs and context-appropriate escaping or encoding for values used in generated code
  • Validate schema inputs against a strict, documented schema before compilation
  • Reduce trust in externally supplied schemas and restrict who can create or modify them
  • Run Node.js workloads with least privilege and limit access to sensitive resources

How teams detect issues like this

High-level detection approaches include:

  • Static analysis for schema-derived strings interpolated into generated code or evaluation contexts
  • Code review for unsafe string construction involving formats, Kind names, property keys, or Literal values
  • Tests using unusual schema strings to verify that compilation and checking treat them strictly as data
  • Policy checks that restrict dynamic code generation and flag untrusted schemas reaching compiler operations

Automated code review tools may help identify risky data flows and code-generation patterns.

Sources

SourceLink
github.comgithub.com/scalar/typebox
github.comgithub.com/scalar/typebox/blob/v0.1.3/src/compiler/compiler.ts#L427
github.comgithub.com/scalar/typebox/commit/21d55f035a83868a3577be2142b9c9bbc125969b
github.comgithub.com/scalar/typebox/pull/5
github.comgithub.com/sinclairzx81/sinclair-typebox/security/advisories/GHSA-976x-prgx-qv35
npmjs.comnpmjs.com/package/@scalar/typebox
vulncheck.comvulncheck.com/advisories/scalar-typebox-before-0.1.4-code-injection-via-typecompiler-schema-strings

Frequently asked

questions

The issue can affect applications that pass attacker-influenced schema strings to the affected TypeCompiler operations. Exposure depends on how schemas enter the application and where compilation or checking occurs.

An attacker needs a way to supply or influence relevant schema values. The vulnerability description does not imply that every deployment exposes such a path.

Avoid turning schema-derived strings into executable code. Prefer safe, structured processing and validate inputs before they reach compiler operations.

Treat externally supplied schemas as untrusted, review string interpolation and code-generation paths, and enforce policies that limit dynamic code execution.

Find out what's already
exploitable in your codebase.