Skip to content

Commit e99ff8b

Browse files
Protect readLine() against DoS
1 parent fbe7b75 commit e99ff8b

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

flow-server/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@
170170
<version>${hibernate.validator.version}</version>
171171
<scope>test</scope>
172172
</dependency>
173-
173+
<dependency>
174+
<groupId>io.github.pixee</groupId>
175+
<artifactId>java-security-toolkit</artifactId>
176+
</dependency>
174177
</dependencies>
175178
<build>
176179
<resources>

flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunDevBundleBuild.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.vaadin.flow.server.frontend;
1717

18+
import io.github.pixee.security.BoundedLineReader;
1819
import java.io.BufferedReader;
1920
import java.io.File;
2021
import java.io.IOException;
@@ -173,7 +174,7 @@ private void runFrontendBuildTool(String toolName, String executable,
173174
new InputStreamReader(process.getInputStream(),
174175
StandardCharsets.UTF_8))) {
175176
String stdoutLine;
176-
while ((stdoutLine = reader.readLine()) != null) {
177+
while ((stdoutLine = BoundedLineReader.readLine(reader, 5_000_000)) != null) {
177178
logger.debug(stdoutLine);
178179
toolOutput.append(stdoutLine)
179180
.append(System.lineSeparator());

flow-test-util/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
<groupId>junit</groupId>
5757
<artifactId>junit</artifactId>
5858
</dependency>
59+
<dependency>
60+
<groupId>io.github.pixee</groupId>
61+
<artifactId>java-security-toolkit</artifactId>
62+
</dependency>
5963
</dependencies>
6064

6165
<build>

flow-test-util/src/main/java/com/vaadin/flow/testutil/net/LinuxEphemeralPortRangeDetector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package com.vaadin.flow.testutil.net;
1818

19+
import io.github.pixee.security.BoundedLineReader;
1920
import java.io.BufferedReader;
2021
import java.io.File;
2122
import java.io.IOException;
@@ -65,7 +66,7 @@ public static LinuxEphemeralPortRangeDetector getInstance() {
6566
int lowPort = defaultRange.getLowestEphemeralPort();
6667
int highPort = defaultRange.getHighestEphemeralPort();
6768
try (BufferedReader in = new BufferedReader(inputFil)) {
68-
String[] split = in.readLine().split("\\s+", 3);
69+
String[] split = BoundedLineReader.readLine(in, 5_000_000).split("\\s+", 3);
6970
lowPort = Integer.parseInt(split[0]);
7071
highPort = Integer.parseInt(split[1]);
7172
} catch (IOException | NullPointerException ignore) {

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
<failsafe.parallel>all</failsafe.parallel>
147147
<failsafe.threadCount>2</failsafe.threadCount>
148148
<failsafe.perCoreThreadCount>true</failsafe.perCoreThreadCount>
149+
<versions.java-security-toolkit>1.2.1</versions.java-security-toolkit>
149150
</properties>
150151

151152
<repositories>
@@ -280,6 +281,12 @@
280281
<artifactId>hamcrest-all</artifactId>
281282
<version>1.3</version>
282283
</dependency>
284+
<dependency>
285+
<groupId>io.github.pixee</groupId>
286+
<artifactId>java-security-toolkit</artifactId>
287+
288+
<version>${versions.java-security-toolkit}</version>
289+
</dependency>
283290
</dependencies>
284291
</dependencyManagement>
285292

0 commit comments

Comments
 (0)