Skip to content

Commit 0a176ae

Browse files
authored
Merge pull request #546 from RUB-NDS/tls13fix
Tls13fix
2 parents 3c772c6 + 01f4b9c commit 0a176ae

File tree

26 files changed

+228
-139
lines changed

26 files changed

+228
-139
lines changed

Attacks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>de.rub.nds.tlsattacker</groupId>
66
<artifactId>TLS-Attacker</artifactId>
7-
<version>2.7</version>
7+
<version>2.8</version>
88
</parent>
99
<artifactId>Attacks</artifactId>
1010
<packaging>jar</packaging>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public Lucky13CommandConfig(GeneralDelegate delegate) {
6565
ciphersuiteDelegate = new CiphersuiteDelegate();
6666
protocolVersionDelegate = new ProtocolVersionDelegate();
6767
starttlsDelegate = new StarttlsDelegate();
68+
proxyDelegate = new ProxyDelegate();
6869
addDelegate(clientDelegate);
6970
addDelegate(hostnameExtensionDelegate);
7071
addDelegate(ciphersuiteDelegate);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ public void executeAttack() {
100100
*/
101101
@Override
102102
public Boolean isVulnerable() {
103-
if (config.getRecordGeneratorType() == PaddingRecordGeneratorType.VERY_SHORT) {
104-
groupRecords = false;
105-
}
103+
groupRecords = false;
106104
CONSOLE.info("A server is considered vulnerable to this attack if it responds differently to the test vectors.");
107105
CONSOLE.info("A server is considered secure if it always responds the same way.");
108106
EqualityError error;
@@ -205,7 +203,6 @@ public boolean lookEqual(List<VectorResponse> responseVectorListOne, List<Vector
205203
* @return
206204
*/
207205
public List<VectorResponse> createVectorResponseList() {
208-
209206
PaddingTraceGenerator generator = PaddingTraceGeneratorFactory.getPaddingTraceGenerator(config);
210207
PaddingVectorGenerator vectorGenerator = generator.getVectorGenerator();
211208
List<TlsTask> taskList = new LinkedList<>();

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/padding/LongPaddingGenerator.java

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ public List<PaddingVector> getVectors(CipherSuite suite, ProtocolVersion version
6868
List<PaddingVector> createBasicMacVectors(CipherSuite suite, ProtocolVersion version) {
6969
List<PaddingVector> vectorList = new LinkedList<>();
7070
int macSize = AlgorithmResolver.getMacAlgorithm(version, suite).getSize();
71+
int i = 1;
7172
for (ByteArrayXorModification modification : createFlippedModifications(macSize)) {
7273
vectorList.add(new TrippleVector("BasicMac-" + modification.getStartPosition() + "-"
73-
+ ArrayConverter.bytesToHexString(modification.getXor()), new ByteArrayExplicitValueModification(
74-
new byte[DEFAULT_CIPHERTEXT_LENGTH - macSize - DEFAULT_PADDING_LENGTH]), modification, null));
74+
+ ArrayConverter.bytesToHexString(modification.getXor()), "BasicMac" + i,
75+
new ByteArrayExplicitValueModification(new byte[DEFAULT_CIPHERTEXT_LENGTH - macSize
76+
- DEFAULT_PADDING_LENGTH]), modification, null));
77+
i++;
7578
}
7679
return vectorList;
7780
}
@@ -88,18 +91,20 @@ List<PaddingVector> createMissingMacByteVectors(CipherSuite suite, ProtocolVersi
8891
int macSize = AlgorithmResolver.getMacAlgorithm(version, suite).getSize();
8992
byte[] padding = createPaddingBytes(DEFAULT_CIPHERTEXT_LENGTH - macSize);
9093
// Missing first MAC byte because of overlong valid padding
91-
vectorList.add(new TrippleVector("MissingMacByteFirst", new ByteArrayExplicitValueModification(new byte[0]),
92-
new ByteArrayDeleteModification(0, 1), new ByteArrayExplicitValueModification(padding)));
94+
vectorList.add(new TrippleVector("MissingMacByteFirst", "MissingMacByteFirst",
95+
new ByteArrayExplicitValueModification(new byte[0]), new ByteArrayDeleteModification(0, 1),
96+
new ByteArrayExplicitValueModification(padding)));
9397
// Missing last MAC byte because of overlong valid padding
94-
vectorList.add(new TrippleVector("MissingMacByteLast", new ByteArrayExplicitValueModification(new byte[0]),
95-
new ByteArrayDeleteModification((macSize - 1), 1), new ByteArrayExplicitValueModification(padding)));
98+
vectorList.add(new TrippleVector("MissingMacByteLast", "MissingMacByteLast",
99+
new ByteArrayExplicitValueModification(new byte[0]), new ByteArrayDeleteModification((macSize - 1), 1),
100+
new ByteArrayExplicitValueModification(padding)));
96101
return vectorList;
97102
}
98103

99104
List<PaddingVector> createOnlyPaddingVectors(CipherSuite suite, ProtocolVersion version) {
100105
List<PaddingVector> vectorList = new LinkedList<>();
101106
byte[] plain = createPaddingBytes(DEFAULT_CIPHERTEXT_LENGTH - 1);
102-
vectorList.add(createVectorWithPlainData("Plain XF (0xXF=#padding bytes)", plain));
107+
vectorList.add(createVectorWithPlainData("Plain XF (0xXF=#padding bytes)", "PlainOnlyPadding", plain));
103108
plain = new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255,
104109
(byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255,
105110
(byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255,
@@ -111,7 +116,7 @@ List<PaddingVector> createOnlyPaddingVectors(CipherSuite suite, ProtocolVersion
111116
(byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255,
112117
(byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255, (byte) 255,
113118
(byte) 255, };
114-
vectorList.add(createVectorWithPlainData("Plain FF", plain));
119+
vectorList.add(createVectorWithPlainData("Plain FF", "PlainTooMuchPadding", plain));
115120
return vectorList;
116121
}
117122

@@ -137,19 +142,19 @@ private List<PaddingVector> createClassicModifiedPaddingWithValidMAC(int applica
137142
byte[] padding = createPaddingBytes(paddingValue);
138143
padding[i] ^= 0x80; // flip first padding byte highest bit
139144
vectorList.add(new TrippleVector("InvPadValMac-[" + i + "]x80-" + applicationLength + "-" + paddingValue,
140-
new ByteArrayExplicitValueModification(new byte[applicationLength]), null,
145+
"InvPadValMacStart" + i, new ByteArrayExplicitValueModification(new byte[applicationLength]), null,
141146
new ByteArrayExplicitValueModification(padding)));
142147
padding = createPaddingBytes(paddingValue);
143148
padding[i] ^= 0x8; // flip middle padding byte
144149
// middle bit
145150
vectorList.add(new TrippleVector("InvPadValMac-[" + i + "]x08-" + applicationLength + "-" + paddingValue,
146-
new ByteArrayExplicitValueModification(new byte[applicationLength]), null,
151+
"InvPadValMacMid" + i, new ByteArrayExplicitValueModification(new byte[applicationLength]), null,
147152
new ByteArrayExplicitValueModification(padding)));
148153
padding = createPaddingBytes(paddingValue);
149154
padding[i] ^= 0x01; // flip last padding byte lowest
150155
// bit
151156
vectorList.add(new TrippleVector("InvPadValMac-[" + i + "]x01-" + applicationLength + "-" + paddingValue,
152-
new ByteArrayExplicitValueModification(new byte[applicationLength]), null,
157+
"InvPadValMacEnd" + i, new ByteArrayExplicitValueModification(new byte[applicationLength]), null,
153158
new ByteArrayExplicitValueModification(padding)));
154159
}
155160
return vectorList;
@@ -161,64 +166,67 @@ private List<PaddingVector> createClassicModifiedPaddingWithInvalidMAC(int appli
161166
for (int i = 0; i < DEFAULT_CIPHERTEXT_LENGTH - applicationLength - paddingValue - 1; i++) {
162167
byte[] padding = createPaddingBytes(paddingValue);
163168
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b00000001-" + applicationLength + "-"
164-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
165-
new ByteArrayXorModification(new byte[] { 0b00000001 }, i), new ByteArrayExplicitValueModification(
166-
padding)));
169+
+ paddingValue, "ValPadInvMac1_" + i, new ByteArrayExplicitValueModification(
170+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b00000001 }, i),
171+
new ByteArrayExplicitValueModification(padding)));
167172
padding = createPaddingBytes(paddingValue);
168173
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b00000010-" + applicationLength + "-"
169-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
170-
new ByteArrayXorModification(new byte[] { 0b00000010 }, i), new ByteArrayExplicitValueModification(
171-
padding)));
174+
+ paddingValue, "ValPadInvMac2_" + i, new ByteArrayExplicitValueModification(
175+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b00000010 }, i),
176+
new ByteArrayExplicitValueModification(padding)));
172177
padding = createPaddingBytes(paddingValue);
173178
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b00000100-" + applicationLength + "-"
174-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
175-
new ByteArrayXorModification(new byte[] { 0b00000100 }, i), new ByteArrayExplicitValueModification(
176-
padding)));
179+
+ paddingValue, "ValPadInvMac3_" + i, new ByteArrayExplicitValueModification(
180+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b00000100 }, i),
181+
new ByteArrayExplicitValueModification(padding)));
177182
padding = createPaddingBytes(paddingValue);
178183
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b00001000-" + applicationLength + "-"
179-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
180-
new ByteArrayXorModification(new byte[] { 0b00001000 }, i), new ByteArrayExplicitValueModification(
181-
padding)));
184+
+ paddingValue, "ValPadInvMac4_" + i, new ByteArrayExplicitValueModification(
185+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b00001000 }, i),
186+
new ByteArrayExplicitValueModification(padding)));
182187
padding = createPaddingBytes(paddingValue);
183188
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b00010000-" + applicationLength + "-"
184-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
185-
new ByteArrayXorModification(new byte[] { 0b00010000 }, i), new ByteArrayExplicitValueModification(
186-
padding)));
189+
+ paddingValue, "ValPadInvMac5_" + i, new ByteArrayExplicitValueModification(
190+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b00010000 }, i),
191+
new ByteArrayExplicitValueModification(padding)));
187192
padding = createPaddingBytes(paddingValue);
188193
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b00100000-" + applicationLength + "-"
189-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
190-
new ByteArrayXorModification(new byte[] { 0b00100000 }, i), new ByteArrayExplicitValueModification(
191-
padding)));
194+
+ paddingValue, "ValPadInvMac6_" + i, new ByteArrayExplicitValueModification(
195+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b00100000 }, i),
196+
new ByteArrayExplicitValueModification(padding)));
192197
padding = createPaddingBytes(paddingValue);
193198
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b01000000-" + applicationLength + "-"
194-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
195-
new ByteArrayXorModification(new byte[] { 0b01000000 }, i), new ByteArrayExplicitValueModification(
196-
padding)));
199+
+ paddingValue, "ValPadInvMac7_" + i, new ByteArrayExplicitValueModification(
200+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { 0b01000000 }, i),
201+
new ByteArrayExplicitValueModification(padding)));
197202
padding = createPaddingBytes(paddingValue);
198203
vectorList.add(new TrippleVector("ValPadInvMac-[" + i + "]-0b10000000-" + applicationLength + "-"
199-
+ paddingValue, new ByteArrayExplicitValueModification(new byte[applicationLength]),
200-
new ByteArrayXorModification(new byte[] { (byte) 0b10000000 }, i),
204+
+ paddingValue, "ValPadInvMac8_" + i, new ByteArrayExplicitValueModification(
205+
new byte[applicationLength]), new ByteArrayXorModification(new byte[] { (byte) 0b10000000 }, i),
201206
new ByteArrayExplicitValueModification(padding)));
202207
}
203208
for (int i = 0; i < paddingValue; i++) {
204209
byte[] padding = createPaddingBytes(paddingValue);
205210

206211
padding[i] ^= 0x80; // flip first padding byte highest bit
207212
vectorList.add(new TrippleVector("InvPadInvMac-[" + i + "]x80-" + applicationLength + "-" + paddingValue,
208-
new ByteArrayExplicitValueModification(new byte[applicationLength]), new ByteArrayXorModification(
209-
new byte[] { 0x01 }, 0), new ByteArrayExplicitValueModification(padding)));
213+
"InvPadInvMacStart" + i, new ByteArrayExplicitValueModification(new byte[applicationLength]),
214+
new ByteArrayXorModification(new byte[] { 0x01 }, 0), new ByteArrayExplicitValueModification(
215+
padding)));
210216
padding = createPaddingBytes(paddingValue);
211217
padding[i] ^= 0x8; // flip middle padding byte
212218
// middle bit
213219
vectorList.add(new TrippleVector("InvPadInvMac-[" + i + "]x08-" + applicationLength + "-" + paddingValue,
214-
new ByteArrayExplicitValueModification(new byte[applicationLength]), new ByteArrayXorModification(
215-
new byte[] { 0x01 }, 0), new ByteArrayExplicitValueModification(padding)));
220+
"InvPadInvMacMid" + i, new ByteArrayExplicitValueModification(new byte[applicationLength]),
221+
new ByteArrayXorModification(new byte[] { 0x01 }, 0), new ByteArrayExplicitValueModification(
222+
padding)));
216223
padding = createPaddingBytes(paddingValue);
217224
padding[i] ^= 0x01; // flip last padding lowest first
218225
// bit
219226
vectorList.add(new TrippleVector("InvPadInvMac-[" + i + "]x01-" + applicationLength + "-" + paddingValue,
220-
new ByteArrayExplicitValueModification(new byte[applicationLength]), new ByteArrayXorModification(
221-
new byte[] { 0x01 }, 0), new ByteArrayExplicitValueModification(padding)));
227+
"InvPadInvMacEnd" + i, new ByteArrayExplicitValueModification(new byte[applicationLength]),
228+
new ByteArrayXorModification(new byte[] { 0x01 }, 0), new ByteArrayExplicitValueModification(
229+
padding)));
222230
}
223231
return vectorList;
224232
}
@@ -237,8 +245,8 @@ private List<ByteArrayXorModification> createFlippedModifications(int byteLength
237245
return modificationList;
238246
}
239247

240-
private PaddingVector createVectorWithPlainData(String name, byte[] plain) {
241-
return new PlainPaddingVector(name,
248+
private PaddingVector createVectorWithPlainData(String name, String identifier, byte[] plain) {
249+
return new PlainPaddingVector(name, identifier,
242250
(ByteArrayExplicitValueModification) ByteArrayModificationFactory.explicitValue(plain));
243251
}
244252
}

0 commit comments

Comments
 (0)