Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix path traversal issue in createTemporaryNodeServer
The test-only createTemporaryNodeServer helper featured a path traversal vulnerability. This enables attackers with network access to the device to read arbitrary files while unit tests are running that activate this test server. This patch fixes the issue by validation of paths. To test this vulnerability before the patch: 1. Run the test-only server: ``` node -e 'console.log(require("./test/unit/test_utils.js").createTemporaryNodeServer().port) ``` 2. From another terminal, send the following request (modify the port to the port reported in the previous step): ``` curl --path-as-is http://localhost:45755/../../package.json ``` Before the patch, the second step would traverse the directory, and return results from the root of the PDF.js repository, instead of files within test/pdfs/. With the patch, the server refuses the request with HTTP status 400.
- Loading branch information