Clojure: Deserialization of Untrusted Data Allows Remote Code Execution A security advisory reports that Clojure's compiled functions, which implement java.util.Comparator, allow remote code execution through deserialization of untrusted data, reproduced on Clojure 1.10.3, 1.11.1, 1.12.4, 1.12.6, and 1.13.0-alpha11 independent of *read-eval*. The gadget chains a serialized java.util.PriorityQueue whose comparator is clojure.core/apply with elements clojure.core/load-string and a Clojure source string, so a single ObjectInputStream.readObject call executes attacker-supplied code using only classes in clojure.jar and the JDK. The report notes that javap on the 1.12.6 release shows clojure.lang.AFunction still implements java.util.Comparator with the same compare method, meaning the fix does not change that class. Repository navigation Deserialization of Untrusted Data Allows Remote Code Execution This report was submitted with AI assistance Package Affected versions Patched versions Description Summary Compiled Clojure functions implement java.util.Comparator , and AFunction.compare runs the function. A serialized java.util.PriorityQueue whose comparator is clojure.core/apply and whose elements are clojure.core/load-string and a string of Clojure source executes that source during ObjectInputStream.readObject , using only classes in clojure.jar and the JDK. Reproduced on 1.10.3, 1.11.1, 1.12.4, 1.12.6, and 1.13.0-alpha11, independent of read-eval . Details Root cause clojure.lang.AFunction , the base class of every compiled Clojure function, implements java.util.Comparator , and its compare runs the function before interpreting the result: src/jvm/clojure/lang/AFunction.java:18 public abstract class AFunction extends AFn implements IObj, Comparator, Fn, Serializable { src/jvm/clojure/lang/AFunction.java:52-53 public int compare Object o1, Object o2 { Object o = invoke o1, o2 ; // the function executes here ... javap on the 1.12.6 release shows this is unchanged by the fix: bash $ javap -cp clojure-1.12.6.jar clojure.lang.AFunction public abstract class clojure.lang.AFunction extends clojure.lang.AFn implements clojure.lang.IObj, java.util.Comparator, clojure.lang.Fn, java.io.Serializable { public int compare java.lang.Object, java.lang.Object ; Two functions shipped in clojure.jar complete the chain: php src/clj/clojure/core.clj:663-668 apply - . f applyTo seq args src/clj/clojure/core.clj:4136-4144 load-string - load-reader - clojure.lang.Compiler.eval java.util.PriorityQueue is serializable, and its readObject rebuilds the heap with the comparator: php java.util.PriorityQueue.readObject - heapify - siftDownUsingComparator - comparator.compare e0, e1 With comparator = apply and queue = load-string, "