Skip to content

Vendored Maven reports applied and vex attests not_affected for a dependency declared as the hard range [1.0]: the pin goes into <dependencyManagement>, Maven does not apply it, and the build keeps the unpatched jar #2378

In review

Description

[agent] Found by the architecture refactor routine on main at cfc870f, with real Maven 3.9.11 on JDK 21.

The problem

A Maven project can declare a dependency as a hard requirement, <version>[1.0]</version>: "this version and no other". When the patched package is declared that way, vendored mode leaves the declaration alone and writes its pin into <dependencyManagement> instead. Maven does not apply managed versions to a declaration that has a version of its own, so the build goes on resolving the upstream jar. All the same:

  • socket-patch vendor exits 0 with status: success and summary.applied: 1. Its one note says the declaration "is left as is, probably unpatched".
  • socket-patch vendor --check exits 0: "committed artifact and wiring verified".
  • socket-patch vex exits 0 and attests not_affected ("Patched via Socket patch … (vendored)") for a product whose build has the unpatched jar on its classpath.

It happens with a single pom.xml and in a reactor, where the module with the hard range stays unpatched beside siblings that are patched. scan --mode vendored and get --mode vendored vendor "via the same engine as the vendor command" (the contract's words), so they are affected too; I ran vendor.

The contract's row for the note is vendor_jvm_degraded | "applied, VEX withheld". docs/design/maven-vendoring.md (lines 125 to 128) says: "Range selectors, unresolved properties, classifier declarations, conflicting explicit versions and publishing POMs produce specific warnings; the backend does not silently claim those unsupported declarations are patched."

The same hole was closed for the neighbouring cases one at a time: an unresolved ${property} (#513, #459; a9d2312 and c07af61), a module left at the base version (#584; b291caa), and the liveness check as a whole (2abbdc7, #2006). The range branch sits between those branches and was not touched. It dates from the v5 consolidation (2463257, 2026-10-01) and reads the same at the v5.1.0 tag (read there, not built).

Other ranges are handled: [1.0,2.0), [1.0,) and (,1.0] get a second note (selection_undetermined), and vex then refuses with "the patch … is not wired in every module that resolves it". Hosted mode refuses the hard range outright (below). So this is the vendored planner and the single-version range.

Evidence

All runs use the binary built from main, the reactor fixture of crates/socket-patch-cli/tests/vendor_jvm_cli.rs (a local repository holding org.example:foo:1.0, an agent record of a patch for it, and that suite's vendor-service fixture), and a real mvn with a private local repository for each project.

One pom

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.x</groupId><artifactId>agg</artifactId><version>1</version>
  <dependencies>
    <dependency><groupId>org.example</groupId><artifactId>foo</artifactId><version>[1.0]</version></dependency>
  </dependencies>
</project>
$ socket-patch vendor --json                     # exit 0
status: "success", summary.applied: 1
events: applied
        skipped  vendor_jvm_degraded  "reason: range: pom.xml:5: org.example:foo version [1.0] is left as is, probably unpatched"

$ socket-patch vendor --check                    # exit 0
pkg:maven/org.example/foo@1.0: committed artifact and wiring verified

$ socket-patch vex --product pkg:maven/com.x/agg@1      # exit 0
Warning: pom.xml: org.example:foo carries the Socket version {"1.0-socket.1d3c1fd2"} but Maven resolves {"[1.0]"} (a direct <version> overrides <dependencyManagement>)
Warning: pkg:maven/org.example/foo@1.0: the installed tree does not match its vendored artifact; […] re-run your package manager's install to resync it.    # the control prints this one too
Emitted 1 VEX statement
  "status": "not_affected", "justification": "inline_mitigations_already_exist",
  "impact_statement": "Patched via Socket patch 1d3c1fd2-… (vendored)",
  "products": [{"@id": "pkg:maven/com.x/agg@1", "subcomponents": [{"@id": "pkg:maven/org.example/foo@1.0"}]}, …]

$ mvn -o dependency:build-classpath -Dmdep.outputFile=cp.txt   # Maven 3.9.11
$ tr ':' '\n' < cp.txt | grep foo
…/org/example/foo/1.0/foo-1.0.jar                # the upstream jar

vex prints the truth in its first warning and attests anyway: the lockfile discovery drops the pin, and the vendor ledger's entry carries the statement.

What the run wrote into pom.xml: a <dependencyManagement> entry for org.example:foo at 1.0-socket.1d3c1fd2 and the socket-patch-vendor repository. The [1.0] line is untouched. The control, the same pom with <version>1.0</version>, has that line rewritten, and Maven resolves foo-1.0-socket.1d3c1fd2.jar.

A reactor

An aggregator with modules a and b, foo declared in each. Each row is one project; the last two columns are what real Maven puts on each module's classpath.

a declares b declares vendor vex Maven: a Maven: b
1.0 1.0 applied not_affected patched patched
[1.0] 1.0 applied, the range note not_affected foo-1.0.jar patched
[1.0] (no module b) applied, the range note not_affected foo-1.0.jar
[1.0] no version; the root manages 1.0 applied, the range note not_affected foo-1.0.jar patched
${foo.version}, the root sets it to [1.0] 1.0 applied, the range note not_affected foo-1.0.jar patched
[1.0] and bar:1.0, which depends on foo:1.0 1.0 applied, the range note not_affected foo-1.0.jar patched
[1.0,2.0), [1.0,) or (,1.0] 1.0 applied, range and selection_undetermined refuses, exit 1 patched

vendor --check exits 0 in every row. In the third row no module of the project builds with the patch.

The same declaration in hosted mode

The bench's Maven project (socket-patch-bench serve maven/hosted) with its patched dependency declared as <version>[3.3.7]</version>:

$ socket-patch scan                              # exit 0, nothing written
Switched 0 packages to hosted patches; rewrote 0 files.
No patches could be switched to hosted:
  pkg:maven/io.midadi2/bech2-client@3.3.7: no lockfile entry pinning it could be rewritten (see the warning below)
Warning: io.midadi2:bech2-client <version>[3.3.7]</version> matches neither the base (3.3.7) nor the suffixed (3.3.7-socket.07ea3d34) version; skipping

A unit test

A throwaway test beside an_uncertain_module_beside_a_rewritten_one_is_not_attestable (core vendor/jvm/maven_reactor.rs), with that test's helpers and one changed line, fails on main:

#[test]
fn probe_a_hard_range_module_is_not_attestable() {
    let files = fs(&[
        ("pom.xml", ROOT),
        ("a/pom.xml", &module("a", &dep("[1.10.0]"))),
        ("b/pom.xml", &module("b", &dep("1.10.0"))),
    ]);
    let (_, after) = vendor(&files);
    assert_eq!(text(&after, "b/pom.xml"), module("b", &dep(SV)));
    assert_eq!(text(&after, "a/pom.xml"), module("a", &dep("[1.10.0]")));
    assert_eq!(attestable(&after), (true, false), "beside a rewritten sibling: (wired, attestable)");
}
$ cargo test -p socket-patch-core --lib -- probe_a_hard_range_module_is_not_attestable
assertion `left == right` failed: beside a rewritten sibling: (wired, attestable)
  left: (true, true)
 right: (true, false)

Where

All in core vendor/jvm/maven_reactor.rs:

  • rewrite_declarations, lines 2951 to 2955: the range branch pushes the range note and nothing else. The branches around it that leave a declaration alone also record it as uncertain and, where the root's pin cannot reach it, leave the root unpinned (uncertain.insert(at) at lines 2849, 2871, 2886, 2909, 2937 and 3098; unpinned.insert(root) beside four of them).
  • unattestable_in (line 946) is what vex asks. It fails for a declaration in uncertain, so it passes here.
  • covers (line 1646) counts a module as wired when the nearest management on its chain holds the suffixed version. It does not look at a version the module's own declaration carries, which Maven reads first. unwired_in (line 1690) therefore finds nothing open.
  • refuse_unwired (line 820) refuses a plan when no pom would name the suffixed version (Vendored Maven reactor reports applied and VEX attests not_affected when a ${property} version is left unresolved, so the build keeps Central's unpatched jar (also triggered by Maven 4 <parent/> inference) #513). The pin in <dependencyManagement> names it, so the project whose only declaration is [1.0] is not refused. UNWIRING (line 803) already lists range among the reasons that leave a declaration alone.

Planned fix

One rule for a declaration the planner leaves at a version Maven reads before any pin: it is uncertain, whatever the reason. In the range branch, record the declaration in uncertain when the range admits the base version, as the property branches do, and have covers treat a module's own explicit version as beating management. Then vex withholds the statement with the reason it already has for the other cases, and a project in which no declaration reads the pin is refused by refuse_unwired as an unresolved property is, instead of being reported as applied. Tests: the unit test above, its single-declaration twin through refuse_unwired, and a row in tests/vendor_jvm_cli.rs for vendor, vendor --check and vex.

One point for a maintainer: a hard range names one version exactly, so [1.0] could instead be rewritten to [1.0-socket.<hex8>] like a plain 1.0, which would patch the module instead of declining it. The contract's "a declaration that names the base version is rewritten" could be read either way, and hosted mode declines today. The fix above does not need that answer; it only stops the false statement.

How to reproduce

The runs above came from two throwaway #[ignore] tests appended to crates/socket-patch-cli/tests/vendor_jvm_cli.rs (never committed). Each builds the suite's fixture(root, Shape::Reactor, &[("foo", FOO_UUID)]), replaces the poms with one row of the table, runs spawn(root, &["vendor"], true), vendor --check and vex --product pkg:maven/com.x/agg@1, and keeps the directory.

For the transitive row, add to the fixture's local repository org/example/bar/1.0/bar-1.0.pom (a dependency on org.example:foo:1.0) and a bar-1.0.jar.

Real Maven over each kept project, with the local repository warmed once so that it holds maven-dependency-plugin:

cp -r <warm repository> <root>/repo && cp -r <root>/m2/. <root>/repo/
cd <root>/proj
mvn -q -B -o -Dmaven.repo.local=<root>/repo dependency:build-classpath -Dmdep.outputFile=cp.txt
for f in $(find . -name cp.txt); do echo "$f: $(tr ':' '\n' < $f | grep -o 'foo-[^/]*\.jar')"; done

For the open ranges, the local repository also needs org/example/foo/maven-metadata-local.xml listing 1.0; without it the planner's second note reads "the local Maven repository lists no versions of it", and vex refuses either way.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Nov 30, 2026
  2. added a commit that references this issue on Nov 30, 2026
  3. mikolalysenko commented on Dec 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/2378-maven-hard-range-vex.


    Generated by Claude Code

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

    agent:claimedagent:triagedarch-auditbugpriority:p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions