T09 · Insecure Skill Coding Practices
- Location
src/file-sync.ts:288- Finding
Arbitrary File Write Through Relay Manifest Path Traversal
- Content
View full analysis
(parsed as EncryptedPayload, relayKey); if (manifest.version && manifest.entries) { coreManifest = manifest; } ``` ```ts const delta = compareManifest(coreManifest); // Build a lookup of available file blobs by path const fileBlobMap = new Map(fileBlobs.map(f => [f.path, f])); // Apply upserts let imported = 0; for (const entry of delta.upsert) { const fileBlob = fileBlobMap.get(entry.path); if (!fileBlob) { continue; } try { const content = decrypt(fileBlob.data, relayKey); const actualHash = createHash('sha256').update(content).digest('hex'); if (actualHash !== entry.sha256) { process.stderr.write(`[file-sync] hash mismatch for ${entry.path}, skipping\n`); continue; } const destPath = join(paths.root, entry.path); mkdirSync(dirname(destPath), { recursive: true }); writeFileSync(destPath, content); imported++; } catch (err: any) { process.stderr.write(`[file-sync] failed to write ${entry.path}: ${err.message}\n`); } } ``` ### Technical Analysis The Node accepts paths from an encrypted relay manifest and uses them directly in: ```ts join(paths.root, entry.path) ``` The code does not reject: - Absolute paths - `..` parent-directory components - Paths that normalize outside `paths.root` - Destination paths traversing symbolic links - NUL bytes or other invalid path data Encryption and SHA-256 validation establish that the content came from a party possessing the relay key and that it was not modified in transit. They do not establish that the destination path is safe. For example, a manifest path such as `../../.zshrc` can normalize outside `~/.ldm`. A compromised paired Core, stolen relay encryption key, or malicious authorized peer could therefore cau ...[truncated 1421 chars]- Remediation
View remediation
