OWASP Dependency Check (dep-scan)

repository·master·Indexed 23 days ago

https://github.com/owasp-dep-scan/dep-scan

An open-source security audit tool (version 6.3.1) that identifies vulnerabilities and license risks in project dependencies. It distinguishes between declared and reachable dependencies and supports integration with CycloneDX SBOMs, Dependency Track, and cdxgen. The project includes utilities for Software Composition Analysis (SCA), supply-chain security, and automated vulnerability fix command generation for NuGet, npm, and Maven.

Tokens
64.2K
Snippets
104
Records
320
Agent score
79%

What's inside owasp-dep-scan

  1. What is OWASP dep-scan?

    master

    OWASP dep-scan is a security and risk audit tool designed to identify known vulnerabilities, advisories, and license limitations in project dependencies. It supports scanning local repositories and container images. It is designed for integration into CI environments and ASPM/VM platforms. Key capabilities include:

    • Vulnerability Scanning: Identifies CVEs in application code, Linux container images, Kubernetes manifests, and OS layers.
    • Reachability Analysis: Determines if a vulnerable package is actually on an executed path (Reachable) or merely declared in the BOM (Non-reachable).
    • SBOM & Compliance: Generates Software Bill-of-Materials (SBOM) with Vulnerability Disclosure Report (VDR) information and CSAF 2.0/2.1 VEX documents.
    • Risk Auditing: Performs deep audits for dependency confusion attacks and maintenance risks.
  2. Overview of OWASP dep-scan features

    master

    OWASP dep-scan is a security and risk audit tool designed to identify known vulnerabilities (CVEs), advisories, and license limitations within project dependencies. It supports scanning local repositories, Linux container images, Kubernetes manifests, and operating systems.

    Key capabilities include:

    • Reachability Analysis: Advanced analysis to determine if a vulnerability is actually reachable in your code.
    • Local Scanning: Package vulnerability scanning is performed locally for speed, without requiring a central server.
    • SBOM & VEX Generation: Generates Software Bill-of-Materials (SBOM) with Vulnerability Disclosure Report (VDR) information and Common Security Advisory Framework (CSAF) 2.0 VEX documents.
    • Risk Auditing: Performs deep audits for dependency confusion attacks and maintenance risks.
  3. Choose between CSAF 2.0 and 2.1

    master

    When generating CSAF documents, you can choose between version 2.0 and 2.1. CSAF 2.1 is the default and provides a richer data set.

    CSAF 2.1 (Recommended):

    • Sets document.csaf_version to 2.1.
    • Includes a $schema URI.
    • Supports the cvss_v4 score family.
    • Supports multiple CWEs per vulnerability via a cwes array.

    CSAF 2.0:

    • Sets document.csaf_version to 2.0.
    • Omits the $schema URI.
    • Does not support cvss_v4 (CVSS v4 vectors are only retained when targeting 2.1).
    • Supports only a single cwe per vulnerability; additional CWEs are relegated to developer notes.
  4. Understand 'Next Steps' guidance in reports

    master

    The "Next Steps" column in the dep-scan console's Top Priority table provides human-readable guidance based on the reachability tier of a finding. The logic is driven by find_next_steps in analysis_lib/output.py:

    Reachability StateGuidance Pattern
    Reachable + ExploitableSuggests adding workarounds and validations to make the CVE non-reachable.
    Endpoint-ReachablePoints toward framework-level validation options.
    Service-ReachableSuggests confirming the package uses an allow-listed service.
    Malware + ReachableTriggers a "top-priority security incident" warning.
    High CVE CountIf a package has many CVEs (e.g., len(cve_list) > 5), the guidance shifts toward coordinated upgrades.
  5. How BOM engines work

    master

    The bom-engine determines how the Software Bill-of-Materials (SBOM) is generated. Choosing the right engine depends on your environment and requirements:

    • auto: Automatically selects an engine. It uses CdxgenImageBasedGenerator if Docker is available and the project is not an OCI image. Otherwise, it defaults to the local CdxgenGenerator or CdxgenServerGenerator (if --cdxgen-server is provided).
    • CdxgenGenerator: Always uses the local cdxgen CLI. Requires cdxgen to be installed via npm or as a standalone executable.
    • CdxgenServerGenerator: Uses a remote cdxgen server. Requires the --cdxgen-server flag to specify the URL.
    • CdxgenImageBasedGenerator: Uses official cdxgen container images. This is highly reliable for enterprise apps requiring specific build tools but is more resource-intensive. You can customize the images using environment variables like CDXGEN_IMAGE_{project_type} (e.g., CDXGEN_IMAGE_JAVA).
    • BlintGenerator: Uses the OWASP blint library. Requires installing depscan with the [all] extra: pip install owasp-depscan[all].
  6. Security of Registry and GitHub metadata lookups

    master

    The package risk audit path performs network lookups to PyPI, npm, and crates.io, and uses GitHub token helpers to call the GitHub API.

    Existing Controls:

    • Timeouts: Applied to network calls.
    • Fixed Hosts: Registry base URLs are fixed in configuration.
    • Circuit Breaker: The metadata fetch path includes a circuit breaker to stop after repeated failures.

    Risks to Monitor:

    • Over-trusting remote metadata.
    • Silent changes to security conclusions due to failed lookups.
    • Credential leakage through logs.
  7. How the dep-scan server mode works

    master

    In server mode, dep-scan provides an HTTP endpoint (using a Quart server) at /scan to process scan requests. This mode introduces a new trust boundary as it accepts remote inputs.

    Supported scan types via the server include:

    • Path-based scans: Scanning specific local paths.
    • URL-based scans: Using the cdxgen server to inspect remote URLs.
    • Uploaded BOM scans: Processing a provided SBOM file.
    Client --> Quart server (/scan) --> input validation --> BOM generation and analysis --> JSON response
                 |
                 +--> path-based scan
                 +--> URL-based scan via cdxgen server
                 +--> uploaded BOM scan
  8. Understand Dep-scan Prioritized Recommendations

    master

    Dep-scan provides a prioritized view of vulnerabilities (Top Priority BOM) to help teams focus on remediation. The recommendation report includes:

    • Package: The specific dependency identifier (e.g., pkg:maven/org.apache.tomcat.embed/tomcat-embed-core).
    • Prioritized CVEs: The list of vulnerabilities associated with that package.
    • Fix Version: The recommended version to upgrade to, if determinable.
    • Next Steps: Actionable guidance, such as identifying upgrade challenges or checking issue trackers for patches when a fix version cannot be determined.
  9. Security considerations for CLI usage and orchestration

    master

    When using the dep-scan CLI, be aware that the arguments provided (source paths, images, binary paths, BOM files, etc.) directly influence file reading, report writing, analyzer execution, and external service communication.

    Key Risks:

    • Untrusted Inputs: Risk increases when scanned content is untrusted or when automation passes partially untrusted values to the CLI.
    • Subprocess/Network Injection: Ensure user-controlled values do not cross into subprocess construction, network targets, report rendering, or filesystem writes without validation.
    • Execution Modes: The CLI can execute external tools locally, over HTTP, or via container images.
  10. How reachability affects prioritization and VEX output

    master

    Reachability data is used to automate triage and compliance artifacts:

    1. Prioritization: The prioritization engine tags reachable findings (especially endpoint-reachable or malicious-and-reachable) with the CycloneDX property depscan:prioritized. These are surfaced in the Top Priority table.

    2. VEX (Vulnerability Exploitability eXchange) Output: The VEX exporter maps reachability to machine-readable status:

    • Reachable dependencies: Become known_affected.
    • Present-but-unreachable dependencies: Become known_not_affected with the justification vulnerable_code_not_in_execute_path.
  11. How Go reachability works with golem

    master

    dep-scan uses golem (Go Source Inspector) as its native slicer for Go projects. Golem analyzes the source code to produce call graphs, interprocedural data-flow slices, and symbol-usage evidence.

    The Reachability Logic:

    1. golem scans the code and emits slices containing versioned purl identifiers (e.g., pkg:golang/github.com/satori/go.uuid@v1.2.0).
    2. dep-scan converts these slices into a shared reachability pipeline.
    3. If a vulnerable module's functions are actually called (e.g., pgx.Connect), the module is marked as Reachable and assigned depscan:prioritized.
    4. If a module is present in the Bill of Materials (BOM) but its functions are never called, it is considered present-but-unreachable and is not prioritized.

    Reachability is enabled by default using the FrameworkReachability analyzer. You can switch to SemanticReachability if you also require reached services and endpoints to be attributed.

  12. Analyze the structure of a VDR entry

    master

    Each entry in the vulnerabilities array describes one CVE against one component. The structure is normalized using versioned purl keys. Key fields include:

    • affects[].ref: The versioned purl of the installed component.
    • affects[].versions: Contains blocks for both affected and unaffected (fixed) versions. The version with status: "unaffected" is the suggested fix version.
    • analysis.detail: A JSON-encoded list of purls representing the dependency tree.
    • properties: An array containing dep-scan's specific verdicts (depscan:insights and depscan:prioritized).
    {
      "id": "CVE-2023-XXXX",
      "source": {"name": "NVD", "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-XXXX"},
      "ratings": [{"method": "CVSSv31", "severity": "high", "score": 7.5}],
      "affects": [
        {
          "ref": "pkg:maven/io.netty/netty-codec-http2@4.1.94.Final?type=jar",
          "versions": [
            {"version": "4.1.94.Final", "status": "affected"},
            {"version": "4.1.100.Final", "status": "unaffected"}
          ]
        }
      ],
      "analysis": {
        "state": "in_triage",
        "detail": "Dependency Tree: [\"pkg:maven/io.quarkus/quarkus-vertx@3.3.3?type=jar\", \"pkg:maven/io.netty/netty-codec-http2@4.1.94.Final?type=jar\"]"
      },
      "properties": [
        {"name": "depscan:insights", "value": "Direct dependency"},
        {"name": "depscan:prioritized", "value": "false"}
      ]
    }