Diamond Dependencies Fail Open: The Vulnerability Class Hiding in Your Dependency Resolver

A diamond-shaped dependency graph in orange. The bottom node is split into version 1.4, which loaded, and version 2.1, whose edge is broken, above an open red padlock. Title: Diamond Dependencies Fail Open.

Diamond Dependencies Fail Open: The Vulnerability Class Hiding in Your Dependency Resolver

TL;DR

  • A diamond dependency conflict can silently remove a security control (a sanitiser, an authentication check, an authorisation check) from a request path at runtime.
  • No single weakness causes it. Version mediation, a breaking change, an error that only surfaces at runtime and a consumer that catches and ignores that error all have to line up. I’m calling the combination dependency mediation fail-open.
  • Package managers settle version conflicts differently, so the winning version can be older or newer than the one a library was built against. The breakage cuts both ways.
  • Errors can be swallowed by catching any ancestor of the error class, or by catching the precise child class, so searching for broad catches alone misses many of them.
  • Software Composition Analysis (SCA) vendors already see the declared tree, the resolved tree and, with reachability, the calls that won’t resolve. Many also sell Static Application Security Testing (SAST), which sees the catch. Nobody joins the evidence, so applications go to production wide open without anyone being warned.
  • You can find it today with open-source tooling: a declared SBOM in SBOM-Graph reveals the diamonds, scarno’s ABI diff shows which calls are at risk (on Maven projects today, with more languages coming), and handler and absence analysis confirms where a control fails open.

In my SBOM-Graph launch post, I described the diamond dependency problem as a source of subtle, maddening runtime failures: two versions of the same library in your graph, one of them dragged in by an upstream pin that nobody ever removed. I now think I undersold it, because under the right conditions it can do something much worse than crash your application. It can quietly remove a security control and let the request carry on as if nothing happened.

In this post I’m going to name it, walk through every link in the chain, show why your tooling doesn’t warn you even though it holds the evidence, and explain how to find it with tools you can run today.

A Composite Weakness Nobody Has Named

What makes this so hard to spot is that no single component is at fault. Every library is free of known CVEs, every repository passes its scans, and every line of code looks reasonable in isolation. The vulnerability only exists when four conditions meet in a running system.

The Common Weakness Enumeration (CWE) already has the vocabulary for this. A composite is two or more distinct weaknesses that must all be present at the same time for a vulnerability to arise. A chain is where one weakness creates the conditions that let the next one become exploitable. What I’m describing is both: a composite of four conditions that plays out as a chain at runtime.

I’ve been through CWE, the OWASP Top 10 and the academic literature on dependency conflicts. Every link in this chain is documented somewhere, and I’ll credit that work as I go, but I haven’t found anyone treating the combination as a vulnerability class. If you know of prior work that does, please tell me and I’ll credit it.

What Is a Diamond Dependency?

Your application depends on two libraries, acme-events and acme-models. Both of them depend on a third library, acme-core, but acme-events was built against acme-core 1.4 and acme-models was built against acme-core 2.1. Draw that graph and you get a diamond: one node at the top, two in the middle and a shared node at the bottom.

This is known as the diamond dependency problem, and it’s as old as package managers. Most runtimes can only load one copy of acme-core, so something has to choose which version wins. That choice is called dependency mediation, and whichever version it picks, one of the two middle libraries ends up running against a version it was never built or tested with.

In a large estate you rarely have one diamond. You have hundreds, spread across transitive dependencies you didn’t choose and may not know exist, and the mediation outcome can change every time someone adds or bumps an unrelated dependency.

How Package Managers Settle the Conflict

Every ecosystem answers the “which version wins?” question differently, and both the depth of a dependency and the order you declare things in can change the answer.

How seven package managers mediate the same diamond, by depth and by declaration order

The same diamond in two shapes. In Maven, depth decides first and declaration order breaks the tie, so reordering two lines in a POM can change the version that loads.

Two things stand out. First, Maven and NuGet can both select an older version than a library asked for. Maven’s own issue tracker describes nearest-wins and declared-first as rules that are likely to produce dependency downgrades and the runtime errors that follow (MNG-7852). NuGet’s documentation says its direct-dependency-wins rule can result in a downgrade that breaks things (NuGet dependency resolution), and it warns you with NU1605. Gradle picks the highest version requested, Go’s minimal version selection never goes below any stated requirement, and pip honours declared ranges within one environment.

Second, Cargo unifies versions within a SemVer-compatible range and builds separate copies across incompatible ones, and npm nests copies by default. Loading two copies avoids this particular failure, but swaps it for others, such as two instances of a library that each keep their own state.

Breaking Changes Cut Both Ways

We usually talk about breaking changes as something that happens when you upgrade. Mediation makes it a two-way street, because the version that wins can sit on either side of the version a library was built against.

Backward, forward and sideways breakage when mediation picks a different version

Backward: the method doesn’t exist yet. Forward: the method no longer exists. Sideways: the method exists but behaves differently.

  • Mediation picks an older version (backward). The library calls a method, class or parameter that was added in a later release. In the version that loaded, it doesn’t exist yet.
  • Mediation picks a newer version (forward). The library calls something that was deprecated and then removed or renamed. In the version that loaded, it no longer exists.
  • Mediation picks a version with the same API but different behaviour (sideways). Nothing is missing, so nothing fails. The method does something subtly different, such as a changed default or a validation step that moved.

The sideways case is the quietest of all. Wang et al. call these semantic conflicts, and their Sensor tool detected 150 such issues in 29 projects, 81.8% of which were confirmed as real bugs.

Semantic Versioning (SemVer) is supposed to protect us from all this, but it’s a promise rather than a guarantee. Microsoft’s own Azure SDK guidance notes that not all libraries strictly follow semantic versioning, and that breaking changes sometimes happen within the same major version.

Runtime, Not Compile Time

In most of the languages we build business applications in, libraries are linked at runtime. Each library was compiled or written against the version it declared, and nothing checks that contract again when a different version is loaded. The failure only appears when execution reaches the call that no longer resolves:

  • Java and the JVM: NoSuchMethodError, NoSuchFieldError, NoClassDefFoundError or AbstractMethodError, all subclasses of LinkageError, which is an Error rather than an Exception.
  • .NET: MissingMethodException, MissingFieldException, TypeLoadException or FileLoadException, all of which derive from System.Exception.
  • Python: ImportError (or its child ModuleNotFoundError), AttributeError, or a TypeError when a signature has changed.
  • JavaScript and TypeScript: TypeError: x is not a function, or undefined where an object was expected.

Important note: Go and Rust are different. Both build every dependency from source, so a missing or renamed API breaks the build rather than the running system, and most of the chain I’m describing can’t form there. The sideways case still applies to them, though, because a semantic difference compiles perfectly well.

Because the failure is tied to a code path, it also hides from testing. If the call that no longer resolves sits in an error handler, an admin flow or a rarely used feature flag, your test suite may never reach it, even though production eventually will.

The Error Lands on the Consumer

Open-source libraries generally don’t handle these errors, and rightly so. A library can’t recover from a missing method in one of its own dependencies, and in Java the platform says as much: an Error indicates serious problems that a reasonable application should not try to catch. So the error travels up the stack until it reaches the code that called the library in the first place: yours.

Now put yourself in the shoes of the engineer who sees it. The stack trace runs deep into the internals of a library they’ve never opened, calling a third library they’ve never heard of. The root cause isn’t in anyone’s code at all; it’s in the resolution metadata of the build. Fixing it properly means understanding mediation, tracing which upstream dependency forced the version, and often coordinating with another team or an upstream maintainer.

With a release deadline looming, the path of least resistance is a try/catch around the call, a log line, and moving on. I don’t blame anyone for doing this. But it’s exactly what CWE describes as CWE-390: Detection of Error Condition Without Action, usually written with CWE-396: Declaration of Catch for Generic Exception, and it’s the category OWASP added to the 2025 Top 10 as A10:2025 Mishandling of Exceptional Conditions.

Parents, Children and the Catch You Can’t See

Here’s where it gets harder to find. Exceptions live in class hierarchies, and a catch block handles the class it names and every class beneath it. So the same NoSuchMethodError can be swallowed by any of five different catch clauses in Java: Throwable, Error, LinkageError, IncompatibleClassChangeError or NoSuchMethodError itself.

Exception hierarchies for Java, .NET and Python, showing which catches swallow a version-mismatch error

Catch any box and you swallow everything beneath it. The broad parents get flagged as code smells; the precise children pass every rule.

That cuts both ways for anyone searching for the problem:

  • Catching a parent swallows more than you think. In .NET and Python the errors derive from the ordinary base exception, so the generic catch (Exception) or except Exception: that developers write every day swallows them without anyone deciding to. In Java you need Throwable or Error, or a framework that catches them for you: plugin loaders, schedulers, message listeners, or a task submitted to an ExecutorService whose Future nobody inspects.
  • Catching the child looks like best practice. A precise catch (NoSuchMethodError e) or except ImportError: is exactly what code reviewers ask for. It passes every “don’t catch generic exceptions” rule, and it’s precisely the pattern a developer writes when they’ve deliberately built a fallback for an older library version.
  • Reflection changes the class entirely. Java’s reflective lookups throw ClassNotFoundException and NoSuchMethodException, which are checked exceptions under ReflectiveOperationException, so a plain catch (Exception e) takes them.
  • Some lookups don’t throw at all. .NET’s Type.GetType(name) returns null when the type isn’t found, Python’s getattr(obj, name, None) and importlib.util.find_spec return None, and JavaScript’s optional chaining (lib.validate?.(x)) quietly returns undefined. There’s no exception to catch, just an absence that the rest of the code has to handle correctly.

So finding swallowed version-mismatch errors means searching for the whole chain of ancestors, the specific children and the absence-returning lookups, not just the broad parents.

The Silent Fail-Open

This is where a reliability bug becomes a security vulnerability. If the call that failed was part of a security control, catching and ignoring the error doesn’t just keep the application running. It keeps it running without the control. CWE already describes the outcome as CWE-636: Not Failing Securely (‘Failing Open’), and notes that it typically comes from wanting to “fail functional” rather than “failing safe”.

Four ways a security control silently drops out when a symbol is missing at runtime

If the error propagates, the request fails closed. If it’s caught, defaulted or skipped, the request carries on without the control.

I’ve found four shapes this takes. The code is illustrative, not lifted from a real incident.

1. The control sits inside the try block

A sanitiser call uses a parameter that only exists in a newer version. Mediation picks an older one, the call throws, and the catch carries on with the raw input.

try:
    safe_html = sanitizer.clean(user_html, strip_comments=True)  # parameter added in a later release
except Exception:
    log.warning("sanitiser failed, continuing")
    safe_html = user_html

2. The catch falls back to an older path

The developer, trying to be helpful, writes a fallback for the older version of the library. The older path predates the check the newer version added.

try {
    return verifier.verify(token, Options.requireAudience(expectedAudience)); // added in 3.x
} catch (NoSuchMethodError e) {
    return verifier.verify(token); // 2.x path: no audience check
}

3. Feature detection returns nothing

This is the quietest form, because nothing is thrown or caught at all. Optional imports, reflective lookups and conditional configuration (such as Spring’s @ConditionalOnClass) only wire in a component if the thing they look for is present. If mediation removes or renames it, the lookup returns nothing, the security configuration never loads and nothing is logged.

validate = getattr(lib, "validate", None)
if validate:
    validate(payload)
# None: the check never runs

4. A filter or middleware fails to start

An authentication or authorisation filter throws during initialisation because of a missing method. A framework built to keep going logs the failure, skips the component and starts the application without it.

A worked example: XML External Entities

The best example I’ve found is hiding in plain sight in the OWASP XML External Entity Prevention Cheat Sheet. Most Java XML parsers have XML External Entity (XXE) processing enabled by default, so you harden them with setFeature calls. The cheat sheet marks the strongest of those features as Xerces 2 only, and notes that if you’re ignoring errors for multi-provider support, each setFeature call should be in its own try/catch. That pattern looks like this:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
    dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (ParserConfigurationException e) {
    logger.info("Feature not supported by your XML processor");
}
// ...the remaining features, each in its own try/catch...
Document doc = dbf.newDocumentBuilder().parse(untrustedInput);

Now add a diamond. An older parser wins mediation, and parsers don’t always support the features newer ones do; the OpenJDK tracker has a case of an old Apache Xerces on the classpath that doesn’t support FEATURE_SECURE_PROCESSING. The hardening call throws, the catch logs it at info level, and the parse runs with DTDs still allowed. The same code that passed your security review is now open to XXE, and the only evidence is an info-level log line.

Compare that with the OpenRewrite XXE recipe, which rethrows the same exception as an IllegalStateException. With the same code and the same diamond, that version fails closed.

The Evidence Is Already in Your Pipeline

I want to be precise here, because it isn’t that the tools can’t see this. The evidence passes through your pipeline on every build. It’s spread across four phases and, often, across products from the same vendor, and nothing joins it up.

How SCA, reachability and SAST each hold one piece of the evidence

Each signal stays in its own report. Joined, they say “verify this control”. Today, nobody says it.

SCA during a source scan sees the declared dependency tree. At this point, before mediation has happened, the diamond is plainly visible: acme-core is requested at 1.4 by one library and at 2.1 by another.

SCA during a build or artefact scan sees the resolved tree. It now knows what mediation chose: 1.4 loaded, 2.1 erased. Put those two scans side by side and you know which libraries are running against a version they didn’t ask for.

Reachability knows which calls won’t resolve. Most of the leading SCA vendors now ship reachability analysis, and the established approach is function-level reachability: building a call graph to decide whether a known vulnerable function is actually called. A call graph built against the resolved version will also contain calls to classes, methods and fields that don’t exist in it. Those calls are the backward and forward breakages from earlier, sitting in the data. Some vendors already analyse whether an upgrade introduces breaking changes before recommending it (Endor Labs, for example), which is the same capability pointed at a different question.

SAST sees the catch. Many of the same vendors sell SAST alongside SCA. Semgrep’s reachability, for example, is built on its SAST engine. A SAST tool can see that the call reachability flagged sits inside a catch that carries on, falls back, or returns a default. That isn’t proof of a vulnerability, but it’s certainly worth a warning.

Are SAST tools ignoring the silencing of linkage errors?

I checked, and the short answer is yes. The rules that exist treat broad catches as a code-quality matter, and none that I could find connects them to dependency versions or to security:

All of these look at the broad parents. None of them fires on a precise catch (NoSuchMethodError e), which is exactly the fallback pattern in shape 2 above, and none of them asks whether the code inside the try is a security control.

Detecting linkage conflicts statically isn’t new either. Google’s Linkage Checker reports linkage errors across a whole classpath, and Spotify’s missinglink, wrapped for sbt by the Scala Center, checks that transitive dependencies don’t exhibit binary compatibility conflicts. These are build-time reliability tools, though, and they don’t look at how your code handles the error.

I’ve raised this directly with SCA vendors. At the time of writing, their tools still don’t highlight it. The result is that applications are going into production with security controls that can silently switch off, and nobody, not the developer, not the AppSec team, not the vendor, has been warned.

Note to SCA and SAST vendors: you already hold every piece of this. Compare the declared and resolved trees, treat the unresolved edges in your reachability call graph as findings in their own right, and check how the calling code handles the failure. Where a library is requested at more than one version, a call won’t resolve in the version that loads, and the code around that call carries on regardless, raise it as a security finding rather than a code-quality note.

Finding It With SBOM-Graph and scarno

Until the vendors join the evidence up, you can do it yourself with two of my open-source tools, SBOM-Graph and scarno, followed by some targeted analysis of your own code.

Step 1: Find the diamonds with a declared SBOM

Most SBOM tooling produces a resolved SBOM: a record of what actually ended up in the build. By then mediation has already happened, the losing version has been erased, and the diamond has gone with it.

A declared SBOM records what each component asked for. Load declared SBOMs into SBOM-Graph and the diamond is still there: acme-events pointing at acme-core 1.4, acme-models pointing at acme-core 2.1. SBOM-Graph’s Diamond Dependency Analysis report (/reports/multi-version-sources/{project}/{version}) shows the scan sources for every version of a conflicting library, so you can trace which upstream dependency is pinning it and which projects are affected across the estate.

Step 2: Find the calls at risk with scarno’s ABI diff

A diamond on its own isn’t a vulnerability; plenty of them are harmless. What you need to know is whether the code actually calls something that differs between the version it declared and the version it will get. For Maven projects (Java and Kotlin), run scarno --deep-inspection against each affected project. It compares the public Application Binary Interface (ABI) of each transitive dependency’s declared version against its resolved version, using javap from a local JDK, and reports two kinds of finding:

  • TS-ABI-RUNTIME-RISK (high): a symbol your code calls has been removed or had its signature changed in the resolved version, so a NoSuchMethodError is likely. These are your backward and forward breakages.
  • TS-ABI-DRIFT (medium): the ABI differs between the declared and resolved versions, but your code doesn’t call the changed symbols.

In the current release, the call-site matching that separates the two isn’t wired in yet, so every difference is reported as TS-ABI-DRIFT. Cross-check the changed symbols against scarno’s per-symbol usage counts to find the ones your code calls.

Where the local artefact cache doesn’t hold the versions it needs, --allow-remote-fetch (with --index pointing at your registry) fetches them; without it, scarno makes no network calls at all. I’m working on extending the ABI diff to other languages, and it will be available in an upcoming version of scarno. Until then, scarno’s per-symbol usage analysis for Python and .NET still tells you exactly which parts of each dependency your code calls, so you only have to check those symbols against the resolved version by hand. The output of these two steps turns “two versions of acme-core coexist in 14 projects” into “in three of those projects, code calls a symbol that won’t be there”. That’s a work queue rather than a report.

Step 3: Handler analysis

For each TS-ABI-RUNTIME-RISK call site, follow the call up the stack and find out what happens when it fails:

  • Find every enclosing try block, in the calling method and in its callers, up to the framework boundary.
  • Match each catch against the full hierarchy: every ancestor of the error class and every child of it, plus multi-catch clauses and catch-alls such as a bare except:.
  • Note what each handler does: rethrow, return a default, fall back to another code path, or log and continue.
  • Check framework behaviour for components that fail during initialisation: does the application refuse to start, or start without them?

Step 4: Absence analysis

Not every failure is an exception. For the lookups that return nothing instead of throwing (feature detection, reflective lookups, optional imports, conditional configuration) and for the handlers that return a default, trace the value that comes back:

  • Does a null, None, undefined, false or empty value flow into a check such as if (validator != null) or if policy:, so that the control is skipped rather than enforced?
  • Does a handler’s return null propagate to a caller that treats absence as permission, such as if (decision == null) return true?
  • Does the rest of the flow carry on with unvalidated, unencoded or unauthorised data because the step that should have produced the safe value produced nothing?

Wherever the code that drops out is a sanitiser, an encoder, an authentication or authorisation check, a signature or token validation, or a piece of cryptographic configuration, you have a candidate fail-open. Confirm it with a test against the resolved artefact that actually ships.

Steps 1 and 2 are automated today. Steps 3 and 4 are where you currently need custom SAST rules or a reviewer, but because the first two steps narrow the search to a handful of call sites, that review is a few hours’ work rather than an audit of every catch block in the estate. They’re also a good fit for LLM-assisted review, as long as the graph and scarno’s findings are the ground truth the model works from, rather than something it’s asked to infer.

What to Do About It

Break any one link in the chain and the vulnerability goes away, so you have several places to intervene. In rough order of effort:

  1. Make security controls fail closed. Never wrap a sanitiser, an authentication check or an authorisation check in a catch that carries on, and never treat an absent validator or policy as permission. If the control can’t run, the request is denied. This is the cheapest fix and it holds whatever your dependency graph does.
  2. Treat dependency convergence as a security gate. Turn on the Maven Enforcer’s dependencyConvergence or requireUpperBoundDeps rules, the Linkage Checker, Gradle’s failOnVersionConflict(), and treat NuGet’s NU1605 as an error. When a conflict is genuinely unavoidable, make it an explicit, reviewed decision rather than a side effect of declaration order.
  3. Search for the whole hierarchy, not just the broad catches. Write custom SAST rules for every ancestor and child of the version-mismatch errors in your languages, and for absence-returning lookups, wherever they enclose or feed your sanitisation, authentication and authorisation code.
  4. Test what you ship. Run your security tests against the resolved artefact that goes to production, not the declared dependencies in your IDE.
  5. Join the data. Use the four steps above to connect the declared graph, the ABI differences and the handling code, so you review the handful of call sites that matter.

Note to engineering leaders: ask your teams two questions. How many components in your most critical application are requested at more than one version? And what happens to a request when one of your security controls throws, or finds nothing to call? If nobody can answer the first, and the answer to the second is “it gets logged”, you have the conditions for this vulnerability.

Final Thoughts

None of the individual pieces here are new, and I want to credit the people who documented them. Ying Wang and colleagues characterised dependency conflicts in Do the Dependency Conflicts in My Project Matter? (FSE 2018), generated crashing tests for them with Riddle (ICSE 2019), and found the silent semantic variant with Sensor (IEEE TSE). Google’s Java Library Best Practices and Linkage Checker and Spotify’s missinglink gave us tooling for linkage errors. Maven-Hijack showed what an attacker can do deliberately with classpath ordering. CWE-636 and OWASP A10:2025 describe the outcome.

What I haven’t found is anyone connecting them: treating version mediation, two-way breaking changes, runtime linkage failures and catch-and-ignore handling as a single composite weakness with a security outcome. That’s the claim I’m making with dependency mediation fail-open.

I also want to be honest about the limits. The XXE example is built from documented behaviour of real parsers and real guidance, not from an incident I can point to, and I haven’t yet published measurements of how common this is across a real estate. That’s the next piece of work.

If you’ve seen this in the wild, or you know of prior work that names it, I’d genuinely like to hear from you.

Stay tuned!