-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
push down url validation to avoid security check false alarm #2685
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2685 +/- ##
=======================================
Coverage 72.39% 72.39%
=======================================
Files 85 85
Lines 3956 3956
Branches 58 58
=======================================
Hits 2864 2864
Misses 1088 1088
Partials 4 4 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
let's run the code scanner after rebasing or merging to master
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
+ "AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY or AWS_DEFAULT_REGION"); | ||
} | ||
|
||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); |
Check failure
Code scanning / CodeQL
Server-side request forgery Critical
user-provided value
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
frontend/archive/src/main/java/org/pytorch/serve/archive/model/s3/HttpUtils.java
Fixed
Show fixed
Hide fixed
"Miss environment variables " | ||
+ "AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY or AWS_DEFAULT_REGION"); | ||
URL endpointUrl = new URL(url); | ||
FileUtils.copyURLToFile(endpointUrl, modelLocation); |
Check failure
Code scanning / CodeQL
Server-side request forgery Critical
user-provided value
"Miss environment variables " | ||
+ "AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY or AWS_DEFAULT_REGION"); | ||
URL endpointUrl = new URL(url); | ||
FileUtils.copyURLToFile(endpointUrl, modelLocation); |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
throw new IOException( | ||
"Security alert slash or backslash appear in archiveName:" + archiveName); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's some more validaiton we can do
- Ensure the url is using the https protocol and not http or ftp
- Potentially check that the IP is not a litteral IP and instead a domain?
- Limit redirections
- ..%2F is used for path traveral attacks
- Optionally some additional checks on user-agent and content-type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these validation is covered by function validateURL
Description
Please read our CONTRIBUTING.md prior to creating your first pull request.
Please include a summary of the feature or issue being fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
The url validation is already done before we use the url. There is false security alarm b/c security check lost the context. To avoid the false alarm, we push down url validation.
Fixing:
Fixes #(issue)
#2665
Type of change
Please delete options that are not relevant.
Feature/Issue validation/testing
Please describe the Unit or Integration tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.
Test A
Logs for Test A
Test B
Logs for Test B
Checklist: