Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java : Add Log Injection Vulnerability #5099

Merged
merged 5 commits into from
Mar 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove sanitiserGuards
Porcuiney Hairs committed Mar 18, 2021
commit a88c3682ff429dddb09dfd826c9c5efb4bc2c593
29 changes: 0 additions & 29 deletions java/ql/src/experimental/Security/CWE/CWE-117/LogInjection.ql
Original file line number Diff line number Diff line change
@@ -30,35 +30,6 @@ private class LogInjectionConfiguration extends TaintTracking::Configuration {
override predicate isSanitizer(DataFlow::Node node) {
node.getType() instanceof BoxedType or node.getType() instanceof PrimitiveType
}

override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) {
guard instanceof StrCheckSanitizerGuard
}
}

/**
* Models any regex or equality check as a sanitizer guard.
* Assumes any check on the taint to be a valid sanitizing check.
*/
private class StrCheckSanitizerGuard extends DataFlow::BarrierGuard {
StrCheckSanitizerGuard() {
exists(Method m |
m.getDeclaringType().hasQualifiedName("java.util.regex", "Pattern") and
m.hasName("matches")
or
m.getDeclaringType() instanceof TypeString and
m.hasName([
"startsWith", "regionMatches", "matches", "equals", "equalsIgnoreCase", "endsWith",
"contentEquals", "contains"
])
|
m.getAReference() = this
)
}

override predicate checks(Expr e, boolean branch) {
e = this.(MethodAccess).getQualifier() and branch = true
}
}

from LogInjectionConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink