-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Add more Win32 and Azure SDK remote flow sources #21260
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
Open
MathiasVP
wants to merge
7
commits into
github:main
Choose a base branch
from
MathiasVP:add-windows-remote-flow-sources
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.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
208cf71
C++: Add tests with tests for remote flow sources from the Win32 API …
MathiasVP cbc2dbc
C++: Add flow sources and summary models.
MathiasVP 5531ef9
C++: Accept test changes.
MathiasVP 7ef96e3
C++: Add taint-inheriting reads from the Winhttp structs.
MathiasVP 40a5813
C++: Accept test changes.
MathiasVP 32b86ec
C++: Add change note.
MathiasVP 092d254
C++: Fix Copilot comments.
MathiasVP 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
4 changes: 4 additions & 0 deletions
4
cpp/ql/lib/change-notes/2026-02-03-windows-remote-flow-sources.md
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,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Added remote flow source models for the `winhttp.h` windows header and the Azure SDK core library for C/C++. |
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
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,41 @@ | ||
| extensions: | ||
| - addsTo: | ||
| pack: codeql/cpp-all | ||
| extensible: sourceModel | ||
| data: # namespace, type, subtypes, name, signature, ext, output, kind, provenance | ||
| - ["Azure::Core::Http", "RawResponse", True, "GetHeaders", "", "", "ReturnValue[*]", "remote", "manual"] | ||
| - ["Azure::Core::Http", "RawResponse", True, "GetBody", "", "", "ReturnValue[*]", "remote", "manual"] | ||
| - ["Azure::Core::Http", "RawResponse", True, "ExtractBodyStream", "", "", "ReturnValue[*]", "remote", "manual"] | ||
| - ["Azure::Core::Http", "Request", True, "GetHeaders", "", "", "ReturnValue", "remote", "manual"] | ||
| - ["Azure::Core::Http", "Request", True, "GetHeader", "", "", "ReturnValue", "remote", "manual"] | ||
| - ["Azure::Core::Http", "Request", True, "GetBodyStream", "", "", "ReturnValue[*]", "remote", "manual"] | ||
|
|
||
| - addsTo: | ||
| pack: codeql/cpp-all | ||
| extensible: summaryModel | ||
| data: # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance | ||
| - ["Azure::Core", "Url", True, "Url", "", "", "Argument[*0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "SetScheme", "", "", "Argument[*0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "SetHost", "", "", "Argument[*0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "SetPort", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "SetPath", "", "", "Argument[*0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "SetQueryParameters", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "AppendPath", "", "", "Argument[*0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "AppendQueryParameter", "", "", "Argument[*1]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetHost", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetPath", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetPort", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetQueryParameters", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetScheme", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetRelativeUrl", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "GetAbsoluteUrl", "", "", "Argument[-1]", "ReturnValue", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "Decode", "", "", "Argument[*0]", "ReturnValue", "taint", "manual"] | ||
| - ["Azure::Core", "Url", True, "Encode", "", "", "Argument[*0]", "ReturnValue", "taint", "manual"] | ||
| - ["Azure::Core::IO", "BodyStream", True, "Read", "", "", "Argument[-1]", "Argument[*0]", "taint", "manual"] | ||
| - ["Azure::Core::IO", "BodyStream", True, "ReadToCount", "", "", "Argument[-1]", "Argument[*0]", "taint", "manual"] | ||
| - ["Azure::Core::IO", "BodyStream", True, "ReadToEnd", "", "", "Argument[-1]", "ReturnValue.Element", "taint", "manual"] | ||
| - ["Azure", "Nullable", True, "Nullable", "", "", "Argument[0]", "Argument[-1]", "taint", "manual"] | ||
| - ["Azure", "Nullable", True, "operator=", "", "", "Argument[*0]", "Argument[-1]", "value", "manual"] | ||
| - ["Azure", "Nullable", True, "Value", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"] | ||
| - ["Azure", "Nullable", True, "operator->", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"] | ||
| - ["Azure", "Nullable", True, "operator*", "", "", "Argument[-1]", "ReturnValue[*]", "taint", "manual"] |
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
50 changes: 50 additions & 0 deletions
50
cpp/ql/lib/semmle/code/cpp/models/implementations/WinHttp.qll
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,50 @@ | ||
| private import cpp | ||
| private import semmle.code.cpp.ir.dataflow.FlowSteps | ||
| private import semmle.code.cpp.dataflow.new.DataFlow | ||
|
|
||
| /** The `WINHTTP_HEADER_NAME` class from `winhttp.h`. */ | ||
| class WinHttpHeaderName extends Class { | ||
| WinHttpHeaderName() { this.hasGlobalName("_WINHTTP_HEADER_NAME") } | ||
| } | ||
|
|
||
| /** The `WINHTTP_EXTENDED_HEADER` class from `winhttp.h`. */ | ||
| class WinHttpExtendedHeader extends Class { | ||
| WinHttpExtendedHeader() { this.hasGlobalName("_WINHTTP_EXTENDED_HEADER") } | ||
| } | ||
|
|
||
| private class WinHttpHeaderNameInheritingContent extends TaintInheritingContent, | ||
| DataFlow::FieldContent | ||
| { | ||
| WinHttpHeaderNameInheritingContent() { | ||
| this.getIndirectionIndex() = 2 and | ||
| ( | ||
| this.getAField().getDeclaringType() instanceof WinHttpHeaderName | ||
| or | ||
| // The extended header looks like: | ||
| // struct WINHTTP_EXTENDED_HEADER { | ||
| // union { [...] }; | ||
| // union { [...] }; | ||
| // }; | ||
| // So the first declaring type is the anonymous unions, and the declaring | ||
| // type of those anonymous unions is the `WINHTTP_EXTENDED_HEADER` struct. | ||
| this.getAField().getDeclaringType().getDeclaringType() instanceof WinHttpExtendedHeader | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| /** The `URL_COMPONENTS` class from `winhttp.h`. */ | ||
| class WinHttpUrlComponents extends Class { | ||
| WinHttpUrlComponents() { this.hasGlobalName("_WINHTTP_URL_COMPONENTS") } | ||
| } | ||
|
|
||
| private class WinHttpUrlComponentsInheritingContent extends TaintInheritingContent, | ||
| DataFlow::FieldContent | ||
| { | ||
| WinHttpUrlComponentsInheritingContent() { | ||
| exists(Field f | f = this.getField() and f.getDeclaringType() instanceof WinHttpUrlComponents | | ||
| if f.getType().getUnspecifiedType() instanceof PointerType | ||
| then this.getIndirectionIndex() = 2 | ||
| else this.getIndirectionIndex() = 1 | ||
| ) | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.