{
  "name": "Triage security vulnerability alerts with NVD, Gemini, Supabase, and Jira",
  "nodes": [
    {
      "id": "233713b5-8f5f-4987-b700-454262ab93ba",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2272,
        -32
      ],
      "parameters": {
        "width": 480,
        "height": 832,
        "content": "## NVD + AI SecOps Triage\n\n### How it works\n\n1. Ingests security event data through a webhook and validates the payload structure.\n2. Performs deduplication tracking using Redis to ignore repeated events.\n3. Enriches the event data with vulnerability details from NVD and server context from Supabase.\n4. Analyzes the risk level using an AI agent powered by Gemini with a structured output parser.\n5. Routes the risk assessment to create appropriate Jira tickets and returns webhook responses.\n\n### Setup steps\n\n- Configure Webhook header authentication credentials\n- Set up Redis connection credentials for deduplication\n- Configure NVD API integration if required\n- Set up Supabase connection credentials for server lookups\n- Configure Google Gemini API credentials for the AI agent\n- Set up Jira integration credentials and project settings\n\n### Customization\n\nYou can adjust the AI agent's prompt to change risk thresholds or customize Jira ticket fields based on your team's workflow requirements."
      },
      "typeVersion": 1
    },
    {
      "id": "2abb212f-5a09-4947-8fc1-38dd0b7c32e3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 400,
        "content": "## Webhook ingestion and payload validation\n\nReceives webhook requests and validates the incoming payload, responding early if invalid."
      },
      "typeVersion": 1
    },
    {
      "id": "f8ce0ce4-96bd-4e84-b0d9-d9fc9593ac76",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 400,
        "content": "## Deduplication check\n\nPerforms deduplication via Redis and checks if the event is a first occurrence, responding early if duplicate."
      },
      "typeVersion": 1
    },
    {
      "id": "c36ee9f1-c241-4e56-8eca-c0376e4748a5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 304,
        "content": "## Vulnerability and server enrichment\n\nEnriches vulnerability data via NVD lookup and retrieves server information from Supabase."
      },
      "typeVersion": 1
    },
    {
      "id": "684ac4c4-8f3f-496f-a228-749abf935c25",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 528,
        "content": "## AI risk analysis\n\nPrepares context variables and runs the AI risk analyst agent with Gemini and structured output parser."
      },
      "typeVersion": 1
    },
    {
      "id": "93ebad7d-5792-4567-beb2-3333b4e14838",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 496,
        "content": "## Risk routing and ticketing\n\nRoutes the AI risk assessment results to create Jira tickets and respond to the webhook."
      },
      "typeVersion": 1
    },
    {
      "id": "beb95bcc-c6fa-47e2-a547-c508a69c6107",
      "name": "When Vulnerability Alert Received",
      "type": "n8n-nodes-base.webhook",
      "notes": "Requires a Header Auth credential (shared secret header) set on this node. Rejects unauthenticated callers before any workflow logic runs.",
      "position": [
        -1664,
        432
      ],
      "parameters": {
        "path": "vuln-alert",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "authentication": "headerAuth"
      },
      "typeVersion": 2
    },
    {
      "id": "66194372-e7ec-40c4-bfa9-b2ba2854fd77",
      "name": "If Valid Payload",
      "type": "n8n-nodes-base.if",
      "notes": "Rejects malformed CVE IDs / missing IP before they ever reach an external API call or get interpolated into a URL. Prevents wasted OSV calls and URL-injection from a spoofed payload.",
      "position": [
        -1440,
        432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "v1",
              "operator": {
                "type": "string",
                "operation": "regex"
              },
              "leftValue": "={{ $json.body.cve_id }}",
              "rightValue": "^CVE-\\d{4}-\\d{4,7}$"
            },
            {
              "id": "v2",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.body.ip_address }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ddbe0d92-5709-42e1-81d3-5eb5e6da325e",
      "name": "Increment Dedup Counter",
      "type": "n8n-nodes-base.redis",
      "notes": "INCR is atomic. First time this CVE+asset pair fires, the key doesn't exist and Redis creates it at 1. Any repeat alert (scanner re-poll, retry, duplicate webhook) increments past 1 and gets suppressed downstream, instead of opening duplicate Jira tickets or re-triggering GitHub Actions. Set a TTL/eviction policy on this keyspace (e.g. 10-15 min) in Redis config or a small cleanup workflow so the same CVE can re-alert after the window closes.",
      "position": [
        -992,
        432
      ],
      "parameters": {
        "key": "=secops-dedup:{{ $json.body.cve_id }}:{{ $json.body.ip_address }}",
        "operation": "incr"
      },
      "typeVersion": 1
    },
    {
      "id": "7ef59653-072a-495e-9b1b-e5b5c4d8238a",
      "name": "If First Occurrence",
      "type": "n8n-nodes-base.if",
      "position": [
        -768,
        432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d1",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json['secops-dedup:CVE-2024-3400:10.0.4.22'] }}",
              "rightValue": 1
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1b9f65da-20a4-440d-9f2e-110682aad84b",
      "name": "Prepare LLM Context",
      "type": "n8n-nodes-base.set",
      "notes": "Single control-panel node. Both OSV and CMDB failure states are normalized into an explicit NOT_FOUND string here, so the policy for 'missing data' lives once, in the system prompt below \u2014 not scattered across extra IF nodes.",
      "position": [
        96,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "cve_id",
              "type": "string",
              "value": "={{ $('When Vulnerability Alert Received').item.json.body.cve_id }}"
            },
            {
              "id": "a2",
              "name": "ip_address",
              "type": "string",
              "value": "={{ $('When Vulnerability Alert Received').item.json.body.ip_address }}"
            },
            {
              "id": "a3",
              "name": "osv_summary",
              "type": "string",
              "value": "={{ $('Fetch NVD Vulnerability Details').item.json.error ? 'NOT_FOUND: no OSV record for this CVE' : JSON.stringify($('Fetch NVD Vulnerability Details').item.json) }}"
            },
            {
              "id": "a4",
              "name": "cmdb_summary",
              "type": "string",
              "value": "={{ $json.error ? 'NOT_FOUND: asset not present in CMDB' : JSON.stringify($json.results ? $json.results : $json) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "23d3d43c-e792-421b-98ee-4e21c5956517",
      "name": "Route by Risk Level",
      "type": "n8n-nodes-base.switch",
      "notes": "Only one explicit rule (auto-patch) plus the fallback. Anything that ISN'T a clean 'auto-patch' \u2014 ticket_only, a malformed action, or a parser miss \u2014 falls through to the same backlog-ticket branch instead of silently vanishing, which is what happened in the first draft of this workflow.",
      "position": [
        688,
        528
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "r1",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.action }}",
                    "rightValue": "auto-patch"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "ticket_only_or_unclear"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "315f73cd-1b9e-4a2c-9069-c0973ec82f55",
      "name": "Create Remediated Ticket in Jira",
      "type": "n8n-nodes-base.jira",
      "position": [
        912,
        432
      ],
      "parameters": {
        "project": {
          "__rl": true,
          "mode": "list",
          "value": "10000",
          "cachedResultName": "blankarray"
        },
        "summary": "={{ \"EMERGENCY: \" + $('Prepare LLM Context').item.json.cve_id + \" on \" + $('Prepare LLM Context').item.json.ip_address }}",
        "issueType": {
          "__rl": true,
          "mode": "list",
          "value": "10004",
          "cachedResultName": "Bug"
        },
        "additionalFields": {
          "description": "={{ $('Risk Analyst Agent').item.json.output.reasoning }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3769a220-5dca-4a8a-a8a1-9cf621aa1668",
      "name": "Create Backlog Ticket in Jira",
      "type": "n8n-nodes-base.jira",
      "position": [
        912,
        624
      ],
      "parameters": {
        "project": {
          "__rl": true,
          "mode": "list",
          "value": "10000",
          "cachedResultName": "blankarray"
        },
        "summary": "={{ \"Review needed: \" + $('Prepare LLM Context').item.json.cve_id + \" on \" + $('Prepare LLM Context').item.json.ip_address }}",
        "issueType": {
          "__rl": true,
          "mode": "list",
          "value": "10003",
          "cachedResultName": "Task"
        },
        "additionalFields": {
          "description": "={{ $('Risk Analyst Agent').item.json.output.reasoning }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "13c6102d-906e-45e5-a809-d6603309aa7d",
      "name": "Send Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1136,
        432
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.5
    },
    {
      "id": "dc06c63d-6ac4-4663-bd75-a7ea56e0a908",
      "name": "Send Backlog Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1136,
        624
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.5
    },
    {
      "id": "41f37c7e-7335-4add-b069-a254dcb813b7",
      "name": "Send Invalid Payload Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -1216,
        528
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "DATA INVALID PLACE CHECK AND SEND AGAIN"
      },
      "typeVersion": 1.5
    },
    {
      "id": "47d45c9c-90f4-4bcd-b3b5-a18e039717a5",
      "name": "Send Duplicate Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -544,
        528
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "ALERT WAS ALREADY SENT :)"
      },
      "typeVersion": 1.5
    },
    {
      "id": "0eae609a-8ab7-4298-99ba-2ecfbc080c21",
      "name": "Fetch NVD Vulnerability Details",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "onError=continueRegularOutput: an unknown/withdrawn CVE (404) must not crash the whole execution. The 'not found' case is handled in the prompt, not with another branch node.",
      "onError": "continueRegularOutput",
      "maxTries": 3,
      "position": [
        -336,
        432
      ],
      "parameters": {
        "url": "=https://services.nvd.nist.gov/rest/json/cves/2.0?cveId={{ $('If Valid Payload').item.json.body.cve_id }}",
        "options": {}
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 2000
    },
    {
      "id": "9546210e-ec26-400e-a51a-fb4e2c8dd954",
      "name": "Fetch Server Info from Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -112,
        432
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "ip_address",
              "keyValue": "={{ $('When Vulnerability Alert Received').item.json.body.ip_address }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "cmdb_assets",
        "operation": "getAll"
      },
      "typeVersion": 1
    },
    {
      "id": "bc497312-0ceb-4d48-9a8b-b6d2cc10ed7b",
      "name": "Risk Analyst Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        320,
        432
      ],
      "parameters": {
        "text": "=CVE: {{ $json.cve_id }}\nAsset IP: {{ $json.ip_address }}\n\nOSV vulnerability data:\n{{ $json.osv_summary }}\n\nCMDB asset data:\n{{ $json.cmdb_summary }}\n\nAssess this alert per your instructions and return only the JSON object.",
        "options": {
          "maxIterations": 3,
          "systemMessage": "You are an enterprise SecOps triage analyst. Ground every judgment ONLY in the OSV and CMDB data provided \u2014 never invent a CVSS score, package name, or asset environment that isn't present in that data.\n\nPolicy:\n- Asset environment = Production AND OSV CVSS > 7.0 -> risk_score 90-100, action auto-patch.\n- Asset environment = Staging -> risk_score 40-60, action ticket_only, regardless of CVSS.\n- Asset environment = Production AND CVSS <= 7.0 -> risk_score 50-70, action ticket_only.\n- OSV data is NOT_FOUND -> risk_score 50, action ticket_only, reasoning must say the CVE could not be verified against OSV and needs manual lookup.\n- CMDB data is NOT_FOUND -> risk_score 50, action ticket_only, reasoning must say the asset is unrecognized and needs manual classification.\n\nRespond with ONLY the JSON object \u2014 no preamble, no explanation outside the JSON. Put your reasoning inside the \"reasoning\" field."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "08284d6a-8336-4b4f-ba15-db3ed035dc51",
      "name": "Gemini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        256,
        656
      ],
      "parameters": {
        "options": {
          "temperature": 0.2
        },
        "modelName": "models/gemini-3.1-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "901631cc-937f-4a7c-828d-35dca6892724",
      "name": "Parse Structured Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        496,
        672
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"risk_score\": { \"type\": \"number\" },\n    \"action\": { \"type\": \"string\", \"enum\": [\"auto-patch\", \"ticket_only\"] },\n    \"reasoning\": { \"type\": \"string\" }\n  },\n  \"required\": [\"risk_score\", \"action\", \"reasoning\"]\n}"
      },
      "typeVersion": 1.2
    }
  ],
  "connections": {
    "Gemini Model": {
      "ai_languageModel": [
        [
          {
            "node": "Risk Analyst Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If Valid Payload": {
      "main": [
        [
          {
            "node": "Increment Dedup Counter",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Invalid Payload Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Risk Analyst Agent": {
      "main": [
        [
          {
            "node": "Route by Risk Level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If First Occurrence": {
      "main": [
        [
          {
            "node": "Fetch NVD Vulnerability Details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Duplicate Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare LLM Context": {
      "main": [
        [
          {
            "node": "Risk Analyst Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Risk Level": {
      "main": [
        [
          {
            "node": "Create Remediated Ticket in Jira",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Backlog Ticket in Jira",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Increment Dedup Counter": {
      "main": [
        [
          {
            "node": "If First Occurrence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Risk Analyst Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Create Backlog Ticket in Jira": {
      "main": [
        [
          {
            "node": "Send Backlog Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch NVD Vulnerability Details": {
      "main": [
        [
          {
            "node": "Fetch Server Info from Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Server Info from Supabase": {
      "main": [
        [
          {
            "node": "Prepare LLM Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Remediated Ticket in Jira": {
      "main": [
        [
          {
            "node": "Send Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Vulnerability Alert Received": {
      "main": [
        [
          {
            "node": "If Valid Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "instanceId": null
  },
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  }
}