-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"On 2026-04-24, Apache MINA released three versions on the same day: 2.0.28, 2.1.11, and 2.2.6. One of them contained a fix for a deserialization filter bypass. The other two shipped the bug.\n\nThe fix had been committed to the 2.0.X branch the day before, in `8b1dadb55`. The maintainer's commit message: \"Added patch regarding whitelist bypassing backported from mina-2.2.X.\" There was no such 2.2.X commit. The fix did not exist on 2.2.X yet. It would not land there for another five days.\n\nCVE-2026-42779 is what we call the gap.\n\n## The filter only inspects classes the JVM has already loaded\n\n`IoBuffer.getObject()` is Apache MINA's helper for pulling a Java-serialized object off the wire. Internally it constructs an `ObjectInputStream` with two overrides: `readClassDescriptor()`, which reads MINA's compact wire format, and `resolveClass()`, which maps an `ObjectStreamClass` back to a runtime `Class`.\n\nMINA's wire format puts a one-byte type tag in front of every class descriptor. Type 0 is \"non-Serializable class, primitive, or array\"; the bytes that follow are the standard Java `ObjectStreamClass` blob, and `readClassDescriptor()` delegates to `super.readClassDescriptor()`. Type 1 is \"Serializable class\"; the bytes that follow are a single UTF string with the class name, and `readClassDescriptor()` calls `Class.forName(name)` directly.\n\nIn November 2024, the MINA maintainers added an allowlist for deserialized class names. The mechanism was the `acceptMatchers` list, configured via `IoBuffer.accept(Class...)`. The intent was the standard one for the deserialization bug class: a callsite says \"I expect HashMap and Date here,\" and the filter rejects anything else. The same November commit added the allowlist on all three live branches: `f9cc5ada6` on 2.2.X, `cdb59eb61` on 2.1.X, and `834396355` on 2.0.X. All three commits added the same filter logic. All three filter logics had the same bypass.\n\nHere is the `resolveClass` Apache MINA 2.2.6 shipped, lifted unedited from `AbstractIoBuffer.java`:\n\n```java\nprotected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {\n Class clazz = desc.forClass();\n\n if (clazz == null) {\n String name = desc.getName();\n\n try {\n return Class.forName(name, false, classLoader);\n } catch (ClassNotFoundException ex) {\n return super.resolveClass(desc);\n }\n } else {\n boolean found = false;\n String className = desc.getName();\n\n for (ClassNameMatcher matcher : acceptMatchers) {\n if (matcher.matches(className)) {\n found = true;\n break;\n }\n }\n\n if (found) {\n return clazz;\n }\n\n throw new ClassNotFoundException();\n }\n}\n```\n\nRead it at face value. There is one branch that calls `Class.forName(name)` without consulting `acceptMatchers`, and one branch that consults `acceptMatchers` and returns a class the JVM has already resolved.\n\n`ObjectStreamClass.forClass()` returns a non-null value when the JVM has already loaded the class for that descriptor. It returns null otherwise. The branch that consults the filter is the one where the JVM has already resolved the class. The branch that loads new classes is the one without the filter.\n\nThe acceptMatchers list rejects nothing.\n\n## The exploit primitive is one byte\n\nThe PoC's `craftPayload` function is fifteen lines:\n\n```java\nstatic byte[] craftPayload(Object obj) throws Exception {\n ByteArrayOutputStream baos = new ByteArrayOutputStream();\n\n try (ObjectOutputStream oos = new ObjectOutputStream(baos) {\n @Override\n protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException {\n // ATTACK: write type 0 (non-Serializable path) for ALL classes\n write(0);\n super.writeClassDescriptor(desc);\n }\n }) {\n oos.writeObject(obj);\n oos.flush();\n }\n\n byte[] objData = baos.toByteArray();\n\n ByteArrayOutputStream minaStream = new ByteArrayOutputStream();\n DataOutputStream dos = new DataOutputStream(minaStream);\n dos.writeInt(objData.length);\n dos.write(objData);\n\n return minaStream.toByteArray();\n}\n```\n\nThe attacker writes a 0 byte before every class descriptor. That byte makes MINA's `readClassDescriptor()` take the type-0 branch and hand off to `super.readClassDescriptor()`. Java's stock parser builds an `ObjectStreamClass` from the descriptor bytes; that `ObjectStreamClass` has not been bound to a runtime class yet, so its `forClass()` returns null. `resolveClass()` sees the null, falls into the no-filter branch, and calls `Class.forName(name, false, classLoader)`. The class loads.\n\nThe attacker names a Commons Collections gadget chain. The CC6 variant the PoC ships is the canonical one, `HashSet -> TiedMapEntry -> LazyMap -> ChainedTransformer -> Runtime.exec()`. None of those classes are on any reasonable application's accept list. None of them need to be.\n\nThe HashSet's `readObject` calls `add()`, which calls `hashCode()` on its key, which is the TiedMapEntry. TiedMapEntry's `hashCode` resolves the value from the LazyMap. LazyMap, on a missing key, fires the ChainedTransformer. The chain calls `Runtime.getRuntime().exec(cmd)`.\n\nThat is the entire exploit. Network access to a MINA endpoint that calls `IoBuffer.getObject()`, Commons Collections (or any equivalent gadget library) on the classpath, and one byte per class.\n\n## What runs MINA\n\n`IoBuffer.getObject()` is reachable from any application using MINA's `ObjectSerializationCodecFactory`, the codec that says \"this protocol speaks Java-serialized objects on the wire.\" That is the default codec for protocols that carry Java objects directly. Apache Directory Server uses MINA for LDAP transport. Apache SSHD uses MINA for the SSH transport layer. Apache FtpServer uses MINA. Apache Vysper used MINA for XMPP. Inside enterprise stacks, MINA is a common transport substrate for service buses and game servers, places where one process puts objects on the wire and another process pulls them off without anyone re-considering whether the object payload is trusted. The CVE record affects every one of those that uses `getObject()` or `ObjectSerializationCodecFactory` against untrusted clients.\n\nThe previous CVE in this code, CVE-2026-41635, fixed by the same Apache PMC advisory thread, was the one where there was no filter at all. The November 2024 commits closed CVE-2026-41635 by adding `acceptMatchers`. CVE-2026-42779 is what happens when the filter that closed the prior CVE is itself bypassable. The two CVE numbers cover the same function across two refactors. The patch for the first CVE introduced the bug the second CVE describes.\n\n## The patch is small. It shipped on the wrong branches.\n\nThe fix is the obvious one. Pull the filter check out of the `clazz != null` branch and put it at the top, before either `Class.forName` call:\n\n```java\nprotected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {\n String className = desc.getName();\n\n // apply acceptMatchers filter before any Class.forName() call,\n // regardless of whether forClass() is null or not\n if (!acceptMatchers.stream().anyMatch(m -> m.matches(className))) {\n throw new ClassNotFoundException(\"Class not in accept list \" + className);\n }\n\n Class clazz = desc.forClass();\n\n if (clazz != null) {\n return clazz;\n }\n\n try {\n return Class.forName(className, false, classLoader);\n } catch (ClassNotFoundException ex) {\n return super.resolveClass(desc);\n }\n}\n```\n\nThat diff was committed to the 2.0.X branch on 2026-04-23 in `8b1dadb55`. The commit message: \"Added patch regarding whitelist bypassing backported from mina-2.2.X.\" There was no such 2.2.X commit. The fix did not exist on 2.2.X yet. The maintainer wrote \"backported from mina-2.2.X\" while applying the only known instance of the fix to a different branch entirely.\n\nThe next day, 2026-04-24, three releases went out. 2.0.28 contained `8b1dadb55`. 2.1.11 and 2.2.6 did not.\n\nThe same diff finally landed on the 2.1.X branch on 2026-04-29 as `ba8c355d8`, and on the 2.2.X branch the same day as `cca24d646`. Both commit messages: \"Added a missing fix.\" 2.1.12 and 2.2.7 went out the same day.\n\nThis is a backport gap, the shape where a coordinated multi-branch release ships the security fix on one branch and ships the unfixed code on the others. For five days, anyone running the latest stable from the 2.1 or 2.2 branch was knowingly vulnerable. The advisory the Apache PMC published on 2026-05-01 lists 2.0.0 through 2.0.27 as fixed in 2.0.28, 2.1.0 through 2.1.11 as fixed in 2.1.12, and 2.2.0 through 2.2.6 as fixed in 2.2.7. The advisory does not mention that 2.1.11 and 2.2.6 are five days old. They were released as part of the same coordinated push that fixed 2.0.28.\n\n## The patch ships with two TODOs\n\nEven after the missing fix landed, the file retains evidence the maintainer knew more than the patch reflects.\n\nThe type-1 branch of `readClassDescriptor()` in 2.2.7:\n\n```java\ncase 1: // Serializable class\n String className = readUTF();\n\n // Only accept classes that are listed as acceptable\n // Apply class filter BEFORE calling Class.forName\n if (!acceptMatchers.stream().anyMatch(m -> m.matches(className))) {\n throw new ClassNotFoundException(\"Class not in accept list \" + className);\n }\n\n // Use initialize=false to prevent static block execution during class loading\n Class clazz = Class.forName(className, true, classLoader);\n```\n\nThe comment names the threat. `Class.forName`'s second argument is the `initialize` flag; `false` skips static initializers, `true` runs them. Static initializers are a known deserialization gadget vector because class loading alone can be a side-effect surface. The maintainer noted this in a comment.\n\nThe line below the comment passes `true`.\n\nThe 2024-11-06 commit that introduced the acceptMatchers feature for the first time left a different testimony. Before the patch, `AbstractIoBuffer.java` carried these lines:\n\n```java\nString[] classes = new String[] {\"java.util.Date\", \"long\", \"java.util.ArrayList\"};\n// ...\n//((ValidatingObjectInputStream)in).accept(Date.class, long.class, ArrayList.class);\nreturn in.readObject();\n```\n\n`ValidatingObjectInputStream` is Apache Commons IO's correctly-implemented allowlisting deserializer. It applies the filter at the right layer. The MINA maintainer had the import in the file and the call written on a line, then commented the line out, then committed that commented line. It sat in `AbstractIoBuffer.java` for years. The November 2024 commit that introduced acceptMatchers did not uncomment the line. It deleted the line, and shipped a homegrown filter in its place. The homegrown filter is the one we have been reading.\n\nThis is the [Todo That Shipped](/patterns/todo-that-shipped) shape, recurring twice in the same function. The first instance was the commented-out call to a working library that would have prevented the bug class entirely. The second instance is the comment in the 2.2.7 patch promising a behavior the line below it does not implement. The codebase wrote both sentences before the attacker did.\n\n## The quiet part\n\nThe acceptMatchers list is a list of class names. The bypass works on classes whose names the filter has never seen. Adding more class names to your accept list does not help.\n\nThere is no allowlist of `Class.forName` callsites. There is no allowlist of `resolveClass` branches. The 2.2.7 patch closes one of them. The fallback at the end of the fixed function still calls `super.resolveClass(desc)`, which still calls `Class.forName` against the same descriptor with no filter check. It just inherits the JVM's behavior, which is to load whatever was named.\n\nThe patch closes the bypass that this CVE is about. The pattern the bypass exploited, \"we wrote a filter that runs after the load that mattered,\" is one bug, two branches, two TODOs, and one library-that-already-solves-this commented out for years before the patch deleted it without uncommenting. The fix was already in the codebase on 2026-04-23. The release engineer who cut 2.1.11 and 2.2.6 the next day did not know they needed it, or knew and did not have the commit, or had the commit and did not pick it. The CVE record cannot tell those three states apart. Neither can we.\n\nPoC: [dinosn/CVE-2026-42779](https://github.com/dinosn/CVE-2026-42779)","closing_line":"The fix was in the codebase on 2026-04-24. Two branches shipped that day without it. The window was five days, and the commit message labeled the fix a backport of itself.","hook_md":"On 2026-04-24, Apache MINA released three versions on the same day: 2.0.28, 2.1.11, and 2.2.6. One of them contained a fix for a deserialization filter bypass. The other two shipped the bug.\n\nThe fix had been committed to the 2.0.X branch the day before, in `8b1dadb55`. The maintainer's commit message: \"Added patch regarding whitelist bypassing backported from mina-2.2.X.\" There was no such 2.2.X commit. The fix did not exist on 2.2.X yet. It would not land there for another five days.\n\nCVE-2026-42779 is what we call the gap.","post_id":80,"slug":"mina-fix-shipped-on-one-branch","title":"CVE-2026-42779: Apache MINA Shipped the Fix on One Branch. The Same Day, Two Other Branches Shipped the Bug.","type":"initial","unreadable_sentence":"The branch that consults the filter is the one where the JVM has already resolved the class. The branch that loads new classes is the one without the filter."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCale+kgAKCRDeZjl4jgkQ Jn8CAQCQ+Cw1YVcDAcYf430ZaaWLvsX91jicy5uBz1xE5Uwl1QEA94t0R1v4jROk xlqjI+7lsvyygKM6Swa7AnpSo8Mt/w8= =UzZC -----END PGP SIGNATURE-----