Details
3. Conclusion
True Positive
Key evidence:
manifest.nameflows directly intofinalExtractDirand is used byfs.mkdirSyncandfs.renameSyncwithout sanitization (src/controllers/mcpbController.ts:106-116).manifest.nameis parsed frommanifest.jsoninside an uploaded archive, with only a non‑empty check (src/controllers/mcpbController.ts:89-97).- The
/mcpb/uploadendpoint exposes the upload handler that processes user‑supplied archives (src/routes/index.ts:297-299).
4. Remediation Recommendations
- Add normalization and base directory validation before using
manifest.nameto constructfinalExtractDir(e.g.,const resolved = path.resolve(baseDir,server-${safeName}); if (!resolved.startsWith(baseDir)) reject;). - Use
path.basename()to strip directory components frommanifest.nameand enforce a strict character allow‑list (alphanumeric,_,-,.) before use. - Consider rejecting any
manifest.namethat contains path separators or traversal sequences, and add unit tests for malicious traversal inputs.