Change this code to not log user-controlled data - False positive for GUID types

I am seeing an issue that is very similar to one fixed in 2020 with the tile of "Security Vulnerability: Tainted Input on Guids (C#)"

My issue is "Change this code to not log user-controlled data"

And I see SonarQube flagging a GUID as insecure data that could be used to inject invalid data into the system.

As this is a C# Type Safe GUID this error is a false positive.

While understandable for string. This issue should not flag for GUIDs, Numbers and other well-formed data types.

The issues comes from a [HttpPost] Method.

The method takes a model that contains a GUID property

The value is then passed into the system for processing.

The incorrect flag is then shown if i log the GUID into the file system.

SonarQube will report "Change this code to not log user-controlled data."

While correct that i am logging user-controlled data, this is a type safe GUID.

Hey @Paul.Spain, I’ve taken the liberty to move this post to the false positive/false negative category. As per that category’s template, could you please provide:

  • What language is this for? (okay, you did tell us this one: it’s C#)
  • Which rule? (rule ID, please)
  • Why do you believe it’s a false-positive/false-negative? (you mostly also elaborated on this one, no need to reiterate)
  • Are you using
    • SonarQube Cloud?
    • SonarQube Server / Community Build - which version?
    • SonarQube for IDE - which IDE/version?
      • in connected mode with SonarQube Server / Community Build or SonarQube Cloud?
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

Good morning,
Ah, sorry about the category, I placed it in the category suggested by your site AI.

What language is this for? (okay, you did tell us this one: it’s C#)
C# inside an ASP.net Core product

Which rule
Roslyn.sonaranalyzer.security.cs:S5145
Cwe

Why do you believe it’s a false-positive/false-negative? (you mostly also elaborated on this one, no need to reiterate)
The detection is correct in that I am logging user data to the log file.
However the data in question is a type safe GUID. Coming from a model that is populated from a post.
As the data is of GUID form, I think it is unreasonable to flag this as an issue.
For example there is no such issue when logging user created numbers into the log.

Are you using
Enterprise Edition v2025.4.4 (119049)

How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

Class Model
{
public GUID MyGuid;
}

[HttpPost]


public ActionResult<model> Post (Model model)

{
_logger.LogInformation(model.MyGuid);
}

This is a very stripped down version of what I have, but should be enough for you to recreate the issue.

Could someone add the C# tag to the topic?

I think I agree that logging a specific GUID is not a security risk in most cases. I’m curious to know why this case is flagged, as I assume there is a good rational behind it.