-
Notifications
You must be signed in to change notification settings - Fork 2k
Azure python sdk url summary upstream #20563
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
Merged
yoff
merged 15 commits into
github:main
from
microsoft:azure_python_sdk_url_summary_upstream
Feb 9, 2026
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
47fac88
Azure SDK models for SSRF analysis.
bdrodes d27d4fd
Updating comments.
bdrodes 704e296
Adding azure sdk test cases and updated test expected file.
bdrodes 341f553
Added change logs.
bdrodes 5ca9ff2
Update python/ql/lib/semmle/python/frameworks/SSRFSink.qll
bdrodes fab96d9
Update python/ql/test/query-tests/Security/CWE-918-ServerSideRequestF…
bdrodes d790c6d
Update python/ql/test/query-tests/Security/CWE-918-ServerSideRequestF…
bdrodes acddb2c
Moved change log to correct location.
bdrodes a660eab
Adding docs.
bdrodes 26b8a39
Adjusting acryonym for SSRF for casing standards.
bdrodes 7ddfa80
Merge branch 'main' into azure_python_sdk_url_summary_upstream
bdrodes cd73dcf
Merge branch 'main' into azure_python_sdk_url_summary_upstream
bdrodes 0a88425
Python: Altering SSRF MaD to use 'request-forgery' tag. Update to tes…
bdrodes ac1987f
Update python/ql/lib/change-notes/2025-09-30-azure_ssrf_models.md
bdrodes 8459eec
Moving the SsrfSink concept into Concepts.qll, and renaming to HttpCl…
bdrodes 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
5 changes: 5 additions & 0 deletions
5
python/ql/lib/change-notes/released/2025-09-30-azure_ssrf_models
This file contains hidden or 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,5 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Added `ssrf` MaD for the azure SDK | ||
| * Added MaD `ssrf` to `Http::Client::Request` |
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
python/ql/lib/semmle/python/frameworks/Azure.Keyvault.model.yml
This file contains hidden or 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,9 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/python-all | ||
| extensible: sinkModel | ||
| data: | ||
| - ['azure.keyvault.certificates.CertificateClient!', 'Call.Argument[0,vault_url:]', 'ssrf'] | ||
| - ['azure.keyvault.certificates.DeletedCertificate!', 'Call.Argument[recovery_id:]', 'ssrf'] | ||
| - ['azure.keyvault.keys.KeyClient!', 'Call.Argument[0,vault_url:]', 'ssrf'] | ||
| - ['azure.keyvault.secrets.SecretClient!', 'Call.Argument[0,vault_url:]', 'ssrf'] |
34 changes: 34 additions & 0 deletions
34
python/ql/lib/semmle/python/frameworks/Azure.Storage.model.yml
This file contains hidden or 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,34 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/python-all | ||
| extensible: sinkModel | ||
| data: | ||
| - ['azure.storage.blob.BlobClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient', 'Member[append_block_from_url].Argument[0,copy_source_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient', 'Member[get_page_range_diff_for_managed_disk].Argument[0,previous_snapshot_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient', 'Member[stage_block_from_url].Argument[1,source_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient', 'Member[start_copy_from_url].Argument[0,source_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient', 'Member[upload_blob_from_url].Argument[0,source_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient', 'Member[upload_pages_from_url].Argument[0,source_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobClient!', 'Member[from_blob_url].Argument[0,blob_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.BlobServiceClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.ContainerClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.blob.ContainerClient!', 'Member[from_container_url].Argument[0,container_url:]', 'ssrf'] | ||
| - ['azure', 'Member[storage].Member[blob].Member[download_blob_from_url].Argument[0,blob_url:]', 'ssrf'] | ||
| - ['azure', 'Member[storage].Member[blob].Member[upload_blob_to_url].Argument[0,blob_url:]', 'ssrf'] | ||
| - ['azure.storage.filedatalake.DataLakeDirectoryClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.filedatalake.DataLakeFileClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.filedatalake.DataLakeServiceClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.filedatalake.FileSystemClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareClient!', 'Member[from_share_url].Argument[0,share_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareDirectoryClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareDirectoryClient!', 'Member[from_directory_url].Argument[0,directory_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareFileClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareFileClient!', 'Member[from_file_url].Argument[0,file_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareFileClient', 'Member[start_copy_from_url].Argument[0,source_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareFileClient', 'Member[upload_range_from_url].Argument[0,source_url:]', 'ssrf'] | ||
| - ['azure.storage.fileshare.ShareServiceClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.queue.QueueClient!', 'Call.Argument[0,account_url:]', 'ssrf'] | ||
| - ['azure.storage.queue.QueueClient', 'Member[from_queue_url].Argument[0,queue_url:]', 'ssrf'] | ||
| - ['azure.storage.queue.QueueServiceClient!', 'Call.Argument[0,account_url:]', 'ssrf'] |
This file contains hidden or 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,35 @@ | ||
| private import python | ||
| private import semmle.python.Concepts | ||
| private import semmle.python.ApiGraphs | ||
| private import semmle.python.frameworks.data.ModelsAsData | ||
|
|
||
| /** | ||
| * INTERNAL: Do not use. | ||
| * | ||
| * Sets up SSRF sinks as Http::CLient::Request | ||
|
bdrodes marked this conversation as resolved.
Outdated
|
||
| */ | ||
| module SSRFMaDModel { | ||
|
|
||
| class SSRFSink extends Http::Client::Request::Range instanceof API::CallNode { | ||
|
|
||
| DataFlow::Node urlArg; | ||
|
|
||
| SSRFSink() { | ||
| ( | ||
| this.getArg(_) = urlArg | ||
| or | ||
| this.getArgByName(_) = urlArg | ||
| ) and | ||
| urlArg = ModelOutput::getASinkNode("ssrf").asSink() | ||
|
bdrodes marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| override DataFlow::Node getAUrlPart() { result = urlArg } | ||
|
|
||
| override string getFramework() { result = "MaD" } | ||
|
|
||
| override predicate disablesCertificateValidation( | ||
| DataFlow::Node disablingNode, DataFlow::Node argumentOrigin | ||
| ) { | ||
| // NOTE: if you need to define this, you have to special case it for every possible API in MaD | ||
| none() | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
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.
This file doesn't really match the way the rest of the repo is structured. Normally this kind of code would go in
python/ql/lib/semmle/python/security/dataflow/ServerSideRequestForgeryCustomizations.qll, but then it would only affect just the two SSRF queries. Since these models are principally adding toHttp::Client::Request::Range, and only indirectly becoming SSRF sinks, it might make more sense to put them somewhere likepython/ql/lib/semmle/python/Concepts.qll, maybe just below line 1658import ConceptsShared::Http::Client as Client.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.
(And I would name the class
HttpClientRequestFromModel.)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.
Indeed, this is my only remaining issue. There is also the philosophical question of whether all SSRF sinks really are client requests. If we had MaD for concepts, we could do this the other way round: Make all these models be client requests (with appropriate frameworks and certificate validation) and then they would be imported into the query automatically (and the query would decide that all client requests are SSRF sinks).
But for now, following the suggestion with
HttpClientRequestFromModelwould be ok.Uh oh!
There was an error while loading. Please reload this page.
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.
I've just pushed a change for this. The class was moved and renamed as suggested. I did remove it from a module though. Let me know how this looks.