Class ObjectInputStreamWithClassloader
java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
org.jgroups.util.ObjectInputStreamWithClassloader
- All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable
Override
). To harden this
against unsafe deserialization (gadget-chain) attacks, a
): on
a JVM that doesn't support it,
ObjectInputStream.resolveClass(java.io.ObjectStreamClass) using the passed-in
classloader.
This is the single point through which all JGroups Java-serialization based deserialization goes, both for
RPC calls (e.g. MethodCall arguments/return values, via Util.objectFromStream(DataInput)
and Util.objectFromByteBuffer(byte[])) and for state-transfer / replicated-map marshalling (e.g.
ReplicatedHashMap,
invalid reference
org.jgroups.blocks.PartitionedHashMap
java.io.ObjectInputFilter (JEP 290) can be
configured process-wide via the Global.DESERIALIZATION_FILTER system property; it is then applied to
every stream created here.
java.io.ObjectInputFilter only exists since Java 9, but this module still targets Java 8, so the API
is accessed via reflection (same technique already used for e.g. Loom fibers in
invalid reference
Util#createFiber
FILTER stays null and filtering is simply skipped. Like every
other jgroups.* system property in this codebase (see the static initializer in Util), the
property is read once, when this class is loaded - it's not re-checked per stream. To change it, set it on the
command line (or otherwise before JGroups classes are loaded), not at runtime.- Since:
- 3.5
- Author:
- Bela Ban
-
Nested Class Summary
Nested classes/interfaces inherited from class ObjectInputStream
ObjectInputStream.GetField -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Objectprotected final ClassLoaderprotected static final Logprotected static final MethodFields inherited from interface ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedObjectInputStreamWithClassloader(InputStream in, ClassLoader loader) protected -
Method Summary
Methods inherited from class ObjectInputStream
available, close, defaultReadObject, enableResolveObject, getObjectInputFilter, read, read, readBoolean, readByte, readChar, readClassDescriptor, readDouble, readFields, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readObjectOverride, readShort, readStreamHeader, readUnshared, readUnsignedByte, readUnsignedShort, readUTF, registerValidation, resolveObject, resolveProxyClass, setObjectInputFilter, skipBytesMethods inherited from class InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferToMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ObjectInput
read, skip
-
Field Details
-
log
-
SET_FILTER
-
FILTER
-
loader
-
-
Constructor Details
-
ObjectInputStreamWithClassloader
- Throws:
IOException
-
ObjectInputStreamWithClassloader
- Throws:
IOException
-
ObjectInputStreamWithClassloader
- Throws:
IOExceptionSecurityException
-
ObjectInputStreamWithClassloader
protected ObjectInputStreamWithClassloader(ClassLoader loader) throws IOException, SecurityException - Throws:
IOExceptionSecurityException
-
-
Method Details
-
resolveClass
- Overrides:
resolveClassin classObjectInputStream- Throws:
IOExceptionClassNotFoundException
-
applyFilter
protected void applyFilter()Applies theFILTERbuilt above tothisstream, i.e. the reflective equivalent ofthis.setObjectInputFilter(FILTER).SET_FILTERis only non-null on a JVM that actually hasObjectInputStream.setObjectInputFilter()(Java 9+) and a valid pattern was configured; on Java 8, or when the property is unset, this is a no-op.
-