GHSA-322x-v876-g883High▾ Twilight@asymmetric-effort/nogginlessdom's Path Traversal in matchFileSnapshot allows arbitrary file write
▾ Twilight zone — High severity, or a signal on a lesser flaw
impact 41.3 · likelihood 0 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
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.
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.
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');
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.
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`
}
@asymmetric-effort/nogginlessdom <= 0.0.21Upgrade to a patched release:
@asymmetric-effort/nogginlessdom 0.0.22Connected by shared product, vendor, weakness, or advisory.
GHSA-x4hg-hfwf-p9mwMedium@asymmetric-effort/nogginlessdom vulnerable to ReDoS via user-controlled regex in HTMLInputElement pattern validation
CVE-2023-7260High· 7.5Path Traversal vulnerability discovered in OpenText™ CX-E Voice, affecting all version through 22.4
CVE-2023-7249Critical· 9.8Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability in OpenText OpenText Directory Services allows Path Traversal.This issue affects OpenText Directory Services: from 16.4.2 before 24.1.
CVE-2020-3365Medium· 4.3A vulnerability in the directory permissions of Cisco Enterprise NFV Infrastructure Software (NFVIS) could allow an authenticated, remote attacker to perform a directory traversal attack on a limited set of restricted directories
CVE-2020-3236Medium· 6.7A vulnerability in the CLI of Cisco Enterprise NFV Infrastructure Software (NFVIS) could allow an authenticated, local attacker to gain root shell access to the underlying operating system and overwrite or read arbitrary files
CVE-2010-2861Critical· 9.8Multiple directory traversal vulnerabilities in the administrator console in Adobe ColdFusion 9.0.1 and earlier allow remote attackers to read arbitrary files via the locale parameter to (1) CFIDE/administrator/settings/mappings.cfm, (2)…