Use ObjectInputFilter when deserializing fate objects.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 487
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 13
Description
**Describe the bug**
Fate uses java serialization w/o any validation of the java objects read from persistent storage. Starting with Java 9 there is a new mechanism that could be used to validate object prior to deserialization.
The following is a diff for a quick experiment I did that did not work. With the following change a sunny day IT would not run and the manager logs were full of errors. So the following is probably too strict, did not look into why it was failing.
```diff
diff --git a/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java b/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java
index da8572c7cb..b8a44e62f8 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java
@@ -25,6 +25,7 @@ import static org.apache.accumulo.core.util.UtilWaitThread.sleepUninterruptibly;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.ObjectInputFilter;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -87,6 +88,13 @@ public class ZooStore implements TStore {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(ser);
ObjectInputStream ois = new ObjectInputStream(bais);
+ ois.setObjectInputFilter(filterInfo -> {
+ var clazz = filterInfo.serialClass();
+ if(clazz != null && clazz.getName().startsWith("org.apache.accumulo")){
+ return ObjectInputFilter.Status.ALLOWED;
+ }
+ return ObjectInputFilter.Status.REJECTED;
+ });
return ois.readObject();
} catch (Exception e) {
throw new RuntimeException(e);
```
**Expected behavior**
Fate deserialization only works with a narrow set of types.
Contributor guide
Research direction
Start in core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java at ObjectInputStream construction and readObject, then review the Java ObjectInputFilter behavior against the serialized Fate types. Use the sunny day IT as the regression check; done means Fate deserialization accepts its narrow required type set without the manager errors described in the experiment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100