Security Debt Tracking

Production-grade guide to security debt tracking covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.

Security debt tracking is the disciplined practice of identifying, measuring, and prioritizing unresolved security issues across an engineering organization’s software lifecycle—especially those that are known but not yet resolved. It matters when security work accumulates faster than it is addressed, when vulnerabilities are discovered but left unpatched, when compliance requirements are met but not sustained, and when security teams can no longer keep up with alerts, scan results, and audit findings. Security debt tracking transforms reactive security into a prioritized, visible, and actionable program.

Tracking Security Debt: From Discovery to Resolution

Identifying and Ingesting Security Issues

Security debt begins with ingestion: collecting findings from automated and manual security activities. Tools produce data in structured formats, but the key challenge is normalizing and enriching these inputs into a single source of truth.

Each security scan or audit produces a list of issues. A typical vulnerability.json from a container scanner might look like:

[
  {
    "id": "CVE-2023-1234",
    "title": "SQL Injection in User Login",
    "severity": "high",
    "cvss": 8.1,
    "discovered_by": "snyk",
    "source": "docker-image-registry:myapp:prod",
    "details": {
      "file": "/app/src/auth/login.php",
      "line": 42,
      "context": "if (mysqli_query($conn, $sql)) { ... }"
    },
    "references": [
      "https://nvd.nist.gov/vuln/detail/CVE-2023-1234",
      "https://github.com/myorg/myapp/pull/123"
    ],
    "created_at": "2023-10-05T14:23:00Z"
  }
]

To ingest this into the central debt tracking system, a pipeline consumes these files and inserts them into a security_issues table:

CREATE TABLE security_issues (
  id UUID PRIMARY KEY,
  issue_id TEXT NOT NULL UNIQUE,
  title TEXT NOT NULL,
  severity TEXT NOT NULL CHECK (severity IN ('low', 'medium', 'high', 'critical')),
  cvss DECIMAL(3,1),
  source TEXT,
  discovered_by TEXT,
  status TEXT DEFAULT 'open',
  assigned_to TEXT,
  created_at TIMESTAMPTZ NOT NULL,
  updated_at TIMESTAMPTZ NOT NULL,
  metadata JSONB
);

A script reads *.json files from a shared volume and inserts records:

find /scan-results -name "*.json" -exec \
  pgcli -c "COPY security_issues FROM STDIN WITH (FORMAT JSON, HEADER TRUE)" \
  -f {} \;

This ingestion is idempotent: re-running the same scan produces no duplicates, thanks to the issue_id (e.g., CVE-2023-1234 or PR-123) serving as a primary key.

Representing Debt with a Unified Prioritization Model

Once ingested, issues are surfaced in a unified view where debt is not just a backlog but a measurable, prioritized portfolio.

Each issue is scored using a combination of severity, age, and impact. The model uses a formula:

priority_score = 2 * severity_weight + 1.5 * age_days + impact_multiplier

Where:

A priority_score of 10 or more is considered high priority. This score is computed nightly via a scheduled job:

#!/bin/bash

psql -c '
  WITH scored AS (
    SELECT
      id,
      title,
      severity,
      cvss,
      EXTRACT(EPOCH FROM (NOW() - created_at)) / 86400 AS age_days,
      CASE
        WHEN source ILIKE '%prod%' OR metadata->>'environment' = 'production' THEN 1.3
        WHEN source ILIKE '%critical%' THEN 1.5
        ELSE 1.0
      END AS impact_multiplier,
      CASE
        WHEN severity = 'low' THEN 1
        WHEN severity = 'medium' THEN 2
        WHEN severity = 'high' THEN 3
        WHEN severity = 'critical' THEN 4
      END AS severity_weight
    FROM security_issues
    WHERE status != 'resolved'
  ),
  prioritized AS (
    SELECT
      id,
      title,
      (2 * severity_weight + 1.5 * age_days + impact_multiplier) AS priority_score
    FROM scored
  )
  UPDATE security_issues
  SET priority_score = prioritized.priority_score
  FROM prioritized
  WHERE security_issues.id = prioritized.id;
'

This job runs daily via systemctl:

# /etc/systemd/system/security-debt-prioritizer.service
[Unit]
Description=Security Debt Prioritizer
After=network.target

[Service]
Type=oneshot
User=app
ExecStart=/opt/scripts/update-priorities.sh
Environment=DATABASE_URL=postgresql://user:[email protected]/securedb

[Install]
WantedBy=multi-user.target

Maintaining Debt Visibility and Accountability

Visibility is maintained through a central dashboard and a consistent workflow. The dashboard displays issues sorted by priority_score, with filters for severity, status, discovered_by, and assigned_to.

Each issue has a canonical URL: /debt/{id}. The response includes structured metadata and a history of changes:

{
  "id": "CVE-2023-1234",
  "title": "SQL Injection in User Login",
  "priority_score": 11.2,
  "status": "in-progress",
  "severity": "high",
  "cvss": 8.1,
  "source": "docker-image-registry:myapp:prod",
  "created_at": "2023-10-05T14:23:00Z",
  "updated_at": "2024-01-10T09:15:30Z",
  "assigned_to": "[email protected]",
  "metadata": {
    "impact": "affects 80% of users",
    "risk": "potential data breach",
    "related_tickets": ["JIRA-123", "TICKET-456"]
  },
  "history": [
    {
      "timestamp": "2023-10-05T14:23:00Z",
      "action": "created",
      "by": "snyk",
      "details": "scan completed, 12 issues found"
    },
    {
      "timestamp": "2024-01-02T10:00:00Z",
      "action": "assigned",
      "by": "[email protected]",
      "details": "assigned to Alice"
    }
  ]
}

A /debt API endpoint serves this data:

curl -H "Accept: application/json" \
     https://debt.company.com/debt/CVE-2023-1234

Managing Resolution Workflows

Resolution is guided by a simple workflow: open → assigned → in-progress → reviewed → merged → resolved.

Each transition updates the status field and records the change in history. A POST /debt/{id}/transition endpoint supports transitions:

POST /debt/CVE-2023-1234/transition HTTP/1.1
Host: debt.company.com
Content-Type: application/json

{
  "to": "in-progress",
  "by": "[email protected]",
  "notes": "Started implementing prepared statements."
}

The server responds with a 200 status and the updated issue:

{
  "id": "CVE-2023-1234",
  "status": "in-progress",
  "updated_at": "2024-01-10T09:15:30Z",
  "history": [
    { "timestamp": "2024-01-10T09:15:30Z", "action": "transition", "to": "in-progress", "by": "[email protected]", "notes": "Started implementing prepared statements." }
  ]
}

When a pull request resolves an issue, the system updates the issue via a webhook:

{
  "action": "closed",
  "pull_request": {
    "number": 123,
    "title": "Fix SQL injection in login",
    "html_url": "https://github.com/myorg/myapp/pull/123",
    "merged": true,
    "merged_at": "2024-01-10T09:15:30Z"
  },
  "repository": {
    "name": "myapp",
    "owner": "myorg"
  },
  "sender": {
    "login": "alice"
  }
}

A webhook receiver parses the payload and updates the issue:

# webhook.py
import json
import psycopg2
from datetime import datetime

def handle_webhook(event):
    pr = event["pull_request"]
    issue_id = extract_issue_id(pr["title"])
    status = "resolved" if pr["merged"] else "in-review"

    with psycopg2.connect(DATABASE_URL) as conn:
        with conn.cursor() as cur:
            cur.execute(
                """
                UPDATE security_issues
                SET status = %s, updated_at = %s
                WHERE issue_id = %s
                RETURNING id
                """,
                (status, datetime.utcnow(), issue_id)
            )
            if cur.rowcount == 0:
                # Issue not found: create it
                cur.execute(
                    """
                    INSERT INTO security_issues (issue_id, title, source, status, created_at)
                    VALUES (%s, %s, %s, %s, %s)
                    """,
                    (issue_id, pr["title"], "github", status, pr["merged_at"])
                )
            conn.commit()

Detecting and Resolving Silent Failures

The system is sensitive to subtle but critical failures.

One common silent failure occurs when a scan produces a new issue with a issue_id that is not unique in the database. The ingestion script assumes idempotency, but a misconfigured scanner outputs CVE-2023-1234 multiple times:

[
  { "issue_id": "CVE-2023-1234", "title": "SQL Injection", "created_at": "2023-10-05T14:23:00Z" },
  { "issue_id": "CVE-2023-1234", "title": "SQL Injection (updated)", "created_at": "2023-10-06T10:00:00Z" }
]

The second insert overwrites the first, losing the original metadata. The solution is to use ON CONFLICT (issue_id):

COPY security_issues FROM STDIN WITH (FORMAT JSON, HEADER TRUE)
ON CONFLICT (issue_id) DO UPDATE
SET
  title = EXCLUDED.title,
  severity = EXCLUDED.severity,
  cvss = EXCLUDED.cvss,
  updated_at = NOW(),
  metadata = COALESCE(security_issues.metadata, '{}') || EXCLUDED.metadata
WHERE
  security_issues.updated_at < EXCLUDED.updated_at;

This ensures that newer scans win, but earlier data is preserved.

Another failure mode is the priority_score calculation being out of sync with the status update. A developer assigns an issue but forgets to update the status. The system may show an issue as in-progress but with a priority_score that assumes it was assigned. The solution is to trigger the priority update after every status change:

# After updating status in the database
psql -c 'SELECT update_priority_score();'

The update_priority_score() function is a stored procedure that recalculates all open issues.

A third edge case is the metadata field being used inconsistently. Some scanners write metadata->>'environment', others use metadata->>'env'. To normalize this, a migration script runs weekly:

UPDATE security_issues
SET metadata = jsonb_set(metadata, '{env}', metadata->'environment')
WHERE metadata ? 'environment';

UPDATE security_issues
SET metadata = jsonb_set(metadata, '{environment}', metadata->'env')
WHERE metadata ? 'env' AND NOT metadata ? 'environment';

Sustaining the Practice

Sustaining the practice requires regular review and governance.

A security-debt-report script generates a weekly summary:

#!/bin/bash
# generate-weekly-report.sh
psql -c '
  WITH open_issues AS (
    SELECT
      status,
      severity,
      COUNT(*) AS count,
      AVG(priority_score) AS avg_priority,
      MIN(created_at) AS oldest,
      MAX(created_at) AS newest,
      SUM(CASE WHEN priority_score >= 10 THEN 1 ELSE 0 END) AS high_priority_count
    FROM security_issues
    WHERE status != ''resolved''
    GROUP BY status, severity
  )
  SELECT
    status,
    severity,
    count,
    round(avg_priority, 2) AS avg_priority_score,
    age(now() - oldest) AS age_of_oldest,
    age(now() - newest) AS age_of_newest,
    high_priority_count
  FROM open_issues
  ORDER BY avg_priority_score DESC;
' -t -A

The output is a CSV sent to the security team:

status,severity,count,avg_priority_score,age_of_oldest,age_of_newest,high_priority_count
in-progress,high,27,12.4,120 days,4 days,18
assigned,medium,15,9.1,37 days,10 days,9
open,critical,8,14.3,50 days,3 days,7

This report is used in biweekly security syncs to assess the health of the debt portfolio: Are high-priority items being resolved? Is the backlog growing? Are certain teams or components accumulating more debt?

Evolving the Debt Model

The model evolves over time. Teams begin tracking the number of issues per component:

ALTER TABLE security_issues ADD COLUMN component TEXT;

UPDATE security_issues
SET component = split_part(source, ':', 1)
WHERE source LIKE '%:%';

A query reveals which services contribute most to the debt:

SELECT
  component,
  COUNT(*) AS total_issues,
  SUM(CASE WHEN severity = 'critical' THEN 1 ELSE 0 END) AS critical_count,
  AVG(priority_score) AS avg_priority
FROM security_issues
WHERE status != 'resolved'
GROUP BY component
ORDER BY avg_priority DESC;

This enables targeted investment: the auth service, with 42 open issues and a mean priority score of 13.8, becomes a focus area for the next quarter.

Security debt tracking is not a one-off setup. It is a living system—constantly ingesting, prioritizing, and evolving—where every security issue is a line item in a growing ledger of organizational security health.

This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.