Skip to content

Other loadable copies of a patched class go undetected: META-INF/versions copies in multi-release jars, nested jars in BOOT-INF/lib and WEB-INF/lib, shaded copies #2199

Open

Description

Summary

When a patch replaces a class in a jar, other copies of the same class that the JVM can load are not detected:

  • META-INF/versions/<n>/ copies in a multi-release jar (a Java 9+ runtime loads the versioned copy, not the base one);
  • the same classes relocated or copied into another artifact (shaded/uber jars);
  • nested jars under BOOT-INF/lib/ (Spring Boot) and WEB-INF/lib/ (war).

I found no handling of META-INF/versions, Multi-Release, WEB-INF or shading under crates/ or docs/. BOOT-INF appears only in a reader test (crates/socket-patch-core/src/patch/jar_members.rs:1225), which shows a fat jar can be read, not that nested jars are discovered or patched. Copies in a declared classifier jar ARE detected today (classifier_unpatched_copy, crates/socket-patch-core/src/vendor/jvm/gradle.rs:502), so the mechanism exists for one kind of copy.

Why this matters

A patched base class with an unpatched META-INF/versions/9 copy leaves the vulnerable code running on every modern JVM while the patch reads as applied. Multi-release jars are common in widely used libraries (for example log4j-api and h2).

Suggested direction

  1. Multi-release: when a record lists a/B.class and the installed jar has META-INF/versions/*/a/B.class that the record does not list, treat it like classifier_unpatched_copy: degrade and withhold VEX. (The patch service should list the versioned copies; this is the client-side check that it did.)
  2. Nested jars: discover BOOT-INF/lib/*.jar and WEB-INF/lib/*.jar in build outputs as places a patched artifact can also live, at least to report them.
  3. Shaded copies: out of reach in general; a note in docs/ecosystems.md would set expectations.

Activity

  1. mikolalysenko commented on Dec 1, 2026

    @mikolalysenko
    Collaborator

    [agent] Claiming this issue. Branch: fix/maven-multi-release-copies.


    Generated by Claude Code

  2. mikolalysenko commented on Dec 2, 2026

    @mikolalysenko
    Collaborator

    [agent] #2411 is merged and covers the multi-release part of this issue. I am releasing the claim; the rest is open for whoever takes it.

    Done by #2411: a patch that changes a/B.class in a multi-release jar is checked against the jar's META-INF/versions/<N>/a/B.class copies. A copy the patch does not list and that does not hold the patched bytes is reported: agent apply fails the package, apply --check and vex do not vouch for it, and vendored mode warns.

    Still open here:

    • Nested jars (BOOT-INF/lib/, WEB-INF/lib/) and shaded or relocated copies of a patched class are not detected. The docs and the contract now say so.
    • Hosted mode does not read the jar at scan time, so scan --mode hosted reports nothing; vex judges a hosted pin's jar only where a local cache holds it.
    • Whole-jar records list no members, so there is nothing to compare.

    One thing for the maintainers from that PR: agent apply exits 1 on every run for an affected patch until a patch that also lists the versioned copy exists. If many published patches are member-keyed patches of multi-release jars, that is worth a count before the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions