You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C#: cs/exposure-of-sensitive-information has no documented way to mark a custom masking function as a sanitizer #23160
cs/exposure-of-sensitive-information (ExposureOfPrivateInformation) reports an email address written to a log even when it has been masked first by a project-specific function:
publicstaticclassEmailMasking{// "alice@example.com" -> "a***e@example.com"publicstaticstringMask(string?address){/* keeps first and last letter before the '@' */}}logger.LogInformation("To={To}",string.Join(", ",message.To.Select(EmailMasking.Mask)));
The alert is still raised on the log call. The taint step goes through the body of Mask (string indexing and concatenation), so a function whose purpose is to remove the sensitive part is not treated as removing it.
What I would like (enhancement)
Document how to declare a masking or redaction function as a sanitizer for this query. From reading the source, ExposureOfPrivateInformationQuery.qll uses ExternalLocationSanitizer, which is barrierNode(this, "file-content-store"), so a Models-as-Data barrierModel with that kind should work. The kind name is not mentioned in the C# MaD documentation, so it is hard to discover.
Optionally, recognise common masking and redaction helpers as barriers by default, the way some other queries treat encoders and validators.
Workaround I am trying
A model pack in .github/codeql/extensions (default setup):
Thanks for confirming that the model pack approach is the right one. That confirmation helps, but I think the underlying problem is worth stating plainly: a user should not have to read query source code to find the barrier kind name for a query they are trying to configure.
The string file-content-store is doing a lot of work here. It is not obvious that it covers log output, it is not mentioned in the C# Models as Data documentation, and a small typo in that string would fail quietly, leaving the alert in place with no hint that the model was never applied. Masking and redaction helpers are common in real codebases, so this is likely to affect more people than just this report.
I would suggest three things. First, document the barrier kinds per query, ideally in the query help itself, so the kind for each query can be found from the alert page. Second, publish a worked example for a custom masking function, using this EmailMasking case, showing the full model pack and where it goes in default setup. Third, consider a warning when a barrierModel names a kind that no query in the pack uses, since that is a cheap way to catch spelling mistakes.
On recognising common masking helpers by default, I would be cautious. A method called Mask that keeps the domain and parts of the local part may be fine for logs in one project and not acceptable in another, so the documented model route matters more than a built in guess.
If useful, I can draft the documentation section and the worked example based on the model pack in this issue.
Activity
jketema commentedon Nov 17, 2026
Hi @keithmycek,
Our documentation seems very incomplete here. I'll raise this with the team.
You're model pack approach seems the right one. See also https://docs.github.com/en/code-security/how-tos/find-and-fix-code-vulnerabilities/manage-your-configuration/edit-default-setup#extending-codeql-coverage-with-codeql-model-packs-in-default-setup, which I assume I'd already found.
eshaanjain26 commentedon Nov 29, 2026
Thanks for confirming that the model pack approach is the right one. That confirmation helps, but I think the underlying problem is worth stating plainly: a user should not have to read query source code to find the barrier kind name for a query they are trying to configure.
The string file-content-store is doing a lot of work here. It is not obvious that it covers log output, it is not mentioned in the C# Models as Data documentation, and a small typo in that string would fail quietly, leaving the alert in place with no hint that the model was never applied. Masking and redaction helpers are common in real codebases, so this is likely to affect more people than just this report.
I would suggest three things. First, document the barrier kinds per query, ideally in the query help itself, so the kind for each query can be found from the alert page. Second, publish a worked example for a custom masking function, using this EmailMasking case, showing the full model pack and where it goes in default setup. Third, consider a warning when a barrierModel names a kind that no query in the pack uses, since that is a cheap way to catch spelling mistakes.
On recognising common masking helpers by default, I would be cautious. A method called Mask that keeps the domain and parts of the local part may be fine for logs in one project and not acceptable in another, so the documented model route matters more than a built in guess.
If useful, I can draft the documentation section and the worked example based on the model pack in this issue.
Eshaan Jain, independent researcher (IEEE Senior Member)