ruvnet/ruflo · error · Error
Path contains null bytes
Error message
Path contains null bytes
What it means
Thrown by RvfaReader.fromFile before opening the file. Null bytes can truncate or manipulate a resolved path on systems with C-style string handling, so the library rejects them up front rather than handing an unsafe path to readFile. It is an input-sanitization guard, not a file-not-found check.
Source
Thrown at v3/@claude-flow/cli/src/appliance/rvfa-format.ts:387
const sorted = [...header.sections].sort((a, b) => a.offset - b.offset);
for (let i = 1; i < sorted.length; i++) {
const prev = sorted[i - 1];
const curr = sorted[i];
if (prev.offset + prev.size > curr.offset) {
throw new Error(
`Sections "${prev.id}" and "${curr.id}" overlap ` +
`(${prev.offset}+${prev.size} > ${curr.offset})`,
);
}
}
return new RvfaReader(buf, header);
}
/** Read an RVFA image from a file path. */
static async fromFile(path: string): Promise<RvfaReader> {
if (path.includes('\0')) {
throw new Error('Path contains null bytes');
}
const data = await readFile(path);
return RvfaReader.fromBuffer(data);
}
/** Return the parsed header. */
getHeader(): RvfaHeader {
return this.header;
}
/** List all sections declared in the header. */
getSections(): RvfaSection[] {
return this.header.sections;
}
/**
* Extract and decompress a section by its id.
*View on GitHub (pinned to 6b01dc5a68)
Solutions
- Sanitize the path at the trust boundary: reject or strip '\0' before calling fromFile.
- Validate argv/env-supplied paths during CLI argument parsing, not inside the reader caller.
- If a NUL was unintentional, regenerate the path string from a clean source.
Example fix
// before
const reader = await RvfaReader.fromFile(argv[2]);
// after
const p = argv[2];
if (typeof p !== 'string' || p.includes('\0')) {
throw new Error('Invalid path: contains null byte');
}
const reader = await RvfaReader.fromFile(p); Defensive patterns
Strategy: validation
Validate before calling
function isSafeFilePath(p: unknown): boolean {
return typeof p === 'string' && p.length > 0 && !p.includes('\0');
}
if (!isSafeFilePath(path)) {
throw new Error('Refusing path with null byte');
} Type guard
function isSafeFilePath(p: unknown): p is string {
return typeof p === 'string' && p.length > 0 && !p.includes('\0');
} Prevention
- Treat every external path as untrusted and sanitize at the boundary.
- Never assemble paths by concatenating raw buffers that may contain 0x00.
- Keep path validation in argv parsing, not deep inside file readers.
When it happens
Trigger: Calling RvfaReader.fromFile(path) where path contains a literal NUL ('\0') character. Typical sources: an argv path that was copy-pasted from untrusted text, a path assembled by Buffer concatenation that included a 0x00 byte, or a path field read from an untrusted manifest.
Common situations: CLI invoked with a malformed argument; a test fixture built from raw buffers; an upstream tool that emits C-style null-terminated strings without trimming the terminator.
Related errors
- Validation failed: ${result.error}
- Header JSON exceeds maximum size (${headerLen} > ${MAX_HEADE
- SSRF guard: invalid URL — ${rawUrl}
- SSRF guard: only HTTPS URLs are permitted, got ${parsed.prot
- SSRF guard: private/loopback host rejected — ${host}
AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12).
Data as JSON: /api/errors/9486e3f27b89d0cb.
Report an issue: GitHub.