1010
1111import de .rub .nds .modifiablevariable .util .ArrayConverter ;
1212import de .rub .nds .tlsattacker .attacks .config .BleichenbacherCommandConfig ;
13+ import de .rub .nds .tlsattacker .attacks .exception .OracleUnstableException ;
1314import de .rub .nds .tlsattacker .attacks .pkcs1 .Bleichenbacher ;
1415import de .rub .nds .tlsattacker .attacks .pkcs1 .BleichenbacherVulnerabilityMap ;
1516import de .rub .nds .tlsattacker .attacks .pkcs1 .BleichenbacherWorkflowGenerator ;
@@ -128,12 +129,12 @@ public EqualityError getEqualityError() {
128129 CONSOLE .info ("A server is considered vulnerable to this attack if it responds differently to the test vectors." );
129130 CONSOLE .info ("A server is considered secure if it always responds the same way." );
130131 LOGGER .debug ("Testing: " + config .getWorkflowType ());
131- errorType = isVulnerable (pkcs1Vectors );
132+ errorType = isVulnerable (pkcs1Vectors , publicKey );
132133 return errorType ;
133134 }
134135
135- public EqualityError isVulnerable (List <Pkcs1Vector > pkcs1Vectors ) {
136- fingerprintPairList = getBleichenbacherMap (config .getWorkflowType (), pkcs1Vectors );
136+ public EqualityError isVulnerable (List <Pkcs1Vector > pkcs1Vectors , RSAPublicKey publicKey ) {
137+ fingerprintPairList = getBleichenbacherMap (config .getWorkflowType (), pkcs1Vectors , publicKey );
137138 if (fingerprintPairList .isEmpty ()) {
138139 LOGGER .warn ("Could not extract Fingerprints" );
139140 return null ;
@@ -146,14 +147,14 @@ public EqualityError isVulnerable(List<Pkcs1Vector> pkcs1Vectors) {
146147 // network. In this case we do a rescan
147148 // and check if we find the exact same answer behaviour (twice)
148149 List <VectorFingerprintPair > secondBleichenbacherVectorMap = getBleichenbacherMap (config .getWorkflowType (),
149- pkcs1Vectors );
150+ pkcs1Vectors , publicKey );
150151 EqualityError error2 = getEqualityError (secondBleichenbacherVectorMap );
151152 BleichenbacherVulnerabilityMap mapOne = new BleichenbacherVulnerabilityMap (fingerprintPairList , error );
152153 BleichenbacherVulnerabilityMap mapTwo = new BleichenbacherVulnerabilityMap (secondBleichenbacherVectorMap ,
153154 error2 );
154155 if (mapOne .looksIdentical (mapTwo )) {
155156 List <VectorFingerprintPair > thirdBleichenbacherVectorMap = getBleichenbacherMap (
156- config .getWorkflowType (), pkcs1Vectors );
157+ config .getWorkflowType (), pkcs1Vectors , publicKey );
157158 EqualityError error3 = getEqualityError (secondBleichenbacherVectorMap );
158159 BleichenbacherVulnerabilityMap mapThree = new BleichenbacherVulnerabilityMap (
159160 thirdBleichenbacherVectorMap , error3 );
@@ -202,7 +203,7 @@ private void printBleichenbacherVectormap(List<VectorFingerprintPair> bleichenba
202203 }
203204
204205 private List <VectorFingerprintPair > getBleichenbacherMap (BleichenbacherWorkflowType bbWorkflowType ,
205- List <Pkcs1Vector > pkcs1Vectors ) {
206+ List <Pkcs1Vector > pkcs1Vectors , RSAPublicKey publicKey ) {
206207 Config tlsConfig = getTlsConfig ();
207208 tlsConfig .setWorkflowExecutorShouldClose (false );
208209 List <VectorFingerprintPair > bleichenbacherVectorMap = new LinkedList <>();
@@ -226,6 +227,17 @@ private List<VectorFingerprintPair> getBleichenbacherMap(BleichenbacherWorkflowT
226227 processFinishedStateVectorPair (stateVectorPair , bleichenbacherVectorMap );
227228 }
228229 }
230+ // Check that the public key send by the server is actually the public
231+ // key used to generate
232+ // the vectors. This is currently a limitation of our script as the
233+ // attack vectors are
234+ // generated statically and not dynamically. We will adjust this in
235+ // future versions.
236+ for (StateVectorPair pair : stateVectorPairList ) {
237+ if (!pair .getState ().getTlsContext ().getServerRsaModulus ().equals (publicKey .getModulus ())) {
238+ throw new OracleUnstableException ("Server sent us a different publickey during the scan. Aborting test" );
239+ }
240+ }
229241
230242 return bleichenbacherVectorMap ;
231243 }
@@ -236,7 +248,7 @@ private void processFinishedStateVectorPair(StateVectorPair stateVectorPair,
236248 ResponseFingerprint fingerprint = ResponseExtractor .getFingerprint (stateVectorPair .getState ());
237249 bleichenbacherVectorMap .add (new VectorFingerprintPair (fingerprint , stateVectorPair .getVector ()));
238250 } else {
239- LOGGER .error ("Could not execute Workflow. Something went wrong... Check the debug output for more information" );
251+ LOGGER .warn ("Could not execute Workflow. Something went wrong... Check the debug output for more information" );
240252 }
241253 clearConnections (stateVectorPair .getState ());
242254
0 commit comments