Skip to main content

Dependency Confusion

Description

The application incorrectly defines the dependencies to be used. This generates some ambiguity that can be used by an attacker to confuse the package manager in charge of installing or updating the project's dependencies, with the aim of executing potentially harmful code, thus increasing the possible attack vectors.

Impact

  • Execute malicious code in the application
  • Deploy a malicious version of the application that can lead to a system unavailability

Recommendation

  • Set the name of the organization that owns the private dependency in the package manager file.

  • Set the organization in both the private and public registry of the package manager.

Threat

Anonymous attacker from the Internet

Expected Remediation Time

⌚ 20 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: N
  • Attack complexity: L
  • Privileges required: N
  • User interaction: R
  • Scope: U
  • Confidentiality: L
  • Integrity: H
  • Availability: L

Temporal

  • Exploit code madurity: H
  • Remediation level: O
  • Report confidence: C

Result

  • Vector string: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:L/E:H/RL:O/RC:C
  • Score:
    • Base: 7.6
    • Temporal: 7.3
  • Severity:
    • Base: High
    • Temporal: High

Code Examples

Compliant code

All the registries of the package manager have the organization id set

<distributionManagement>
<repository>
<id>{organization_id}</id>
<url>https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/</url>
</repository>
<snapshotRepository>
<id>{organization_id}</id>
<url>https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/</url>
</snapshotRepository>
</distributionManagement>

Non compliant code

There is configuration to upload the package without the organization id

<distributionManagement>
<repository>
<url>https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/</url>
</repository>
<snapshotRepository>
<url>https://{WORKSPACE}.bytesafe.dev/maven/{REGISTRY}/</url>
</snapshotRepository>
</distributionManagement>

Requirements