Описание
@asymmetric-effort/nogginlessdom's Path Traversal in matchFileSnapshot allows arbitrary file write
Summary
The matchFileSnapshot function in src/assertions/snapshots.ts accepted a filePath parameter with zero validation. When snapshot update mode was active (UPDATE_SNAPSHOTS=1 or setUpdateMode('all')), an attacker who controls test input could write arbitrary content to any filesystem path the process has write access to, including creating intermediate directories.
Affected Code
File: src/assertions/snapshots.ts, lines 732-769
The filePath flows from expect(value).toMatchFileSnapshot(filePath) at index.ts:1033-1035 with no sanitization, no check that the path is within an expected directory, and no symlink resolution.
Proof of Concept
Impact
In CI/CD environments where test files may come from untrusted pull requests, this allows writing to any writable filesystem location with directory creation. An attacker could overwrite configuration files, inject code into build artifacts, or modify CI pipeline definitions.
Fix
Fixed in commit https://github.com/asymmetric-effort/NogginLessDom/commit/785e6ac6e124d1a89b3ccf40bbd75fc8e4cb215d on main. The matchFileSnapshot function now validates that the resolved file path is within the project root directory (defaults to process.cwd(), configurable via optional projectRoot parameter). Paths that resolve outside the project directory are rejected with a descriptive error.
Пакеты
@asymmetric-effort/nogginlessdom
<= 0.0.21
0.0.22
8.7 High
CVSS4
Дефекты
8.7 High
CVSS4