The analysis of the security patch (commit 22c2192f5d9beef8a787c45eff3a14c24dbb5f96) clearly indicates the source of the vulnerability. The patch was applied to the file server/api/projects/index.js, specifically to the Express.js-style route handler for POST /api/upload.
The root cause is twofold:
- Missing Authentication: The endpoint was public, as shown by the removal of the simple callback
function (req, res) and the addition of the secureFnc middleware and subsequent authorization checks. This allowed unauthenticated attackers to reach the vulnerable code path.
- Path Traversal: The original code constructed the destination directory for file uploads using
path.resolve(runtime.settings.appDir, _${destination}). The destinationvariable was taken directly from the request body without validation. This allowed an attacker to craft a maliciousdestinationstring with../` sequences to traverse the directory structure and write a file to any location the application's user had permissions for.
The patch addresses both issues by first enforcing authentication and authorization, and then by adding robust validation to the destination parameter. It normalizes the path, explicitly checks for traversal sequences (..), and ensures the final resolved path is within the intended base directory. The vulnerable function is the anonymous callback function that handles this API endpoint, which is best identified in a profiler by its route prjApp.post('/api/upload').