Blame SOURCES/0001-Disallow-EventData-deserialization-by-default.patch

f4d659
From b1c0ca75ca38a7a8b50bfdfdf2c324169a6ddf02 Mon Sep 17 00:00:00 2001
f4d659
From: Michael Simacek <msimacek@redhat.com>
f4d659
Date: Mon, 19 Mar 2018 16:01:57 +0100
f4d659
Subject: [PATCH] Disallow EventData deserialization by default
f4d659
f4d659
---
f4d659
 .../src/main/java/org/slf4j/ext/EventData.java      | 21 +++++++++++++++------
f4d659
 1 file changed, 15 insertions(+), 6 deletions(-)
f4d659
f4d659
diff --git a/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java b/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java
f4d659
index dc5b502..fa5c125 100644
f4d659
--- a/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java
f4d659
+++ b/slf4j-ext/src/main/java/org/slf4j/ext/EventData.java
f4d659
@@ -76,12 +76,21 @@ public class EventData implements Serializable {
f4d659
      */
f4d659
     @SuppressWarnings("unchecked")
f4d659
     public EventData(String xml) {
f4d659
-        ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
f4d659
-        try {
f4d659
-            XMLDecoder decoder = new XMLDecoder(bais);
f4d659
-            this.eventData = (Map<String, Object>) decoder.readObject();
f4d659
-        } catch (Exception e) {
f4d659
-            throw new EventException("Error decoding " + xml, e);
f4d659
+        if ("1".equals(System.getProperty("org.slf4j.ext.allowInsecureDeserialization"))) {
f4d659
+            ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
f4d659
+            try {
f4d659
+                XMLDecoder decoder = new XMLDecoder(bais);
f4d659
+                this.eventData = (Map<String, Object>) decoder.readObject();
f4d659
+            } catch (Exception e) {
f4d659
+                throw new EventException("Error decoding " + xml, e);
f4d659
+            }
f4d659
+        } else {
f4d659
+            throw new UnsupportedOperationException(
f4d659
+                    "Constructing EventData from XML is vulnerable to remote " +
f4d659
+                    "excution and is not allowed by default. If you're " +
f4d659
+                    "completely sure the source data is trusted, you can enable " +
f4d659
+                    "it by setting org.slf4j.ext.allowInsecureDeserialization " +
f4d659
+                    "JVM property to 1");
f4d659
         }
f4d659
     }
f4d659
 
f4d659
-- 
f4d659
2.14.3
f4d659