ruvnet/ruflo · error

Cache path contains null bytes

Error message

Cache path contains null bytes

What it means

Path-validation guard in the RVF embedding cache: the configured cachePath contains null (0x00) bytes, which cannot be a valid filesystem path and can be used to smuggle truncation attacks past path checks. Rejected before any fs call touches the path; the constructor invokes this validator when wiring the persistent cache.

Source

Thrown at v3/@claude-flow/embeddings/src/rvf-embedding-cache.ts:25

 * Features:
 * - Map-based in-memory cache with periodic flush to binary file
 * - LRU eviction tracked via access timestamps
 * - TTL support for cache entries
 * - Deterministic FNV-1a text hashing for keys
 * - Binary format: RVEC magic + entry records
 *
 * Binary entry format:
 *   [4-byte key-hash][4-byte dims][dims*4 bytes float32][8-byte timestamp][8-byte access-count]
 *
 * @module @claude-flow/embeddings
 */

import { existsSync, mkdirSync, readFileSync, writeFileSync, renameSync } from 'fs';
import { dirname } from 'path';

/** Validate a file path is safe */
function validatePath(p: string): void {
  if (p.includes('\0')) throw new Error('Cache path contains null bytes');
}

// ============================================================================
// Configuration
// ============================================================================

/**
 * Configuration for RVF embedding cache
 */
export interface RvfEmbeddingCacheConfig {
  /** Path to the binary cache file */
  cachePath: string;
  /** Maximum number of entries (default: 10000) */
  maxSize?: number;
  /** TTL in milliseconds (default: 7 days) */
  ttlMs?: number;
  /** Embedding dimensions (used for validation) */
  dimensions?: number;

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Remove null bytes from the cache path; build paths from validated config values.
  2. Reject or sanitize the path before constructing the cache.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/@claude-flow/embeddings/src/rvf-embedding-cache.ts:25 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/3045999f01010cbd. Report an issue: GitHub.