-
Notifications
You must be signed in to change notification settings - Fork 32
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
Reapply "Add rules for pytorch config best practices" #64
Draft
GrosQuildu
wants to merge
1
commit into
main
Choose a base branch
from
spencer-pytorch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+196
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
rules: | ||
- id: pytorch-allowed-urls | ||
message: Allowing URLs via environment variables is enabled | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
pattern: "use_env_allowed_urls=true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
rules: | ||
- id: pytorch-auto-install-deps | ||
message: Automatic installation of model dependencies is enabled | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
pattern: "install_py_dep_per_model=true" | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
rules: | ||
- id: pytorch-bound-to-all-interfaces | ||
message: Pytorch binds to all interfaces | ||
languages: [generic] | ||
severity: ERROR | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: HIGH | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
pattern-either: | ||
- pattern-regex: (grpc_)?(inference|management|metrics)_address=https?://0\.0\.0\.0:\d+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
rules: | ||
- id: pytorch-cors | ||
message: CORS settings are specified but all origins are allowed | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
pattern-not: | ||
- pattern: "cors_allowed_origin=*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
rules: | ||
- id: pytorch-defaults-job-queue-size | ||
message: No specified job queue size in Pytorch config (default 100) | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
patterns: | ||
- pattern-regex: | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a strange bug that this rule will find issue in the following:
May be semgrep's issue we may report |
||
(?s)(.*) | ||
- pattern-not-regex: .*job_queue_size= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
rules: | ||
- id: pytorch-defaults-max-request-size | ||
message: No specified maximum request size in Pytorch config | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
patterns: | ||
- pattern-regex: | | ||
(?s)(.*) | ||
- pattern-not-regex: .*max_request_size= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
rules: | ||
- id: pytorch-defaults-max-response-size | ||
message: No specified maximum response size in Pytorch config | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
patterns: | ||
- pattern-regex: | | ||
(?s)(.*) | ||
- pattern-not-regex: .*max_response_size= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
rules: | ||
- id: pytorch-defaults-number-of-gpu | ||
message: No GPU usage limits in Pytorch config (defaults to all available) | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
patterns: | ||
- pattern-regex: | | ||
(?s)(.*) | ||
- pattern-not-regex: .*number_of_gpu= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
rules: | ||
- id: pytorch-limit-max-image-pixels | ||
message: Image size limit disabled in Pytorch config | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: MEDIUM | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
pattern: "limit-max-image-pixels=false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
rules: | ||
- id: pytorch-unsecured-http | ||
message: Pytorch interface is exposed without TLS | ||
languages: [generic] | ||
severity: WARNING | ||
metadata: | ||
category: security | ||
subcategory: [audit] | ||
technology: [shell] | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: HIGH | ||
references: | ||
- https://pytorch.org/serve/configuration.html | ||
paths: | ||
include: | ||
- 'config.properties' | ||
pattern-either: | ||
- pattern-regex: (grpc_)?(inference|management|metrics)_address=http:// |
Oops, something went wrong.
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.
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.
Why is this bad? What is more secure alternative?
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.
We set impact to medium, but I don't see exploit scenario
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.
If it's not always exploitable maybe let's set category to
best-practice
?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.
Agreed, category should be best practice here; that was my intention with this rule but I didn't realize it was an available option. I'll make this change — in fact I think it applies to some other rules in here as well.