resteasy/0001-RESTEASY-2559-Improper-validation-of-response-header.patch
Alexander Scheel dd38accbc5
CVE-2020-1695: Improper validation of response header in MediaTypeHeaderDelegate.java class
Resolves: rh-bz#1845547

Signed-off-by: Alexander Scheel <ascheel@redhat.com>
2020-11-30 09:53:34 -05:00

48 lines
2.0 KiB
Diff

From f58a22382e31c0c4b92e519fa84f701a606981ac Mon Sep 17 00:00:00 2001
From: Bartosz Spyrko-Smietanko <bspyrkos@redhat.com>
Date: Thu, 16 Apr 2020 14:01:17 +0100
Subject: [PATCH] [RESTEASY-2559] Improper validation of response header in
MediaTypeHeaderDelegate.java class
---
.../plugins/delegates/MediaTypeHeaderDelegate.java | 1 +
.../test/mediatype/MediaTypeHeaderTest.java | 14 ++++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/mediatype/MediaTypeHeaderTest.java
diff --git a/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegate.java b/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegate.java
index db0b4d588..b31d4376e 100755
--- a/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegate.java
+++ b/resteasy-jaxrs/src/main/java/org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegate.java
@@ -89,6 +89,7 @@ public class MediaTypeHeaderDelegate implements RuntimeDelegate.HeaderDelegate
case '[':
case ']':
case '=':
+ case '\n':
return false;
default:
break;
diff --git a/testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/mediatype/MediaTypeHeaderTest.java b/testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/mediatype/MediaTypeHeaderTest.java
new file mode 100644
index 000000000..e46f018f7
--- /dev/null
+++ b/testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/mediatype/MediaTypeHeaderTest.java
@@ -0,0 +1,14 @@
+package org.jboss.resteasy.test.mediatype;
+
+import org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate;
+import org.junit.Test;
+
+public class MediaTypeHeaderTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNewLineInHeaderValueIsRejected() {
+ MediaTypeHeaderDelegate delegate = new MediaTypeHeaderDelegate();
+
+ delegate.fromString("foo/bar\n");
+ }
+}
--
2.26.2