@@ -42,6 +42,7 @@ public final class SafeObjectInputStream extends ObjectInputStream {
4242 "\\ [Z" , "\\ [B" , "\\ [S" , "\\ [I" , "\\ [J" , "\\ [F" , "\\ [D" , "\\ [C" ,
4343 "java..*" , "sun.util.calendar..*" , "org.apache.ofbiz..*" ,
4444 "org.codehaus.groovy.runtime.GStringImpl" , "groovy.lang.GString" };
45+ private static final String [] DEFAULT_DENYLIST = { "rmi" , "<" };
4546
4647 /** The regular expression used to match serialized types. */
4748 private final Pattern allowlistPattern ;
@@ -53,9 +54,9 @@ public final class SafeObjectInputStream extends ObjectInputStream {
5354 */
5455 public SafeObjectInputStream (InputStream in ) throws IOException {
5556 super (in );
56- String safeObjectsProp = getPropertyValue ("SafeObjectInputStream" , "ListOfSafeObjectsForInputStream " , "" );
57- String [] allowlist = safeObjectsProp .isEmpty () ? DEFAULT_ALLOWLIST_PATTERN : safeObjectsProp .split ("," );
58- allowlistPattern = Arrays .stream (allowlist )
57+ String allowListProp = getPropertyValue ("SafeObjectInputStream" , "allowList " , "" );
58+ String [] allowList = allowListProp .isEmpty () ? DEFAULT_ALLOWLIST_PATTERN : allowListProp .split ("," );
59+ allowlistPattern = Arrays .stream (allowList )
5960 .map (String ::trim )
6061 .filter (str -> !str .isEmpty ())
6162 .collect (collectingAndThen (joining ("|" , "(" , ")" ), Pattern ::compile ));
@@ -65,9 +66,13 @@ public SafeObjectInputStream(InputStream in) throws IOException {
6566 protected Class <?> resolveClass (ObjectStreamClass classDesc ) throws IOException , ClassNotFoundException {
6667 String className = classDesc .getName ();
6768 // DenyList
68- if (className .contains ("java.rmi" ) // Don't allow RMI
69- || className .contains ("<" )) { // Prevent generics markup in string type names
70- throw new InvalidClassException (className , "Unauthorized deserialisation attempt" );
69+ String rejectedObjectsProp = getPropertyValue ("security" , "denyList" , "" );
70+ String [] denyList = rejectedObjectsProp .isEmpty () ? DEFAULT_DENYLIST : rejectedObjectsProp .split ("," );
71+ // For now DEFAULT_DENYLIST: don't allow RMI, prevent generics markup in string type names
72+ for (String deny : denyList ) {
73+ if (className .contains (deny )) {
74+ throw new InvalidClassException (className , "Unauthorized deserialisation attempt" );
75+ }
7176 }
7277 if (!allowlistPattern .matcher (className ).find ()) {
7378 Debug .logWarning ("***Incompatible class***: " + className
0 commit comments