Full-codebase-audit 2026-05-30 outputs: - Audit report: 09 - Audits/Full Codebase Audit - 2026-05-30.md - 81 issue files ISSUE-055..135 (decisions + 1 skipped no-brainer). - Scanner docs from scratch (was zero): architecture, data model, API ref, payment flow, operations runbook + repo README. - Doc-sync updates across API reference, data models, flows, design system. - Secret Rotation Runbook (08 - Operations) for the exposed credentials. - Reusable workflow guide (07 - Development) + .claude/workflows/full-codebase-audit.js. Issues remain status:open intentionally — the code fixes are uncommitted-then-committed working-tree changes per repo and aren't "resolved" until merged/deployed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1.8 KiB
1.8 KiB
issue, title, severity, domain, labels, status, created, source
| issue | title | severity | domain | labels | status | created | source | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 055 | DELETE /api/files/delete has no ownership check — requires new persistence layer (NB-27 skipped) | high | File Management |
|
open | 2026-05-30 | Full Codebase Audit 2026-05-30 |
DELETE /api/files/delete has no ownership check — requires new persistence layer (NB-27 skipped)
Severity: high Domain: File Management Labels: security, backend, idor, skipped-nobrainer
Description
fileService.deleteFile() is a pure filesystem path operation — there is no File model and no createdBy/owner field stored anywhere in the database. Any authenticated user who knows (or guesses) another user's filename can delete that file via DELETE /api/files/delete?filename=....
This was triaged as NB-27 but skipped because adding an ownership check requires first creating a new File persistence layer (model + write-on-upload path), which is a larger-than-mechanical change that risks introducing new bugs.
What is Needed
- Create a
Filemodel (or add anuploadssub-document to the User model) that records{ filename, uploadedBy: ObjectId, createdAt }when a file is stored. - Add a middleware or controller check in
fileController.deleteFilethat looks up the record and requiresreq.user.id === file.uploadedBy(or admin). - Back-fill the upload handler to write the record on every
POST /api/files/upload.
Affected Files
backend/src/services/file/fileController.ts— add ownership checkbackend/src/services/file/fileRoutes.ts— (route already protected byauthenticateToken)- New:
backend/src/models/File.ts(or equivalent) — persistence layer