Skip to content

Commit c585b2e

Browse files
committed
Java: stack trace exposure: address false positives
1 parent 6519629 commit c585b2e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java/ql/src/Security/CWE/CWE-209/StackTraceExposure.ql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import semmle.code.java.security.XSS
2222
*/
2323
class PrintStackTraceMethod extends Method {
2424
PrintStackTraceMethod() {
25-
getDeclaringType().hasQualifiedName("java.lang", "Throwable") and
25+
getDeclaringType()
26+
.getSourceDeclaration()
27+
.getASourceSupertype*()
28+
.hasQualifiedName("java.lang", "Throwable") and
2629
getName() = "printStackTrace"
2730
}
2831
}
@@ -96,7 +99,8 @@ class StackTraceStringToXssSinkFlowConfig extends TaintTracking2::Configuration
9699
*/
97100
predicate printsStackExternally(MethodAccess call, Expr stackTrace) {
98101
printsStackToWriter(call) and
99-
call.getQualifier() = stackTrace
102+
call.getQualifier() = stackTrace and
103+
not call.getQualifier() instanceof SuperAccess
100104
}
101105

102106
/**

0 commit comments

Comments
 (0)