Writing

Exporting SBOMs from Next.js and Uploading to Dependency-Track

Supply chain attacks are on the rise, and knowing what is in your application is no longer optional. A Software Bill of Materials (SBOM) gives you a complete inventory of all dependencies in your codebase, making it easier to track vulnerabilities and respond to security incidents promptly.

In this guide, I will walk you through generating an SBOM from a Next.js application and uploading it to Dependency-Track for continuous monitoring.

What is an SBOM?

An SBOM is essentially a list of all the components, libraries, and dependencies that make up your software. Think of it as an ingredient list for your application. Standards like CycloneDX and SPDX provide structured formats for creating and sharing SBOMs.

Why Use Dependency-Track?

Dependency-Track is an open-source platform that continuously monitors your dependencies for known vulnerabilities. It integrates with multiple vulnerability databases (NVD, OSS Index, GitHub Advisories) and provides a centralized dashboard for tracking security risks across all your projects.

Step 1: Install CycloneDX

First, to generate an SBOM, we need to install the CycloneDX CLI tool globally on your machine:

npm install -g @cyclonedx/cyclonedx-npm
Step 2: Generate the SBOM

Navigate to your Next.js project directory and run:

cyclonedx-npm --output-file sbom.json

This command scans your package.json and package-lock.json files, then generates a CycloneDX-formatted SBOM in JSON format.

You can also specify the output format (XML or JSON):

cyclonedx-npm --output-format XML --output-file sbom.xml
Step 3: Set Up Dependency-Track

If you do not have Dependency-Track running yet, the easiest way is by using Docker:

docker run -d -p 8080:8080 --name dependency-track dependencytrack/bundled

Access the web interface at http://localhost:8080. The default credentials are:

  • Username: admin
  • Password: admin
Dependency-Track login screen
Step 4: Create a Project in Dependency-Track

Once logged in, create a new project:

  1. Click Projects in the sidebar
  2. Click the + button to create a new project
  3. Fill in the project details (name, version, description)
  4. Click Create
Step 5: Get Your API Key

To upload SBOMs programmatically, you need an API key:

  1. Click on Administration in the sidebar
  2. Navigate to Access Management > Teams
  3. Select Automation team
  4. Copy the API key from the API Keys section
Dependency-Track login screen
Step 6: Upload the SBOM

Now upload your SBOM using curl:

curl -X "POST" "http://localhost:8080/api/v1/bom" \
  -H "Content-Type: multipart/form-data" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "project=PROJECT_UUID" \
  -F "[email protected]"

Replace YOUR_API_KEY with your actual API key and PROJECT_UUID with your project's UUID (found in the project details page).

Step 7: View Results

After uploading, Dependency-Track will analyze your SBOM and cross-reference it against vulnerability databases. You can view:

  • Total component count
  • Vulnerable components
  • Severity breakdown (critical, high, medium, low)
  • License information
  • Detailed CVE reports
Dependency-Track login screen
Automating SBOM Generation in CI/CD

For continuous monitoring, add SBOM generation to your CI/CD pipeline. Here is an example GitHub Actions workflow:

name: Generate and Upload SBOM

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  sbom:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'
      
      - name: Install dependencies
        run: npm ci
      
      - name: Generate SBOM
        run: |
          npm install -g @cyclonedx/cyclonedx-npm
          cyclonedx-npm --output-file sbom.json
      
      - name: Upload to Dependency-Track
        run: |
          curl -X "POST" "${{ secrets.DT_URL }}/api/v1/bom" \
            -H "Content-Type: multipart/form-data" \
            -H "X-API-Key: ${{ secrets.DT_API_KEY }}" \
            -F "project=${{ secrets.DT_PROJECT_UUID }}" \
            -F "[email protected]"
Best Practices
  • Generate SBOMs regularly: Automate SBOM generation on every build or deploy
  • Monitor vulnerabilities: Set up alerts in Dependency-Track for new CVEs
  • Track dependencies over time: Use Dependency-Track's trending features to see how your risk profile changes
  • Include dev dependencies: Use --omit=dev flag if you only want production dependencies
  • Version your SBOMs: Tag SBOMs with release versions for historical tracking
Common Issues

Large dependency trees taking too long? Use the --short-PURLs flag to reduce file size.

Missing dependencies? Make sure package-lock.json is up to date by running npm install first.

Upload failing? Check that your API key has the correct permissions and the project UUID is valid.

SBOMs are becoming a requirement for compliance frameworks like NIST SSDF and executive orders on software supply chain security. By integrating SBOM generation into your workflow, you are not just improving security but also positioning yourself for regulatory readiness.

Dependency-Track gives you visibility into what is running in production, helps you respond faster to vulnerabilities, and provides the audit trail needed for security reviews. Stay SAFE!