Skip to content

Commit 0b79e50

Browse files
author
bb
committed
fix(ascanrules): reduce false positives in boolean-based SQLi check (#9289)
- Raise OR-TRUE response size threshold from 1.2x to 1.4x - Add minimum absolute size difference guard (500 bytes) - Prevents false positives on dynamic pages with variable content such as ads, timestamps, and session tokens
1 parent e183846 commit 0b79e50

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/SqlInjectionScanRule.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,9 +1228,12 @@ private void testBooleanBasedNoDataSqlInjection(String param, String origParamVa
12281228
String mResBodyNormalStripped = this.stripOff(mResBodyNormalUnstripped, origParamValue);
12291229

12301230
// if the results of the "OR 1=1" exceed the original query (unstripped, by more
1231-
// than a 20% size difference, say), we may be onto something.
1232-
// TODO: change the percentage difference threshold based on the alert threshold
1233-
if ((resBodyORTrueUnstripped.length() > (mResBodyNormalUnstripped.length() * 1.2))) {
1231+
// than a 40% size difference AND at least 500 bytes), we may be onto something.
1232+
// Raised threshold and added absolute byte guard to reduce false positives (#9289)
1233+
int normalLen = mResBodyNormalUnstripped.length();
1234+
int orTrueLen = resBodyORTrueUnstripped.length();
1235+
int absoluteDiff = orTrueLen - normalLen;
1236+
if (orTrueLen > (normalLen * 1.4) && absoluteDiff > 500) {
12341237
LOGGER.debug(
12351238
"Check 2a, unstripped html output for OR TRUE condition [{}] produced sufficiently larger results than the original message",
12361239
sqlBooleanOrTrueValue);

0 commit comments

Comments
 (0)