Skip to content

Commit 06a0909

Browse files
committed
Fixed a false positve in the BleichenBacherAttacker
1 parent 24ad2bb commit 06a0909

File tree

5 files changed

+120
-5
lines changed

5 files changed

+120
-5
lines changed

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/config/HeartbleedCommandConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import de.rub.nds.tlsattacker.core.config.delegate.ProtocolVersionDelegate;
1919
import de.rub.nds.tlsattacker.core.constants.HeartbeatMode;
2020
import de.rub.nds.tlsattacker.core.workflow.factory.WorkflowTraceType;
21-
import de.rub.nds.tlsattacker.transport.TransportHandlerType;
2221

2322
public class HeartbleedCommandConfig extends AttackConfig {
2423

@@ -65,7 +64,6 @@ public boolean isExecuteAttack() {
6564
public Config createConfig() {
6665
Config config = super.createConfig();
6766
config.setAddHeartbeatExtension(true);
68-
config.setWorkflowTraceType(WorkflowTraceType.FULL);
6967
config.setHeartbeatMode(HeartbeatMode.PEER_ALLOWED_TO_SEND);
7068
return config;
7169
}

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/impl/BleichenbacherAttacker.java

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import de.rub.nds.modifiablevariable.util.ArrayConverter;
1212
import de.rub.nds.tlsattacker.attacks.config.BleichenbacherCommandConfig;
1313
import de.rub.nds.tlsattacker.attacks.pkcs1.Bleichenbacher;
14+
import de.rub.nds.tlsattacker.attacks.pkcs1.BleichenbacherVulnerabilityMap;
1415
import de.rub.nds.tlsattacker.attacks.pkcs1.BleichenbacherWorkflowGenerator;
1516
import de.rub.nds.tlsattacker.attacks.pkcs1.BleichenbacherWorkflowType;
1617
import de.rub.nds.tlsattacker.attacks.pkcs1.Pkcs1Vector;
@@ -99,12 +100,45 @@ private EqualityError isVulnerable(BleichenbacherWorkflowType bbWorkflowType, Li
99100
return null;
100101
}
101102
printBleichenbacherVectormap(bleichenbacherVectorMap);
103+
EqualityError error = getEqualityError(bleichenbacherVectorMap);
104+
if (error == EqualityError.SOCKET_EXCEPTION || error == EqualityError.SOCKET_STATE) {
105+
LOGGER.debug("Found a Socket related side channel. Rescanning to confirm.");
106+
// Socket Equality Errors can be caused by problems on on the
107+
// network. In this case we do a rescan
108+
// and check if we find the exact same answer behaviour (twice)
109+
List<VectorFingerprintPair> secondBleichenbacherVectorMap = getBleichenbacherMap(bbWorkflowType,
110+
pkcs1Vectors);
111+
EqualityError error2 = getEqualityError(secondBleichenbacherVectorMap);
112+
BleichenbacherVulnerabilityMap mapOne = new BleichenbacherVulnerabilityMap(bleichenbacherVectorMap, error);
113+
BleichenbacherVulnerabilityMap mapTwo = new BleichenbacherVulnerabilityMap(secondBleichenbacherVectorMap,
114+
error2);
115+
if (mapOne.looksIdentical(mapTwo)) {
116+
List<VectorFingerprintPair> thirdBleichenbacherVectorMap = getBleichenbacherMap(bbWorkflowType,
117+
pkcs1Vectors);
118+
EqualityError error3 = getEqualityError(secondBleichenbacherVectorMap);
119+
BleichenbacherVulnerabilityMap mapThree = new BleichenbacherVulnerabilityMap(
120+
secondBleichenbacherVectorMap, error2);
121+
if (!mapTwo.looksIdentical(mapThree)) {
122+
LOGGER.debug("The third scan prove this vulnerability to be non existent");
123+
error = EqualityError.NONE;
124+
}
125+
} else {
126+
LOGGER.debug("The second scan prove this vulnerability to be non existent");
127+
error = EqualityError.NONE;
128+
}
129+
}
130+
if (error != EqualityError.NONE) {
131+
LOGGER.log(LogLevel.CONSOLE_OUTPUT, "Found a vulnerability with " + bbWorkflowType.getDescription());
132+
}
133+
return error;
134+
}
135+
136+
public EqualityError getEqualityError(List<VectorFingerprintPair> bleichenbacherVectorMap) {
102137
ResponseFingerprint fingerprint = bleichenbacherVectorMap.get(0).getFingerprint();
103138
for (VectorFingerprintPair pair : bleichenbacherVectorMap) {
104139
EqualityError error = FingerPrintChecker.checkEquality(fingerprint, pair.getFingerprint(), false);
105140
if (error != EqualityError.NONE) {
106-
LOGGER.log(LogLevel.CONSOLE_OUTPUT, "Found a difference in responses in the {}.",
107-
bbWorkflowType.getDescription());
141+
LOGGER.log(LogLevel.CONSOLE_OUTPUT, "Found an EqualityError!");
108142
LOGGER.log(LogLevel.CONSOLE_OUTPUT,
109143
EqualityErrorTranslator.translation(error, fingerprint, pair.getFingerprint()));
110144
return error;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
3+
*
4+
* Copyright 2014-2017 Ruhr University Bochum / Hackmanit GmbH
5+
*
6+
* Licensed under Apache License 2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*/
9+
package de.rub.nds.tlsattacker.attacks.pkcs1;
10+
11+
import de.rub.nds.tlsattacker.attacks.util.response.EqualityError;
12+
import de.rub.nds.tlsattacker.attacks.util.response.FingerPrintChecker;
13+
import java.util.List;
14+
15+
public class BleichenbacherVulnerabilityMap {
16+
17+
private final List<VectorFingerprintPair> bleichenbacherVectorMap;
18+
19+
private final EqualityError error;
20+
21+
public BleichenbacherVulnerabilityMap(List<VectorFingerprintPair> bleichenbacherVectorMap, EqualityError error) {
22+
this.bleichenbacherVectorMap = bleichenbacherVectorMap;
23+
this.error = error;
24+
}
25+
26+
public boolean looksIdentical(BleichenbacherVulnerabilityMap otherMap) {
27+
if (otherMap.error != this.error) {
28+
return false;
29+
}
30+
for (VectorFingerprintPair otherPair : otherMap.bleichenbacherVectorMap) {
31+
for (VectorFingerprintPair ourPair : bleichenbacherVectorMap) {
32+
if (otherPair.getVector().getDescription().equals(this)) {
33+
// ok we found the right pairs
34+
if (FingerPrintChecker.checkEquality(ourPair.getFingerprint(), otherPair.getFingerprint(), true) != EqualityError.NONE) {
35+
return false;
36+
} else {
37+
break;
38+
}
39+
}
40+
}
41+
}
42+
return true;
43+
}
44+
45+
public List<VectorFingerprintPair> getBleichenbacherVectorMap() {
46+
return bleichenbacherVectorMap;
47+
}
48+
49+
public EqualityError getError() {
50+
return error;
51+
}
52+
}

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/pkcs1/VectorFingerprintPair.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package de.rub.nds.tlsattacker.attacks.pkcs1;
1010

1111
import de.rub.nds.tlsattacker.attacks.util.response.ResponseFingerprint;
12+
import java.util.Objects;
1213

1314
public class VectorFingerprintPair {
1415

@@ -41,4 +42,34 @@ public void setVector(Pkcs1Vector vector) {
4142
public String toString() {
4243
return "PKCS#1 Vector: " + vector.getDescription() + " Fingerprint=" + fingerprint.toString();
4344
}
45+
46+
@Override
47+
public int hashCode() {
48+
int hash = 3;
49+
hash = 67 * hash + Objects.hashCode(this.fingerprint);
50+
hash = 67 * hash + Objects.hashCode(this.vector);
51+
return hash;
52+
}
53+
54+
@Override
55+
public boolean equals(Object obj) {
56+
if (this == obj) {
57+
return true;
58+
}
59+
if (obj == null) {
60+
return false;
61+
}
62+
if (getClass() != obj.getClass()) {
63+
return false;
64+
}
65+
final VectorFingerprintPair other = (VectorFingerprintPair) obj;
66+
if (!Objects.equals(this.fingerprint, other.fingerprint)) {
67+
return false;
68+
}
69+
if (!Objects.equals(this.vector, other.vector)) {
70+
return false;
71+
}
72+
return true;
73+
}
74+
4475
}

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/util/response/EqualityErrorTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static String translation(EqualityError error, ResponseFingerprint finger
6161
builder.append("The server seems to ocassionally respond with a socket exception.");
6262
break;
6363
case SOCKET_STATE:
64-
builder.append("The server seems to ocassionally move the TCP socket in different states. Note that this difference is prone to false-positives if the network is unreliable.");
64+
builder.append("The server seems to ocassionally move the TCP socket in different states.");
6565
break;
6666
default:
6767
builder.append(error.toString());

0 commit comments

Comments
 (0)