SECURITY: Unauthenticated File Download Endpoint Exposes All Uploaded Files
A critical security vulnerability allows any unauthenticated user to download all files uploaded to the system. The file download endpoint `/api/files/` lacks the mandatory authentication middleware, creating a direct path for anonymous data access. This authentication bypass stands in stark contrast to all other file operations—upload, list, and delete—which are correctly protected, exposing a severe and isolated flaw in the application's security perimeter.
The vulnerability is rooted in the route registration within `cmd/server/main.go`. On line 415, the endpoint is registered without the `middleware.RequireAuth` wrapper. The `GetFile` handler function in `internal/handlers/file.go` contains no internal authentication checks, leaving it completely open. This oversight creates a scenario where an attacker who knows or can guess a file's path can retrieve any uploaded document without credentials, bypassing the intended access controls entirely.
This flaw represents a high-severity data exposure risk. The system's security model is fundamentally broken for file retrieval, potentially exposing sensitive user-uploaded content. The inconsistency in middleware application suggests a critical gap in the security review process for route definitions. Immediate remediation is required to apply the `RequireAuth` middleware to the download endpoint, aligning it with the rest of the file management API.