-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Azure python sanitizer upstream2 #21288
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
base: main
Are you sure you want to change the base?
Changes from all commits
9912aaa
b8ba905
46a2a24
08b72d0
7db9779
265922d
88adb05
27e1981
97ddab0
97f19d0
42f6e6a
4f11913
f6c302b
85ae404
df54459
23bab81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Modified SSRF tests to use postprocessing to more easily debug results. | ||
| * Added new full SSRF sanitization barrier from the new AntiSSRF library. |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Security/CWE-918/FullServerSideRequestForgery.ql | ||
| query: Security/CWE-918/FullServerSideRequestForgery.ql | ||
| postprocess: utils/test/InlineExpectationsTestQuery.ql |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Security/CWE-918/PartialServerSideRequestForgery.ql | ||
| query: Security/CWE-918/PartialServerSideRequestForgery.ql | ||
| postprocess: utils/test/InlineExpectationsTestQuery.ql |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,26 +1,30 @@ | ||||||
| from flask import request | ||||||
| from flask import request # $ Source | ||||||
|
|
||||||
| import requests | ||||||
| import requests | ||||||
|
||||||
| import requests | |
| import requests |
Copilot
AI
Feb 9, 2026
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.
Spelling: "contollred" should be "controlled" (appears twice in this file).
Copilot
AI
Feb 9, 2026
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.
Spelling: "contollred" should be "controlled".
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,8 +3,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from azure.keyvault.keys import KeyClient | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from azure.storage.blob import ContainerClient | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from azure.storage.blob import download_blob_from_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from flask import request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from flask import request # $ Source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def azure_sdk_test(credential, output_path): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| user_input = request.args['untrusted_input'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -13,24 +12,14 @@ def azure_sdk_test(credential, output_path): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url = f"https://example.com/foo#{user_input}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| full_url = f"https://{user_input2}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Testing Azure sink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = SecretClient(vault_url=url, credential=credential)# NOT OK -- user only controlled fragment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = SecretClient(vault_url=full_url, credential=credential) # NOT OK -- user has full control | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ShareFileClient.from_file_url(url) # NOT OK -- user only controlled fragment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ShareFileClient.from_file_url(full_url) # NOT OK -- user has full control | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = KeyClient(url, credential)# NOT OK -- user only controlled fragment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = KeyClient(full_url, credential) # NOT OK -- user has full control | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ContainerClient.from_container_url(container_url=url, credential=credential) # NOT OK -- user only controlled fragment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ContainerClient.from_container_url(container_url=full_url, credential=credential) # NOT OK -- user has full control | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = SecretClient(vault_url=url, credential=credential) # $ Alert[py/partial-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = SecretClient(vault_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ShareFileClient.from_file_url(url) # $ Alert[py/partial-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ShareFileClient.from_file_url(full_url) # $ Alert[py/full-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = KeyClient(url, credential) # $ Alert[py/partial-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = KeyClient(full_url, credential) # $ Alert[py/full-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ContainerClient.from_container_url(container_url=url, credential=credential) # $ Alert[py/partial-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = ContainerClient.from_container_url(container_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+22
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| c = SecretClient(vault_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| c = SecretClient(vault_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | |
| c = ShareFileClient.from_file_url(url) # $ Alert[py/partial-ssrf] | |
| c = ShareFileClient.from_file_url(full_url) # $ Alert[py/full-ssrf] | |
| c = KeyClient(url, credential) # $ Alert[py/partial-ssrf] | |
| c = KeyClient(full_url, credential) # $ Alert[py/full-ssrf] | |
| c = ContainerClient.from_container_url(container_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| c = ContainerClient.from_container_url(container_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | |
| SecretClient(vault_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| SecretClient(vault_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | |
| ShareFileClient.from_file_url(url) # $ Alert[py/partial-ssrf] | |
| ShareFileClient.from_file_url(full_url) # $ Alert[py/full-ssrf] | |
| KeyClient(url, credential) # $ Alert[py/partial-ssrf] | |
| KeyClient(full_url, credential) # $ Alert[py/full-ssrf] | |
| ContainerClient.from_container_url(container_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| ContainerClient.from_container_url(container_url=full_url, credential=credential) # $ Alert[py/full-ssrf] |
Copilot
AI
Feb 9, 2026
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.
This assignment to 'c' is unnecessary as it is redefined before this value is used.
This issue also appears in the following locations of the same file:
- line 16
- line 17
- line 18
- line 19
- line 20
- ...and 1 more
| c = SecretClient(vault_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| c = SecretClient(vault_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | |
| c = ShareFileClient.from_file_url(url) # $ Alert[py/partial-ssrf] | |
| c = ShareFileClient.from_file_url(full_url) # $ Alert[py/full-ssrf] | |
| c = KeyClient(url, credential) # $ Alert[py/partial-ssrf] | |
| c = KeyClient(full_url, credential) # $ Alert[py/full-ssrf] | |
| c = ContainerClient.from_container_url(container_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| c = ContainerClient.from_container_url(container_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | |
| SecretClient(vault_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| SecretClient(vault_url=full_url, credential=credential) # $ Alert[py/full-ssrf] | |
| ShareFileClient.from_file_url(url) # $ Alert[py/partial-ssrf] | |
| ShareFileClient.from_file_url(full_url) # $ Alert[py/full-ssrf] | |
| KeyClient(url, credential) # $ Alert[py/partial-ssrf] | |
| KeyClient(full_url, credential) # $ Alert[py/full-ssrf] | |
| ContainerClient.from_container_url(container_url=url, credential=credential) # $ Alert[py/partial-ssrf] | |
| ContainerClient.from_container_url(container_url=full_url, credential=credential) # $ Alert[py/full-ssrf] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
| from flask import Flask, request | ||||||
|
|
||||||
| from flask import request # $ Source | ||||||
| from flask import Flask | ||||||
| from http.client import HTTPConnection | ||||||
|
|
||||||
| app = Flask(__name__) | ||||||
|
|
@@ -10,28 +10,35 @@ def ssrf_test(): | |||||
| unsafe_path = request.args["path"] | ||||||
| user_input = request.args['untrusted_input'] | ||||||
|
|
||||||
| conn = HTTPConnection(unsafe_host) | ||||||
| conn.request("GET", unsafe_path) # NOT OK -- user has full control | ||||||
| conn = HTTPConnection(unsafe_host) # $ Sink[py/full-ssrf] | ||||||
| # NOT OK -- user has full control | ||||||
| conn.request("GET", unsafe_path) # $ Alert[py/full-ssrf] | ||||||
|
|
||||||
| # Full SSRF variant, where there is ALSO made a request with fixed URL on the same | ||||||
| # Full SSRF variant, where there is AlSO made a request with fixed URL on the same | ||||||
|
||||||
| # Full SSRF variant, where there is AlSO made a request with fixed URL on the same | |
| # Full SSRF variant, where there is also made a request with fixed URL on the same |
Copilot
AI
Feb 9, 2026
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.
The sink annotation here is inconsistent with the other sink annotations in this file (# $ Sink[py/full-ssrf] / # $ Sink[py/partial-ssrf]). Please specify the kind for this sink as well so the inline expectations remain unambiguous.
| conn = HTTPConnection(unsafe_host) # $ Sink | |
| conn = HTTPConnection(unsafe_host) # $ Sink[py/full-ssrf] |
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.
The doc comment above
UriValidatorappears to be copy/pasted fromStringRestrictionSanitizerGuardand doesn’t match what follows (this is about URI/domain validation rather than restricting characters). Please update the comment so it accurately describes the sanitizer/guard being introduced.