Skip to content

C#: Fix false positives in cs/log-forging for extension methods#21498

Draft
Gregro wants to merge 1 commit intogithub:mainfrom
Gregro:csharp/fix-log-forging-extension-methods
Draft

C#: Fix false positives in cs/log-forging for extension methods#21498
Gregro wants to merge 1 commit intogithub:mainfrom
Gregro:csharp/fix-log-forging-extension-methods

Conversation

@Gregro
Copy link

@Gregro Gregro commented Mar 19, 2026

The log forging query previously treated all arguments to methods called on logger types as sinks, including user-defined extension methods. This caused false positives when extension methods sanitize input internally, since interprocedural analysis was bypassed.

Now, only direct instance method calls on logger types are treated as sinks. User-defined extension methods are analyzed interprocedurally, allowing the query to see sanitization within method bodies.

Known framework extension methods (Microsoft.Extensions.Logging.LoggerExtensions) are modeled as explicit sinks via Models as Data.

Fixes #15824

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive - Log entries created from user input (cs/log-forging)

1 participant