The vulnerability consists of two main issues: a hardcoded JWT secret key and a widespread lack of authentication on API endpoints. The provided patch, commit a82f9278d2d587b7042a0858aab79fd8b6e3add9, addresses the second issue by adding authentication and permission checks to over 200 API endpoints.
The root cause of the missing authentication vulnerability was that numerous FastAPI route handlers were defined without any dependency to enforce authentication. For example, the create_api_key function in backend/app/api/routes/api_keys.py allowed unauthenticated users to create new API keys. An attacker could exploit this by sending a simple POST request to the /api/v1/api-keys/ endpoint, as demonstrated in the vulnerability report.
The fix involves adding a new dependency, RequirePermissionIfAuthEnabled, to each vulnerable endpoint. This function, when used as a FastAPI dependency, ensures that if authentication is enabled in the application's configuration, the request must have a valid JWT, and the user associated with the token must have the required permissions to access the endpoint.
The functions listed as vulnerable are representative examples of the many endpoints that were missing this check. During exploitation, these are the function names that would appear in a runtime profile or stack trace when an unauthenticated request is made to the corresponding API endpoint.
It is important to note that the provided patch does not address the hardcoded JWT secret key issue. This would need to be fixed separately by removing the hardcoded key and loading it from a secure configuration source.