Skip to content

Commit 21079a1

Browse files
committed
Fix conditionControlsMethod predicate
Exceptions for throw and return statements were missing the appropriate condition
1 parent 4e93330 commit 21079a1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

java/ql/lib/semmle/code/java/security/ConditionalBypassQuery.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ predicate conditionControlsMethod(MethodAccess ma, Expr e) {
1717
cb.controls(ma.getBasicBlock(), cond) and
1818
not cb.controls(any(SensitiveExecutionMethod sem).getAReference().getBasicBlock(),
1919
cond.booleanNot()) and
20-
not cb.controls(any(ThrowStmt t).getBasicBlock(), _) and
21-
not cb.controls(any(ReturnStmt r).getBasicBlock(), _) and
20+
not cb.controls(any(ThrowStmt t).getBasicBlock(), cond.booleanNot()) and
21+
not cb.controls(any(ReturnStmt r).getBasicBlock(), cond.booleanNot()) and
2222
e = cb.getCondition()
2323
)
2424
}

java/ql/test/query-tests/security/CWE-807/semmle/tests/ConditionalBypassTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public static void test6(String user, String password) {
120120

121121
public static void test7(String user, String password) {
122122
Cookie adminCookie = getCookies()[0];
123-
// FALSE NEGATIVE: login is bypasseable
124-
if (adminCookie.getValue() == "false") { // $ MISSING: $ hasConditionalBypassTest
123+
// BAD: login is bypasseable
124+
if (adminCookie.getValue() == "false") { // $ hasConditionalBypassTest
125125
login(user, password);
126126
return;
127127
} else {

0 commit comments

Comments
 (0)