Skip to content

Commit 27ae23f

Browse files
committed
Restructured Bleichenbacher attacks - now only checks one workflow at the time
1 parent 5f99132 commit 27ae23f

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.beust.jcommander.Parameter;
1212
import com.beust.jcommander.ParametersDelegate;
1313
import de.rub.nds.tlsattacker.attacks.config.delegate.AttackDelegate;
14+
import de.rub.nds.tlsattacker.attacks.pkcs1.BleichenbacherWorkflowType;
1415
import de.rub.nds.tlsattacker.core.config.Config;
1516
import de.rub.nds.tlsattacker.core.config.delegate.CiphersuiteDelegate;
1617
import de.rub.nds.tlsattacker.core.config.delegate.ClientDelegate;
@@ -57,6 +58,11 @@ public class BleichenbacherCommandConfig extends AttackConfig {
5758
@ParametersDelegate
5859
private StarttlsDelegate starttlsDelegate;
5960

61+
@Parameter(names = "-workflowType", description = "Which workflow traces should be tested with")
62+
private BleichenbacherWorkflowType workflowType = BleichenbacherWorkflowType.CKE_CCS_FIN;
63+
64+
;
65+
6066
/**
6167
*
6268
* @param delegate
@@ -157,11 +163,17 @@ public enum Type {
157163
*
158164
*/
159165
FULL,
160-
161166
/**
162167
*
163168
*/
164169
FAST
165170
}
166171

172+
public BleichenbacherWorkflowType getWorkflowType() {
173+
return workflowType;
174+
}
175+
176+
public void setWorkflowType(BleichenbacherWorkflowType workflowType) {
177+
this.workflowType = workflowType;
178+
}
167179
}

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

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public class BleichenbacherAttacker extends Attacker<BleichenbacherCommandConfig
5050

5151
private static final Logger LOGGER = LogManager.getLogger();
5252

53-
private Config tlsConfig;
54-
5553
private BleichenbacherWorkflowType vulnerableType;
5654

5755
private EqualityError errorType;
@@ -70,7 +68,6 @@ public class BleichenbacherAttacker extends Attacker<BleichenbacherCommandConfig
7068
public BleichenbacherAttacker(BleichenbacherCommandConfig bleichenbacherConfig, Config baseConfig) {
7169
super(bleichenbacherConfig, baseConfig);
7270
executor = new ParallelExecutor(1, 3);
73-
this.tlsConfig = getTlsConfig();
7471
}
7572

7673
/**
@@ -83,7 +80,6 @@ public BleichenbacherAttacker(BleichenbacherCommandConfig bleichenbacherConfig,
8380
ParallelExecutor executor) {
8481
super(bleichenbacherConfig, baseConfig);
8582
this.executor = executor;
86-
this.tlsConfig = getTlsConfig();
8783
}
8884

8985
/**
@@ -93,6 +89,7 @@ public BleichenbacherAttacker(BleichenbacherCommandConfig bleichenbacherConfig,
9389
* @return
9490
*/
9591
public State executeTlsFlow(BleichenbacherWorkflowType type, byte[] encryptedPMS) {
92+
Config tlsConfig = getTlsConfig();
9693
WorkflowTrace trace = BleichenbacherWorkflowGenerator.generateWorkflow(tlsConfig, type, encryptedPMS);
9794
State state = new State(tlsConfig, trace);
9895
tlsConfig.setWorkflowExecutorShouldClose(false);
@@ -108,35 +105,35 @@ public State executeTlsFlow(BleichenbacherWorkflowType type, byte[] encryptedPMS
108105
*/
109106
@Override
110107
public Boolean isVulnerable() {
111-
tlsConfig = getTlsConfig();
108+
errorType = getEqualityError();
109+
if (errorType != EqualityError.NONE) {
110+
vulnerableType = config.getWorkflowType();
111+
return true;
112+
}
113+
return false;
114+
}
115+
116+
public EqualityError getEqualityError() {
117+
Config tlsConfig = getTlsConfig();
112118
RSAPublicKey publicKey = (RSAPublicKey) CertificateFetcher.fetchServerPublicKey(tlsConfig);
113119
if (publicKey == null) {
114120
LOGGER.info("Could not retrieve PublicKey from Server - is the Server running?");
115121
return null;
116122
}
117123
LOGGER.info("Fetched the following server public key: " + publicKey);
118-
119124
List<Pkcs1Vector> pkcs1Vectors = Pkcs1VectorGenerator.generatePkcs1Vectors(publicKey, config.getType(),
120125
tlsConfig.getDefaultHighestClientProtocolVersion());
121-
122126
// we execute the attack with different protocol flows and
123127
// return true as soon as we find the first inconsistency
124128
CONSOLE.info("A server is considered vulnerable to this attack if it responds differently to the test vectors.");
125129
CONSOLE.info("A server is considered secure if it always responds the same way.");
126-
for (BleichenbacherWorkflowType bbWorkflowType : BleichenbacherWorkflowType.values()) {
127-
LOGGER.debug("Testing: " + bbWorkflowType);
128-
errorType = isVulnerable(bbWorkflowType, pkcs1Vectors);
129-
if (errorType != EqualityError.NONE) {
130-
vulnerableType = bbWorkflowType;
131-
return true;
132-
133-
}
134-
}
135-
return false;
130+
LOGGER.debug("Testing: " + config.getWorkflowType());
131+
errorType = isVulnerable(pkcs1Vectors);
132+
return errorType;
136133
}
137134

138-
public EqualityError isVulnerable(BleichenbacherWorkflowType bbWorkflowType, List<Pkcs1Vector> pkcs1Vectors) {
139-
fingerprintPairList = getBleichenbacherMap(bbWorkflowType, pkcs1Vectors);
135+
public EqualityError isVulnerable(List<Pkcs1Vector> pkcs1Vectors) {
136+
fingerprintPairList = getBleichenbacherMap(config.getWorkflowType(), pkcs1Vectors);
140137
if (fingerprintPairList.isEmpty()) {
141138
LOGGER.warn("Could not extract Fingerprints");
142139
return null;
@@ -148,15 +145,15 @@ public EqualityError isVulnerable(BleichenbacherWorkflowType bbWorkflowType, Lis
148145
// Socket Equality Errors can be caused by problems on on the
149146
// network. In this case we do a rescan
150147
// and check if we find the exact same answer behaviour (twice)
151-
List<VectorFingerprintPair> secondBleichenbacherVectorMap = getBleichenbacherMap(bbWorkflowType,
148+
List<VectorFingerprintPair> secondBleichenbacherVectorMap = getBleichenbacherMap(config.getWorkflowType(),
152149
pkcs1Vectors);
153150
EqualityError error2 = getEqualityError(secondBleichenbacherVectorMap);
154151
BleichenbacherVulnerabilityMap mapOne = new BleichenbacherVulnerabilityMap(fingerprintPairList, error);
155152
BleichenbacherVulnerabilityMap mapTwo = new BleichenbacherVulnerabilityMap(secondBleichenbacherVectorMap,
156153
error2);
157154
if (mapOne.looksIdentical(mapTwo)) {
158-
List<VectorFingerprintPair> thirdBleichenbacherVectorMap = getBleichenbacherMap(bbWorkflowType,
159-
pkcs1Vectors);
155+
List<VectorFingerprintPair> thirdBleichenbacherVectorMap = getBleichenbacherMap(
156+
config.getWorkflowType(), pkcs1Vectors);
160157
EqualityError error3 = getEqualityError(secondBleichenbacherVectorMap);
161158
BleichenbacherVulnerabilityMap mapThree = new BleichenbacherVulnerabilityMap(
162159
thirdBleichenbacherVectorMap, error3);
@@ -172,7 +169,7 @@ public EqualityError isVulnerable(BleichenbacherWorkflowType bbWorkflowType, Lis
172169
}
173170
}
174171
if (error != EqualityError.NONE) {
175-
CONSOLE.info("Found a vulnerability with " + bbWorkflowType.getDescription());
172+
CONSOLE.info("Found a vulnerability with " + config.getWorkflowType().getDescription());
176173
}
177174
return error;
178175
}
@@ -206,6 +203,7 @@ private void printBleichenbacherVectormap(List<VectorFingerprintPair> bleichenba
206203

207204
private List<VectorFingerprintPair> getBleichenbacherMap(BleichenbacherWorkflowType bbWorkflowType,
208205
List<Pkcs1Vector> pkcs1Vectors) {
206+
Config tlsConfig = getTlsConfig();
209207
List<VectorFingerprintPair> bleichenbacherVectorMap = new LinkedList<>();
210208
List<State> stateList = new LinkedList<>();
211209
List<StateVectorPair> stateVectorPairList = new LinkedList<>();
@@ -267,6 +265,7 @@ public void executeAttack() {
267265
LOGGER.warn("The server is not vulnerable to the Bleichenbacher attack");
268266
return;
269267
}
268+
Config tlsConfig = getTlsConfig();
270269
RSAPublicKey publicKey = (RSAPublicKey) CertificateFetcher.fetchServerPublicKey(tlsConfig);
271270
if (publicKey == null) {
272271
LOGGER.info("Could not retrieve PublicKey from Server - is the Server running?");

0 commit comments

Comments
 (0)