ruvnet/ruflo · error · Error
Header JSON exceeds maximum size (${headerLen} > ${MAX_HEADE
Error message
Header JSON exceeds maximum size (${headerLen} > ${MAX_HEADER_JSON_SIZE}) What it means
Thrown by RvfaReader.fromBuffer() when the declared header JSON length (u32LE at offset 8) exceeds MAX_HEADER_JSON_SIZE (1 MiB). This is a sanity cap that rejects absurd or hostile header-length fields before attempting a multi-megabyte allocation and JSON.parse. The magic and version checks already passed.
Source
Thrown at v3/@claude-flow/cli/src/appliance/rvfa-format.ts:332
// Magic
const magic = buf.subarray(0, MAGIC_SIZE).toString('ascii');
if (magic !== 'RVFA') {
throw new Error(`Invalid RVFA magic: expected "RVFA", got "${magic}"`);
}
// Version
const version = buf.readUInt32LE(MAGIC_SIZE);
if (version !== RVFA_VERSION) {
throw new Error(
`Unsupported RVFA version: ${version} (expected ${RVFA_VERSION})`,
);
}
// Header length
const headerLen = buf.readUInt32LE(MAGIC_SIZE + VERSION_SIZE);
if (headerLen > MAX_HEADER_JSON_SIZE) {
throw new Error(
`Header JSON exceeds maximum size (${headerLen} > ${MAX_HEADER_JSON_SIZE})`,
);
}
if (PREAMBLE_SIZE + headerLen > buf.length) {
throw new Error('Buffer too small to contain declared header');
}
// Parse header JSON
const headerSlice = buf.subarray(PREAMBLE_SIZE, PREAMBLE_SIZE + headerLen);
let parsed: unknown;
try {
parsed = JSON.parse(headerSlice.toString('utf-8'));
} catch {
throw new Error('Failed to parse RVFA header JSON');
}
if (!validateHeader(parsed)) {
throw new Error('RVFA header failed validation');View on GitHub (pinned to 6b01dc5a68)
Solutions
- Discard the appliance file — a header length above 1 MiB is never legitimate for the current format.
- Regenerate the appliance from source via RvfaBuilder.build().
- If accepting untrusted appliances, keep this check as a resource-exhaustion guard.
- Verify the file was not truncated or concatenated with another binary.
Defensive patterns
Strategy: validation
Validate before calling
const MAX_HEADER = 1024 * 1024;
function headerLenWithinMax(buf: Buffer): boolean {
if (buf.length < 12) return false;
const hLen = buf.readUInt32LE(8);
return hLen <= MAX_HEADER;
} Try / catch
try {
const reader = RvfaReader.fromBuffer(buf);
} catch (e) {
if (/Header JSON exceeds maximum size/.test((e as Error).message)) {
throw new Error('Header length field is implausibly large; the appliance is corrupt or hostile');
}
throw e;
} Prevention
- Treat any header length above 1 MiB as corruption; never allocate for it.
- When accepting untrusted appliances, keep this cap as a DoS guard.
- Regenerate appliances from source if the field is corrupt.
- Do not concatenate appliances with other binaries.
When it happens
Trigger: A corrupted 4-byte header-length field that decodes to a huge value (e.g. due to byte rotation), or a deliberately crafted malicious appliance designed to cause memory exhaustion. Random corruption of the length field commonly produces values far above 1 MiB.
Common situations: Bit-rot or partial overwrite of the header-length bytes; a fuzzer or adversarial input; a file produced by a buggy writer that mis-encoded the length.
Related errors
- RVFA header failed validation
- Validation failed: ${result.error}
- Buffer too small to contain RVFA preamble
- Invalid RVFA magic: expected "RVFA", got "${magic}"
- Failed to parse RVFA header JSON
AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12).
Data as JSON: /api/errors/8dd85ebb5e942853.
Report an issue: GitHub.