Skip to content

Commit

Permalink
added full filtering for BDS data.
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Mar 3, 2018
1 parent cb1e710 commit cd98322
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions core/src/main/java/org/bouncycastle/pqc/crypto/xmss/XMSSUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamClass;
import java.util.HashSet;
import java.util.Set;

import org.bouncycastle.crypto.Digest;
import org.bouncycastle.util.Arrays;
Expand Down Expand Up @@ -382,6 +384,24 @@ public static boolean isNewAuthenticationPathNeeded(long globalIndex, int xmssHe
private static class CheckingStream
extends ObjectInputStream
{
private static final Set<String> components = new HashSet<>();

static
{
components.add("java.util.TreeMap");
components.add("java.lang.Integer");
components.add("java.lang.Number");
components.add("org.bouncycastle.pqc.crypto.xmss.BDS");
components.add("java.util.ArrayList");
components.add("org.bouncycastle.pqc.crypto.xmss.XMSSNode");
components.add("[B");
components.add("java.util.LinkedList");
components.add("java.util.Stack");
components.add("java.util.Vector");
components.add("[Ljava.lang.Object;");
components.add("org.bouncycastle.pqc.crypto.xmss.BDSTreeHash");
}

private final Class mainClass;
private boolean found = false;

Expand Down Expand Up @@ -409,6 +429,14 @@ protected Class<?> resolveClass(ObjectStreamClass desc)
found = true;
}
}
else
{
if (!components.contains(desc.getName()))
{
throw new InvalidClassException(
"unexpected class: ", desc.getName());
}
}
return super.resolveClass(desc);
}
}
Expand Down

1 comment on commit cd98322

@YAOY32
Copy link

@YAOY32 YAOY32 commented on cd98322 Aug 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing the Java Cryptography APIs and XMSS/XMSS^MT Private Key vulnerability.

Please # to comment.