Fixed-constraints-added-param-passed #124
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#120 Issue: Path Traversal Vulnerability via Illegal URL Destination Parameter
Problem:
Normally, when passing the destination parameter, a file is downloaded. However, if characters like
../
are added and passed as a parameter after URL encoding, it enables access to files outside of the directory. For instance, the string../test/jest-e2e.json
, when URL encoded, can be passed as the destination parameter:localhost:3000/files/download/..%2Ftest%2Fjest-e2e.json
. This results in the file being served as a response, potentially exposing sensitive information.How to Recreate:
../
as the destination parameter.localhost:3000/files/download/..%2Ftest%2Fjest-e2e.json
.jest-e2e.json
file is served as a response, revealing potentially sensitive data.How to Recreate:
../
as the destination parameter.localhost:3000/files/download/..%2Ftest%2Fjest-e2e.json
.TestCase-1
jest-e2e.json
file is served as a response, revealing potentially sensitive data.TestCase-2
Solution:
To mitigate this vulnerability, we need to validate the destination parameter to ensure it does not contain any illegal characters or patterns that could lead to path traversal attacks. We can achieve this by implementing server-side validation and rejecting requests with invalid destination parameters.
Changes: