Summary
@asymmetric-effort/nogginlessdom's Path Traversal in matchFileSnapshot allows arbitrary file write
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
export function matchFileSnapshot(actual: unknown, filePath: string): void {
const serialized = serialize(actual);
const mode = resolveUpdateMode();
const fileExists = fs.existsSync(filePath);
if (!fileExists) {
if (mode === 'all' || mode === 'new') {
const dir = path.dirname(filePath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
fs.writeFileSync(filePath, serialized, 'utf-8');
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
import { expect, setUpdateMode } from '@asymmetric-effort/nogginlessdom';
setUpdateMode('all');
// Writes arbitrary content to any writable path
expect('malicious content').toMatchFileSnapshot('/tmp/exploit/payload.txt');
// Path traversal via relative components
expect('data').toMatchFileSnapshot('../../../tmp/evil.txt');
// In CI environments, could overwrite CI config
expect('injected step').toMatchFileSnapshot('/home/runner/.github/workflows/backdoor.yml');
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.
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
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.
export function matchFileSnapshot(
actual: unknown,
filePath: string,
projectRoot?: string,
): void {
const root = projectRoot ?? process.cwd();
const resolved = path.resolve(root, filePath);
if (!resolved.startsWith(root + path.sep) && resolved !== root) {
throw new Error(
`File snapshot path must be within the project directory: ${filePath}`,
);
}
// ... all subsequent file I/O uses `resolved` instead of `filePath`
}
Frequently Asked Questions
- What is GHSA-322X-V876-G883? GHSA-322X-V876-G883 is a high-severity path traversal vulnerability in @asymmetric-effort/nogginlessdom (npm), affecting versions <= 0.0.21. It is fixed in 0.0.22. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- Which versions of @asymmetric-effort/nogginlessdom are affected by GHSA-322X-V876-G883? @asymmetric-effort/nogginlessdom (npm) versions <= 0.0.21 is affected.
- Is there a fix for GHSA-322X-V876-G883? Yes. GHSA-322X-V876-G883 is fixed in 0.0.22. Upgrade to this version or later.
- Is GHSA-322X-V876-G883 exploitable, and should I be worried? Whether GHSA-322X-V876-G883 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-322X-V876-G883 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-322X-V876-G883? Upgrade
@asymmetric-effort/nogginlessdomto 0.0.22 or later.