Added java-kotlin Sensitive Logging barriers (substrings) #20741
+116
−5
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.
Logging of sensitive data can be mitigated by taking a substring of the data.
This affects the library used by
java/sensitive-log(CWE 532).The exact length suitable will vary by application, but this change takes a conservative approach and allows either
substringortake/takeLastof up to 7 characters.Complex redaction with a regular expression, replacement of particular characters, a substring not at the start or end of the string, or a conditional substring (such as with Apache StringUtils) are not supported in this sanitizer.
There is a new abstraction for sanitizer barriers, along with logic to detect substring operations that restrict logged data to a safe length in both Java and Kotlin code. The existing sanitizers are pulled into a new class called
GenericSanitizer, which implements the new abstract class, alongside the new sanitizer.The safe length restriction must be done in the analyzed code with a compile-time constant integer, but the integer can reach the substring operation using taint.