Repository navigation
Resolve and suppress false-positive CodeQL alerts - #15347
Merged
Merged
Conversation
…round-trip Resolves CodeQL SM04191 (cs/binary-formatter-without-binder) and SM03722 (cs/dangerous-binary-deserialization). Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
…test Unzip.Extract already canonicalizes and validates entry paths via TaskEnvironment.GetAbsolutePath(...).GetCanonicalForm() and StartsWith(fullDestinationDirectoryPath). Keep AbsolutePath intact, add inline SM02729 suppression, and add DoesNotExtractFilesOutsideDestination regression test. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
In the VMR CodeQL build, virtual object.ToString() dispatch from ASP.NET Core creates false taint paths into MSBuild file existence and timestamp helpers. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
ProfilerLogger writes evaluation profile output to the trusted local path specified by /profileevaluation; the VMR alert stems from cross-repo static taint over-approximation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
XmlPoke and XslTransformation process arbitrary user build XML/XSLT inputs that have no fixed XSD schema; both already configure DtdProcessing. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
…nDependencies Resource files (.resx/.resources) processed during a build are trusted developer inputs; VMR taint flows stem from cross-repo virtual object.ToString() over-approximation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
Matches dotnet/runtime and dotnet/winforms CodeQL configuration; flows into the VMR root .CodeQL.yml via arcade-services codeflow (dotnet/dotnet#9504) to resolve the 25 SM02227 false positives without littering [Serializable] types with inline comments. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
JanProvaznik
temporarily deployed
to
copilot-pat-pool
October 21, 2026 13:02 — with
GitHub Actions
Inactive
JanProvaznik
temporarily deployed
to
copilot-pat-pool
October 21, 2026 13:03 — with
GitHub Actions
Inactive
JanProvaznik
had a problem deploying
to
copilot-pat-pool
October 21, 2026 13:04 — with
GitHub Actions
Failure
JanProvaznik
temporarily deployed
to
copilot-pat-pool
October 21, 2026 13:05 — with
GitHub Actions
Inactive
JanProvaznik
temporarily deployed
to
copilot-pat-pool
October 21, 2026 13:06 — with
GitHub Actions
Inactive
JanProvaznik
had a problem deploying
to
copilot-pat-pool
October 21, 2026 13:07 — with
GitHub Actions
Failure
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The security suppressions and repository-wide query exclusion require human validation against the original alert traces.
No open issues 🎉
What changed in this PR
Addresses reported CodeQL false positives in MSBuild and unified .NET scans without changing production behavior.
Changes:
- Adds inline suppression comments and a repository-level deserialization-query exclusion.
- Replaces BinaryFormatter usage in an exception serialization test.
- Adds a ZIP path-traversal regression test.
| File | Description |
|---|---|
| src/UnitTests.Shared/ObjectModelHelpers.cs | Adds test filesystem suppression comments. |
| src/Tasks/XslTransformation.cs | Documents XML-reader suppression. |
| src/Tasks/XmlPoke.cs | Documents XML-reader suppression. |
| src/Tasks/Unzip.cs | Adds suppression comments explaining existing path checks. |
| src/Tasks/ResGenDependencies.cs | Adds resource-reading suppression comments. |
| src/Tasks/GenerateResource.cs | Adds resource-processing suppression comments. |
| src/Tasks.UnitTests/Unzip_Tests.cs | Tests rejection of ZIP path traversal. |
| src/Framework/NativeMethods.cs | Adds file-metadata suppression comments. |
| src/Framework/FileSystem/WindowsFileSystem.cs | Adds file-existence suppression comment. |
| src/Framework/FileSystem/ManagedFileSystem.cs | Adds filesystem suppression comments. |
| src/Build/Logging/ProfilerLogger.cs | Documents profiler-output suppression. |
| src/Build.UnitTests/BinaryLogger_Tests.cs | Tests serialization contracts without BinaryFormatter. |
| .CodeQL.yml | Excludes the dangerous-deserialization-routine query. |
Review effort: Balanced
AR-May
approved these changes
Oct 22, 2026
AR-May
left a comment
Member
There was a problem hiding this comment.
Overall looks good to me, only have couple of minor comments.
…ne SM00414 comment wording Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
AR-May
approved these changes
Oct 22, 2026
JanProvaznik
enabled auto-merge (squash)
October 22, 2026 13:34
This was referenced Oct 23, 2026
ViktorHofer
pushed a commit
that referenced
this pull request
Nov 18, 2026
…on (#15592) Related issue(s): Follow-up to #15347 and #15465 (S360 CodeQL SDL-required items). ### Context #14693 added `BinaryLogEventFilterException`, a `[Serializable]` (.NET Framework only) exception. The VMR Windows CodeQL scan (`vmr_vertical_build_windows_pgo_arm64`) flagged it as SM02227 ("Deserialization of this type may call System.IO.File.Delete"). This is the same false positive as the 25 `[Serializable]` types suppressed in #15465: the reported path goes from `SerializationInfo.GetString`/`GetValue` through virtual `ToString`/`Flush` dispatch across other VMR repos (runtime, winforms, nuget-client, sdk) and ends in `eng/tools/BinaryToolKit` `File.Delete`. The deserialization constructor only reads `SerializationInfo` values. ### Changes Made Added the inline `// CodeQL [SM02227] ...` suppression above the class, using the same wording as the other suppressed types. ### Testing Comment-only change; no build or test needed. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f8d5e6ae-c629-4d2a-9868-e6af55a54067
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.
Related issue(s):
N/A (S360 CodeQL SDL-Required Findings)
Context
Resolves and suppresses 54 open CodeQL alerts reported against MSBuild in
DevDiv/DotNet-msbuild-Trustedand the unified.NETVMR (dotnet/dotnet).Almost all of the alerts originate from the unified VMR CodeQL build, where cross-repository static call-graph and virtual
object.ToString()/TextWriter.Flush()dispatch over-approximation connects ASP.NET Core HTTP sources into MSBuild internals (GenerateResource,ResGenDependencies,ProfilerLogger,XmlPoke,XslTransformation,FileSystems, and[Serializable]types).Changes Made
src/Build.UnitTests/BinaryLogger_Tests.cs(SM04191,SM03722): ReplaceBinaryFormatterinReplay_EventFilter_ExceptionSerializationPreservesDiagnosticInformation(#if NETFRAMEWORK) with directGetObjectData+SerializationInfoconstructor invocation.src/Tasks/Unzip.cs&src/Tasks.UnitTests/Unzip_Tests.cs(SM02729): KeepAbsolutePathcanonicalization intact (TaskEnvironment.GetAbsolutePath(...).GetCanonicalForm()), add inline// CodeQL [SM02729]false-positive suppression, and add unit testDoesNotExtractFilesOutsideDestination.src/Framework/FileSystem/ManagedFileSystem.cs,src/Framework/FileSystem/WindowsFileSystem.cs,src/Framework/NativeMethods.cs,src/UnitTests.Shared/ObjectModelHelpers.cs(SM00414): Add inline// CodeQL [SM00414]false-positive suppressions on the reported file system sink lines.src/Build/Logging/ProfilerLogger.cs(SM04881): Add inline// CodeQL [SM04881]false-positive suppression onFile.WriteAllText(FileToLog, content).src/Tasks/XmlPoke.cs&src/Tasks/XslTransformation.cs(SM00404): Add inline// CodeQL [SM00404]false-positive suppressions onXmlReader.Create(...).src/Tasks/GenerateResource.cs&src/Tasks/ResGenDependencies.cs(SM02363): Add inline// CodeQL [SM02363]false-positive suppressions on the reported resource-reading lines..CodeQL.yml(SM02227): Add repository-level.CodeQL.ymlexcludingcs/dangerous-deserialization-routine(matchingdotnet/runtimeanddotnet/winforms), which flows into the VMR's generated root.CodeQL.ymlviaarcade-servicescodeflow (dotnet/dotnet#9504).Testing
.\build.cmd -v quiet— passed (0 errors)dotnet build src/Samples/Dependency/Dependency.csproj -v:q— passeddotnet artifacts/bin/bootstrap/core/sdk/11.0.100-rc.2.26504.105/MSBuild.dll --help— passedartifacts\bin\Microsoft.Build.Tasks.UnitTests\Debug\net11.0\Microsoft.Build.Tasks.UnitTests.exe --filter-method "*DoesNotExtractFilesOutsideDestination*" --no-progress— passed (1 succeeded, 0 failed)artifacts\bin\Microsoft.Build.Tasks.UnitTests\Debug\net472\Microsoft.Build.Tasks.UnitTests.exe --filter-method "*DoesNotExtractFilesOutsideDestination*" --no-progress— passed (1 succeeded, 0 failed)artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\net472\Microsoft.Build.Engine.UnitTests.exe --filter-method "*Replay_EventFilter_ExceptionSerializationPreservesDiagnosticInformation*" --no-progress— passed (2 succeeded, 0 failed)