highVulnerability

GHSA-322x-v876-g883

## 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 ```typescript 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 ```typescript 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. ## Fix Fixed in commit https://github.com/asymmetric-effort/NogginL

Properties

ghsa_id
GHSA-322x-v876-g883
summary
@asymmetric-effort/nogginlessdom's Path Traversal in matchFileSnapshot allows arbitrary file write
severity
high
cve_id
GHSA-322x-v876-g883
is_ghsa_only
true
ghsa_published
2026-07-02T20:19:20Z
source_url
https://github.com/advisories/GHSA-322x-v876-g883
ghsa_updated
2026-07-02T20:19:21Z

Related Entities (4)

REPORTED_BY (1)

[Source]GitHub Advisory Database

VULNERABLE_TO (1)

[Software]npm/@asymmetric-effort/nogginlessdom

AFFECTS (1)

[Software]npm/@asymmetric-effort/nogginlessdom

HAS_WEAKNESS (1)

[Weakness]Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Explore deeper with Ninja Signal's threat intelligence graph