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):
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.