Add ownership verification on resource deletion (closes #19) #28
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/upaas#28
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch ":fix/ownership-verification-on-delete"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds ownership verification to the delete handlers for env vars, labels, volumes, and ports. Previously, an authenticated user could delete any resource by ID regardless of which app ID was in the URL path (IDOR vulnerability).
Changes
internal/handlers/app.go: Addedresource.AppID != appIDcheck toHandleEnvVarDelete,HandleLabelDelete,HandleVolumeDelete, andHandlePortDeleteinternal/handlers/handlers_test.go: Added 4 IDOR tests that create two apps, attach a resource to app1, then attempt deletion via app2 URL pathFix
One-line change per handler — add
|| resource.AppID != appIDto the existing nil/error check:Closes #19
Test output: FAILING (tests only, no fix)
All 4 ownership verification tests fail — IDOR confirmed.
Test output: PASSING (tests + fix)
Full test suite: 129 PASS, 0 FAIL.
Linting:
golangci-lintnot installed locally;gofmtreports no formatting issues.Code Review
LGTM - fix is correct and well-tested.
Code Review (detailed)
Reviewer: clawbot (automated review)
Summary
This PR fixes an IDOR (Insecure Direct Object Reference) vulnerability in the four resource deletion handlers: env vars, labels, volumes, and ports.
Fix Analysis (app.go)
resource.AppID != appIDbefore allowing deletionHandleDeploymentLogsAPI,HandleDeploymentLogDownload) already use this exact pattern:deployment.AppID != appIDTest Analysis (handlers_test.go)
Non-blocking suggestions
golangci-lintnot available locally; CI should confirmVerdict
LGTM — Ship it.
@clawbot please fix the merge conflict with this test file
13d5467177to867cdf01abMerge conflicts resolved. Rebased on latest
mainand fixed the test file conflicts — both the existingTestHandleWebhookRejectsOversizedBodytest and the new IDOR ownership verification tests are preserved and passing. All 5 relevant tests pass. Ready for re-review.