fix(security): prevent path traversal in delete endpoint - #161
fix(security): prevent path traversal in delete endpoint#161prathamesh04 wants to merge 2 commits into
Conversation
Fixes infinite loop in assignColorToWorker when all 16 ANSI colors are allocated. Previously, the do...while loop would spin forever looking for an unassigned color, blocking the Node.js event loop and hanging the server at 17+ concurrent deployments. Changes: - Replace random retry with deterministic round-robin index - Remove assignedColorCodes tracking map (no longer needed) - Remove unused AssignedColorCodesType interface - Remove stale TODO comments Colors cycle safely when more than 16 deployments are active. Fixes metacall#116
The delete endpoint was passing unsanitized user input to recursive rm without path boundary check. A malicious suffix like '../../../etc' could escape the appsDirectory and delete arbitrary files. Changes: - Add safeResolve utility for path traversal protection - Add isValidDeploymentName validator (alphanumeric, dots, hyphens, underscores) - Validate suffix before using in delete endpoint - Apply safeResolve in repositoryDelete for defense-in-depth - Return 400 error for invalid deployment names Fixes metacall#121
Testing Complete ✅I've tested PR #161 and verified the security fix works: Tests Performed1. isValidDeploymentName validation:
2. safeResolve path protection:
3. TypeScript compilation:
Testing video: SummaryThe fix properly prevents path traversal attacks by:
|
|
You have merged multiple things in the same post. This is not the way of working man. You should not spam the repository with random PRs. The way of working is with TDD. You first find an issue, you create a test that reproduces it. Then you create a new PR only with this, we run the CI we validate it fails and the bug is reproduced. Then you make a new commit and you verify all tests pass, then I merge it. We run the CI on each step so we verify tests fail first, and then tests pass. If you keep spamming like this, pushing random PRs, probably vibe coded. I will close all of them. For now I left all as draft. |
Description
The delete endpoint was passing unsanitized user input to recursive
rmwithout path boundary check. A malicious suffix like../../../etccould escape theappsDirectoryand delete arbitrary files.Fixes #121
Changes
safeResolveutility for path traversal protectionisValidDeploymentNamevalidator (alphanumeric, dots, hyphens, underscores)safeResolveinrepositoryDeletefor defense-in-depthSecurity Impact
This is a critical security fix that prevents:
Checklist
npm run build)npm run lint)