C#: Update MaD models to taint entire byte- and char collection.#20278
Merged
michaelnebel merged 3 commits intogithub:mainfrom Aug 28, 2025
Merged
C#: Update MaD models to taint entire byte- and char collection.#20278michaelnebel merged 3 commits intogithub:mainfrom
michaelnebel merged 3 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR streamlines byte and char array bulk models in C# taint analysis by treating entire collections as tainted instead of only individual elements. The change affects how taint propagates through byte and char arrays/collections, which are commonly used as alternatives to strings in security-sensitive scenarios.
Key changes:
- Updated taint tracking models to treat entire byte/char collections as tainted rather than just individual elements
- Modified flow models for APIs like
Stream.Read,Convert.FromBase64String, and related methods - Updated test expectations to reflect the new bulk taint behavior
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| csharp/ql/lib/ext/System.model.yml | Updates Convert class method models to treat entire byte/char arrays as tainted |
| csharp/ql/lib/ext/System.IO.model.yml | Updates Stream and TextReader method models to use bulk taint for byte/char arrays |
| csharp/ql/lib/change-notes/2025-08-18-byte-char-bulk-types.md | Documents the change as a minor analysis improvement |
| Multiple .expected files | Updated test expectations reflecting new taint flow behavior |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If a collection of bytes and chars are returned by an API, we now consider the entire collection tainted instead of only the elements of the collection. According to DCA this generates more alerts for some of our existing queries and the results appear to be sound.
@hvitved : Should we consider merging this?