SuperAPI AI 工具集

building-vulnerability-exception-tracking-system

安全与审计

查看项目

更新于 10-15 13:55

技能介绍

用途

漏洞例外跟踪系统用于管理那些无法在 SLA 期限内完成修复的漏洞。它为申请例外、记录补偿控制、获取风险接受审批提供了结构化的工作流,并在有效期结束时自动使例外过期。这有助于组织在遵循 PCI DSS、SOC 2、NIST CSF 等框架的同时,保持对已接受风险的可见性。

适用时机

  • 在环境中部署或配置漏洞例外跟踪系统能力时
  • 建立与合规要求对齐的安全控制时
  • 为该领域构建或改进安全架构时
  • 执行需要此实现的安全评估时

前置条件

  • Python 3.9+,并安装 flask、sqlalchemy、requests、jinja2
  • PostgreSQL 或 SQLite 数据库
  • 用于审批通知的 Email/Slack 集成
  • 漏洞管理平台 API(DefectDojo、Qualys、Tenable)

例外申请工作流

例外类别

类别 描述 最长时长 审批级别
Remediation Delay 补丁可用但部署受阻 30 天 团队负责人 + 安全
No Fix Available 供应商尚未发布补丁 90 天 安全总监
Business Critical 系统无法在不中断的情况下打补丁 60 天 工程 VP + CISO
False Positive 发现并非真实漏洞 永久 安全分析师
Compensating Control 已实施替代缓解措施 180 天 安全架构师

例外申请必填字段

exception_schema = {
    "cve_id": "CVE-2024-XXXX",
    "finding_id": "unique-finding-reference",
    "asset_hostname": "prod-db-01.corp.local",
    "severity": "high",
    "cvss_score": 8.1,
    "category": "remediation_delay",
    "justification": "Database upgrade required before patch can be applied",
    "compensating_controls": [
        "WAF rule blocking exploit pattern deployed",
        "Network segmentation restricting access to trusted VLANs only",
        "Enhanced monitoring via Splunk alert for exploitation indicators"
    ],
    "requested_expiration": "2024-06-15",
    "requestor_email": "dbadmin@company.com",
    "approver_emails": ["security-lead@company.com", "ciso@company.com"],
    "risk_rating": "medium",
}

数据库模式

CREATE TABLE vulnerability_exceptions (
    id SERIAL PRIMARY KEY,
    cve_id VARCHAR(20) NOT NULL,
    finding_id VARCHAR(100) NOT NULL,
    asset_hostname VARCHAR(255),
    severity VARCHAR(20),
    cvss_score DECIMAL(3,1),
    category VARCHAR(50) NOT NULL,
    justification TEXT NOT NULL,
    compensating_controls TEXT,
    status VARCHAR(20) DEFAULT 'pending',
    requested_by VARCHAR(255) NOT NULL,
    approved_by VARCHAR(255),
    requested_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    approved_at TIMESTAMP,
    expires_at TIMESTAMP NOT NULL,
    expired BOOLEAN DEFAULT FALSE,
    risk_rating VARCHAR(20),
    review_notes TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE exception_audit_log (
    id SERIAL PRIMARY KEY,
    exception_id INTEGER REFERENCES vulnerability_exceptions(id),
    action VARCHAR(50) NOT NULL,
    actor VARCHAR(255) NOT NULL,
    details TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_exception_status ON vulnerability_exceptions(status);
CREATE INDEX idx_exception_expires ON vulnerability_exceptions(expires_at);
CREATE INDEX idx_exception_cve ON vulnerability_exceptions(cve_id);

实现

例外申请 API

from flask import Flask, request, jsonify
from datetime import datetime, timezone
import json

app = Flask(__name__)

@app.route("/api/exceptions", methods=["POST"])
def create_exception():
    data = request.json
    required = ["cve_id", "finding_id", "category", "justification", "expires_at", "requestor_email"]
    for field in required:
        if field not in data:
            return jsonify({"error": f"Missing required field: {field}"}), 400

    # Validate expiration does not exceed category maximum
    max_days = {"remediation_delay": 30, "no_fix": 90, "business_critical": 60,
                "false_positive": 365, "compensating_control": 180}
    # Insert into database and notify approvers
    return jsonify({"status": "pending", "id": "exc-12345"})

@app.route("/api/exceptions/<exc_id>/approve", methods=["POST"])
def approve_exception(exc_id):
    approver = request.json.get("approver_email")
    notes = request.json.get("notes", "")
    # Update status to approved, record approver and timestamp
    return jsonify({"status": "approved"})

@app.route("/api/exceptions/<exc_id>/reject", methods=["POST"])
def reject_exception(exc_id):
    reviewer = request.json.get("reviewer_email")
    reason = request.json.get("reason")
    # Update status to rejected, record reviewer and reason
    return jsonify({"status": "rejected"})

过期检查器(每日 Cron)

# Check for expired exceptions daily
python3 scripts/process.py --check-expirations

# Generate monthly exception report
python3 scripts/process.py --report --output exception_report.json

补偿控制文档

对于每个例外,补偿控制必须涵盖:

  • Detection:如何检测利用尝试?
  • Prevention:哪些屏障可降低利用可能性?
  • Response:已具备哪些事件响应程序?
  • Monitoring:哪些持续监控可确保控制措施保持有效?

参考

  • NIST SP 800-53 Rev 5 - CA-7 Continuous Monitoring
  • PCI DSS v4.0 Compensating Controls
  • CIS Controls v8 - Control 7.7