Skip to content

Commit 8318dd3

Browse files
authored
Merge pull request #1860 from fl4via/backport-fixes_2.3.x
[UNDERTOW-2653 / 2605 / 2582 / 2534 / 2609 / 2377 / 2656 / 2674 / 2668] CVE-2024-3884 CVE-2024-4027 CVE-2025-12543 Backport fixes to branch 2.3.x
2 parents 976c5a7 + b58019c commit 8318dd3

49 files changed

Lines changed: 1245 additions & 165 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
fail-fast: false
6060
matrix:
6161
os: [ubuntu-latest, windows-latest, macos-latest]
62-
module: [core]
62+
module: [core, servlet, websockets-jsr]
6363
jdk: [11, 17, 21]
6464
openjdk_impl: [ temurin ]
6565
openssl: [false, true]

build.metadata

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Created by buildmetadata-maven-plugin 1.7.0 ( SHA: 6f444cae )
2+
build.artifactId=undertow-websockets-jsr
3+
build.groupId=io.undertow
4+
build.java.compiler=HotSpot 64-Bit Tiered Compilers
5+
build.java.runtime.name=OpenJDK Runtime Environment
6+
build.java.runtime.version=1.8.0_422-b05
7+
build.java.vendor=Red Hat, Inc.
8+
build.java.vm=OpenJDK 64-Bit Server VM
9+
build.maven.execution.cmdline=-Djavax.net.ssl.trustStore\=/home/aogburn/bin/builder/maven.truststore -Djavax.net.ssl.trustStorePassword\=rhmaven -s /home/aogburn/bin/builder/eap-build-settings.xml clean install -DskipTests
10+
build.maven.version=3.9.6
11+
build.scmRevision.date=17.09.2024
12+
build.scmRevision.id=aaa36f6ad214aecd7d0d611cad582aa058f3a3e8
13+
build.scmRevision.url=scm\:git\://github.com/undertow-io/undertow.git/undertow-websockets-jsr
14+
build.version=2.2.33.SP2-redhat-00001
15+
build.version.full=2.2.33.SP2-redhat-00001raaa36f6ad214aecd7d0d611cad582aa058f3a3e8

core/src/main/java/io/undertow/Handlers.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.undertow.server.handlers.DisableCacheHandler;
3333
import io.undertow.server.handlers.ExceptionHandler;
3434
import io.undertow.server.handlers.GracefulShutdownHandler;
35+
import io.undertow.server.handlers.HostHeaderHandler;
3536
import io.undertow.server.handlers.HttpContinueAcceptingHandler;
3637
import io.undertow.server.handlers.HttpContinueReadHandler;
3738
import io.undertow.server.handlers.HttpTraceHandler;
@@ -600,6 +601,17 @@ public static LearningPushHandler learningPushHandler(int maxEntries, HttpHandle
600601
return new LearningPushHandler(maxEntries, -1, next);
601602
}
602603

604+
/**
605+
* Creates a handler that automatically vets Host header content/absence/presence according to
606+
* https://datatracker.ietf.org/doc/html/rfc7230#section-5.4 and related
607+
*
608+
* @param next The next handler
609+
* @return A host header handler
610+
*/
611+
public static HostHeaderHandler hostHeaderHandler(HttpHandler next) {
612+
return new HostHeaderHandler(next);
613+
}
614+
603615
private Handlers() {
604616

605617
}

core/src/main/java/io/undertow/UndertowLogger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,4 +488,8 @@ void nodeConfigCreated(URI connectionURI, String balancer, String domain, String
488488
@LogMessage(level = WARN)
489489
@Message(id = 5107, value = "Failed to set web socket timeout.")
490490
void failedToSetWSTimeout(@Cause Exception e);
491+
492+
@LogMessage(level = WARN)
493+
@Message(id = 5108, value = "Configuration option is no longer supported: %s.")
494+
void configurationNotSupported(String string);
491495
}

core/src/main/java/io/undertow/UndertowOptions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ public class UndertowOptions {
5151
public static final Option<Long> MULTIPART_MAX_ENTITY_SIZE = Option.simple(UndertowOptions.class, "MULTIPART_MAX_ENTITY_SIZE", Long.class);
5252

5353
/**
54-
* We do not have a default upload limit
54+
* Default maximum upload size 2MB
5555
*/
56-
public static final long DEFAULT_MAX_ENTITY_SIZE = -1;
56+
public static final long DEFAULT_MAX_ENTITY_SIZE = 2097152;
57+
58+
/**
59+
* Default maximum multipart upload size 2MB
60+
*/
61+
public static final long DEFAULT_MULTIPART_MAX_ENTITY_SIZE = 2097152;
5762

5863
/**
5964
* If we should buffer pipelined requests. Defaults to false.

core/src/main/java/io/undertow/attribute/QueryStringAttribute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private QueryStringAttribute(boolean includeQuestionMark) {
4242

4343
@Override
4444
public String readAttribute(final HttpServerExchange exchange) {
45-
String qs = exchange.getQueryString();
45+
String qs = exchange.getDecodedQueryString();
4646
if(qs.isEmpty() || !includeQuestionMark) {
4747
return qs;
4848
}

core/src/main/java/io/undertow/attribute/RequestLineAttribute.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public String readAttribute(final HttpServerExchange exchange) {
4242
.append(exchange.getRequestMethod().toString())
4343
.append(' ')
4444
.append(exchange.getRequestURI());
45-
if (!exchange.getQueryString().isEmpty()) {
45+
if (!exchange.getDecodedQueryString().isEmpty()) {
4646
sb.append('?');
47-
sb.append(exchange.getQueryString());
47+
sb.append(exchange.getDecodedQueryString());
4848
}
4949
sb.append(' ')
5050
.append(exchange.getProtocol().toString()).toString();

core/src/main/java/io/undertow/conduits/FixedLengthStreamSourceConduit.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ private void exitRead(long consumed, Throwable readError) throws IOException {
371371
}
372372
long newVal = oldVal - consumed;
373373
state = newVal;
374+
if (allAreClear(state, MASK_COUNT)) {
375+
if (allAreClear(state, FLAG_FINISHED)) {
376+
next.suspendReads();
377+
}
378+
}
374379
}
375380

376381
private void invokeFinishListener() {

core/src/main/java/io/undertow/security/handlers/SinglePortConfidentialityHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected URI getRedirectURI(final HttpServerExchange exchange, final int port)
6565
}
6666
}
6767
uriBuilder.append(uri);
68-
final String queryString = exchange.getQueryString();
68+
final String queryString = exchange.getDecodedQueryString();
6969
if (queryString != null && !queryString.isEmpty()) {
7070
uriBuilder.append("?").append(queryString);
7171
}

core/src/main/java/io/undertow/security/impl/DigestAuthenticationMechanism.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,17 @@ private AuthenticationMechanismOutcome handleDigestHeader(HttpServerExchange exc
235235
if(parsedHeader.containsKey(DigestAuthorizationToken.DIGEST_URI)) {
236236
String uri = parsedHeader.get(DigestAuthorizationToken.DIGEST_URI);
237237
String requestURI = exchange.getRequestURI();
238-
if(!exchange.getQueryString().isEmpty()) {
239-
requestURI = requestURI + "?" + exchange.getQueryString();
238+
if(!exchange.getDecodedQueryString().isEmpty()) {
239+
requestURI = requestURI + "?" + exchange.getDecodedQueryString();
240240
}
241241
if(!uri.equals(requestURI)) {
242242
//it is possible we were given an absolute URI
243243
//we reconstruct the URI from the host header to make sure they match up
244244
//I am not sure if this is overly strict, however I think it is better
245245
//to be safe than sorry
246246
requestURI = exchange.getRequestURL();
247-
if(!exchange.getQueryString().isEmpty()) {
248-
requestURI = requestURI + "?" + exchange.getQueryString();
247+
if(!exchange.getDecodedQueryString().isEmpty()) {
248+
requestURI = requestURI + "?" + exchange.getDecodedQueryString();
249249
}
250250
if(!uri.equals(requestURI)) {
251251
//just end the auth process

0 commit comments

Comments
 (0)