Skip to content

Commit cd98322

Browse files
committed
added full filtering for BDS data.
1 parent cb1e710 commit cd98322

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

core/src/main/java/org/bouncycastle/pqc/crypto/xmss/XMSSUtil.java

+28
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.io.ObjectInputStream;
99
import java.io.ObjectOutputStream;
1010
import java.io.ObjectStreamClass;
11+
import java.util.HashSet;
12+
import java.util.Set;
1113

1214
import org.bouncycastle.crypto.Digest;
1315
import org.bouncycastle.util.Arrays;
@@ -382,6 +384,24 @@ public static boolean isNewAuthenticationPathNeeded(long globalIndex, int xmssHe
382384
private static class CheckingStream
383385
extends ObjectInputStream
384386
{
387+
private static final Set<String> components = new HashSet<>();
388+
389+
static
390+
{
391+
components.add("java.util.TreeMap");
392+
components.add("java.lang.Integer");
393+
components.add("java.lang.Number");
394+
components.add("org.bouncycastle.pqc.crypto.xmss.BDS");
395+
components.add("java.util.ArrayList");
396+
components.add("org.bouncycastle.pqc.crypto.xmss.XMSSNode");
397+
components.add("[B");
398+
components.add("java.util.LinkedList");
399+
components.add("java.util.Stack");
400+
components.add("java.util.Vector");
401+
components.add("[Ljava.lang.Object;");
402+
components.add("org.bouncycastle.pqc.crypto.xmss.BDSTreeHash");
403+
}
404+
385405
private final Class mainClass;
386406
private boolean found = false;
387407

@@ -409,6 +429,14 @@ protected Class<?> resolveClass(ObjectStreamClass desc)
409429
found = true;
410430
}
411431
}
432+
else
433+
{
434+
if (!components.contains(desc.getName()))
435+
{
436+
throw new InvalidClassException(
437+
"unexpected class: ", desc.getName());
438+
}
439+
}
412440
return super.resolveClass(desc);
413441
}
414442
}

0 commit comments

Comments
 (0)