/

CVE-2026-73231

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-95) in Faker fake Template Helper

CVE-2026-73231

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-95

Impact:

Arbitrary JavaScript Code Execution

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

A code injection vulnerability in Faker's faker.helpers.fake method allows attacker-controlled templates to reach JavaScript's Function constructor through property resolution behavior. When untrusted fake templates are processed in browser or Node.js contexts, an attacker may execute arbitrary JavaScript code with the privileges of the hosting application.

Affected context

The issue can occur in applications that use Faker's faker.helpers.fake helper to process templates influenced by untrusted users, external data, or modifiable configuration. Risk increases when template evaluation can resolve a function-returning property and the hosting process exposes sensitive browser or Node.js capabilities.

Exploit preconditions

  • Attack surface: Faker template processing in browser or Node.js applications
  • Required access: Ability to supply or influence a fake template
  • Trigger point: Invocation of faker.helpers.fake and its property-resolution logic
  • Why exploitation is possible: Attacker-controlled template expressions can reach the JavaScript Function constructor when a resolved function returns another function

Why this happens

The underlying bug is an unsafe evaluation path in the fake-template helper. Property resolution permits attacker-controlled template content to traverse into executable JavaScript behavior, including access to the Function constructor. This maps to CWE-95, Improper Neutralization of Directives in Dynamically Evaluated Code, because data intended to describe fake values can instead be interpreted as executable code.

Potential impact

  • Arbitrary JavaScript code may execute in the application context
  • Sensitive process environment data could be exposed
  • Browser-side credentials or accessible application data could be accessed
  • Application integrity could be compromised
  • The hosting process or user session could be used for further attacks

General mitigation guidance

Mitigation generally focuses on preventing untrusted template content from entering dynamic evaluation paths. Secure-by-default patterns include using fixed, non-evaluated generators; treating templates as data rather than executable expressions; restricting property resolution to an explicit allowlist of inert values; and separating trusted test-data generation from user-controlled input. Where dynamic behavior is unavoidable, applications can reduce input trust, isolate generation in a low-privilege process, limit browser and Node.js capabilities, and apply strict output and execution boundaries.

How teams detect issues like this

Detection can include static analysis for uses of faker.helpers.fake, dynamic template evaluation, Function construction, and unrestricted property-resolution helpers. Code review should examine whether templates originate from request data, files, environment variables, or other untrusted sources, and whether resolved values can become callable functions. Policy enforcement can prohibit dynamic code generation in production paths and require allowlisted template syntax. Automated code-review and dependency-analysis tools may help identify these patterns.

Sources

SourceLink
github.comgithub.com/faker-js/faker/commit/54586208f904012f57c50b46cc1ad32bcbe4bfb7
github.comgithub.com/faker-js/faker/pull/3852
github.comgithub.com/faker-js/faker/releases/tag/v10.5.0
github.comgithub.com/faker-js/faker/security/advisories/GHSA-qxc2-j82w-r537

Frequently asked

questions

It can be exploitable through a remote application interface when that

interface accepts attacker-controlled fake templates and passes them to the

vulnerable helper. A local or internal data source may also be sufficient if

it can modify templates.

The attacker needs a way to influence the template processed by

faker.helpers.fake. Authentication requirements depend on the application's

surrounding API and access controls.

Avoid evaluating untrusted templates. Prefer fixed generators or a narrowly

defined, allowlisted template language that cannot resolve executable

JavaScript objects.

Keep user-controlled data outside dynamic evaluation paths, review helpers that

resolve properties or invoke functions, enforce restrictions on dynamic code

generation, and run data-generation workloads with minimal privileges.

Find out what's already
exploitable in your codebase.