Skip to content

Commit d1cc57a

Browse files
authored
Merge pull request #85 from d0ge/infinity-loop-at-decompression-fix
Infinity loop at compression fix
2 parents bb55cb1 + 7c10cbb commit d1cc57a

File tree

6 files changed

+45
-25
lines changed

6 files changed

+45
-25
lines changed

BappManifest.bmf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Uuid: c61cfa893bb14db4b01775554f7b802e
22
ExtensionType: 1
33
Name: SAML Raider
44
RepoName: saml-raider
5-
ScreenVersion: 2.1.0
6-
SerialVersion: 18
5+
ScreenVersion: 2.1.1
6+
SerialVersion: 19
77
MinPlatformVersion: 0
88
ProOnly: False
99
Author: Roland Bischofberger / Emanuel Duss / Tobias Hort-Giess
1010
ShortDescription: Provides a SAML message editor and a certificate management tool to help with testing SAML infrastructures.
11-
EntryPoint: build/libs/saml-raider-2.1.0.jar
11+
EntryPoint: build/libs/saml-raider-2.1.1.jar
1212
BuildCommand: ./gradlew jar
1313
SupportedProducts: Pro, Community

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Don't forget to rate our extension with as many stars you like :smile:.
7979
### Manual Installation
8080

8181
First, download the latest SAML Raider version:
82-
[saml-raider-2.1.0.jar](https://github.com/SAMLRaider/SAMLRaider/releases/download/v2.1.0/saml-raider-2.1.0.jar).
82+
[saml-raider-2.1.1.jar](https://github.com/SAMLRaider/SAMLRaider/releases/download/v2.1.1/saml-raider-2.1.1.jar).
8383
Then, start Burp Suite and click in the `Extensions` tab on `Add`. Choose the
8484
SAML Raider JAR file to install it and you are ready to go.
8585

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id "java-library"
33
}
44

5-
version = "2.1.0"
5+
version = "2.1.1"
66

77
repositories {
88
mavenCentral()

src/main/java/application/SamlMessageDecoder.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ public static DecodedSAMLMessage getDecodedSAMLMessage(String message, boolean i
3232
boolean isInflated = true;
3333
boolean isGZip = true;
3434

35-
var httpHelpers = new HTTPHelpers();
36-
37-
try {
38-
byte[] inflated = httpHelpers.decompress(base64Decoded, true);
39-
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
40-
} catch (DataFormatException e) {
41-
isGZip = false;
42-
}
43-
44-
try {
45-
byte[] inflated = httpHelpers.decompress(base64Decoded, false);
46-
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
47-
} catch (DataFormatException e) {
35+
if (base64Decoded.length == 0) {
4836
isInflated = false;
37+
isGZip = false;
38+
} else {
39+
var httpHelpers = new HTTPHelpers();
40+
try {
41+
byte[] inflated = httpHelpers.decompress(base64Decoded, true);
42+
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
43+
} catch (DataFormatException e) {
44+
isGZip = false;
45+
}
46+
try {
47+
byte[] inflated = httpHelpers.decompress(base64Decoded, false);
48+
return new DecodedSAMLMessage(new String(inflated, StandardCharsets.UTF_8), isInflated, isGZip);
49+
} catch (DataFormatException e) {
50+
isInflated = false;
51+
}
4952
}
5053

5154
return new DecodedSAMLMessage(new String(base64Decoded, StandardCharsets.UTF_8), isInflated, isGZip);

src/main/java/helpers/HTTPHelpers.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
public class HTTPHelpers {
1111

12-
/**
13-
* <a href="http://qupera.blogspot.ch/2013/02/howto-compress-and-uncompress-java-byte.html">Source</a>
14-
*/
1512
public byte[] decompress(byte[] data, boolean gzip) throws DataFormatException {
13+
if (data.length == 0) {
14+
return new byte[0];
15+
}
1616
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length)) {
1717
Inflater inflater = new Inflater(gzip);
1818
inflater.setInput(data);
@@ -29,10 +29,10 @@ public byte[] decompress(byte[] data, boolean gzip) throws DataFormatException {
2929
}
3030
}
3131

32-
/**
33-
* <a href="http://qupera.blogspot.ch/2013/02/howto-compress-and-uncompress-java-byte.html">Source</a>
34-
*/
3532
public byte[] compress(byte[] data, boolean gzip) {
33+
if (data.length == 0) {
34+
return new byte[0];
35+
}
3636
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length)) {
3737
Deflater deflater = new Deflater(5, gzip);
3838
deflater.setInput(data);

src/test/java/application/HTTPHelpersTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
import java.util.zip.DataFormatException;
77
import org.junit.jupiter.api.Test;
88

9-
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
import static org.junit.jupiter.api.Assertions.*;
1010

1111

1212
public class HTTPHelpersTest {
13+
1314
HTTPHelpers helpers = new HTTPHelpers();
1415

1516
String compressed = "fVLLasMwEPwVo3siWXb8EI6hNJdAemlCDr0UPdaNwZaEV4J+fh2H0gRKTmJ3NLOzIzUox8GLg/tyMbwDemcRku9xsCgWaEviZIWT2KOwcgQUQYvjy9tB8DUTfnLBaTeQO8pzhkSEKfTOkmS/25LPQmpV6jwtOYNu0zGmc53xrmBpoVVWm7JLNatlVVUkOcOEM3NLZqGZjhhhbzFIG+YWSzcrVq7S+pRmIssF4x8k2QGG3sqwsC4heEHp1WOEAT3FfvQDXGs6OhMHWPuLX3CKt5OvhiWZBTDQyTiEFfp5uP0N6+TmLWpeVEqV3DCjeJ5DV9baZGxub8CAUgagLE2t6oq0zVVYLO6n9tFTb3xD7+Hm9jzHIEPEx+rVGUjOcqY9DxyX2+IYtQZEQtvbhD9R+t8XaH8A";
@@ -29,4 +30,20 @@ public void testDeflate() throws IOException {
2930
assertEquals(compressed, result);
3031
}
3132

33+
@Test
34+
public void testEmptyInflate() throws Exception {
35+
byte[] emptyInput = new byte[0];
36+
byte[] decompressed = helpers.decompress(emptyInput, true);
37+
assertNotNull(decompressed, "Decompressed output should not be null");
38+
assertEquals(0, decompressed.length, "Deompressed output of empty input should be empty");
39+
}
40+
41+
@Test
42+
public void testEmptyDeflate() {
43+
byte[] emptyInput = new byte[0];
44+
byte[] compressed = helpers.compress(emptyInput, true);
45+
assertNotNull(compressed, "Compressed output should not be null");
46+
assertEquals(0, compressed.length, "Compressed output of empty input should be empty");
47+
}
48+
3249
}

0 commit comments

Comments
 (0)