Project
AI Vulnerability Management Agent
- Kind
- Flagship
- Status
- Active
- Revision
- Focus
- AI security · Agentic AI · Vulnerability management · Security architecture
- Stack
- Python · FastAPI · PostgreSQL · SQLite · MCP · OpenAI API · Prometheus · Grafana · Docker Compose
A vulnerability triage agent in which deterministic code sets the risk, a human approves every ticket, and the language model can only advise.
Overview
The AI Vulnerability Management Agent is a Python service that takes vulnerability findings, scores them, asks a language model for remediation advice, and prepares a ticket that a person must approve before anything is created. The interesting part is the boundary. The model can recommend, but it cannot decide risk, approve work, or execute anything.
The rule I designed around fits on one line: AI may recommend. Deterministic policy decides. Humans authorize. Controlled code executes.
It is an independent personal project and a portfolio demonstration, not a production platform. It
has only ever run on simulated and synthetic data. Margin note: Source: the repository at commit 557ec2b. Every number on this page comes from runs recorded on 2026-12-01.
The problem
Vulnerability programs produce thousands of findings. Finding them is not the hard part. The hard part is deciding what to fix first, and then acting on that decision safely. I built this project from my background in vulnerability management, to show how an AI agent can help with that work without becoming the security decision-maker.
A language model is useful here. It can summarize a finding, explain why an exposure matters, and draft remediation guidance. It is also a liability. Scanner output, asset notes, and retrieved documents are all text that an attacker can influence, and a model that reads them can be steered. If the model could lower a severity, skip a review, or open a ticket, a crafted string in a finding would become a way to bury a critical vulnerability.
How it works
For each finding, the workflow runs these steps in order:
- Ingest. Findings arrive from a Tenable export or API, a CSV file, or local JSON, with optional asset context. Each record is validated and treated as untrusted.
- Inspect. Text fields are checked for prompt-injection patterns. Knowledge documents are authorized against the caller’s identity before use. Any retrieved evidence that looks like an injection is quarantined, so it never reaches the model.
- Score. A deterministic engine computes the risk score, rating, and remediation deadline.
- Advise. The model receives the computed result and returns a summary and remediation advice through a read-only tool set. In the demo, a deterministic local analyzer stands in for the model.
- Wait for approval. The workflow stops in
AWAITING_APPROVAL. A user with the APPROVER role approves the exact proposed ticket. - Execute once. One execution claims the workflow, creates the ticket through the provider (a
local mock ledger by default, or ServiceNow), and records the result. If the outcome is
uncertain, the workflow moves to
NEEDS_REVIEWinstead of retrying.
The score is additive and readable:
- +30: the CVE is in CISA’s Known Exploited Vulnerabilities catalog.
- +25: the asset is internet-exposed.
- +20: the asset is business-critical.
- +15: EPSS is 0.70 or higher.
- +10: CVSS is 9.0 or higher.
A score of 75 or more is Critical, with a 24-hour deadline. From 50 it is High (7 days), from 25
Medium (30 days), and below that Low (90 days).
Margin note: The weights and thresholds are in app/risk_engine.py at 557ec2b.
Architecture
The diagram redraws the project’s authority model. It shows only what the code enforces: untrusted data crosses into a server-controlled boundary, and the model sits outside that boundary.
The model’s only path back into the boundary is the ticket text. When the ticket is built, the model writes the short description, description, remediation and validation steps, and code sets the priority, risk rating, score, deadline and assignment group. So the model controls the ticket’s wording, never its priority, deadline, score or routing, and a human approves the exact ticket before anything executes. PostgreSQL holds the authoritative workflow state shared across instances. Prometheus and Grafana observe security events but have no authority, so a telemetry failure cannot change an outcome.
Security architecture
- Identity and roles. API callers authenticate with bearer tokens and hold the ANALYST or APPROVER role. A Microsoft Entra ID validator checks token issuer, audience, and signing keys. Retrieval access comes from the authenticated identity, so the model’s knowledge tool cannot ask for broader access.
- Tenant isolation. Every read and state change compares the caller’s tenant with the workflow’s tenant in the store layer.
- Constrained tools. The model sees an allowlisted, read-only tool set, with a cap on tool steps. Unknown and hidden tools are blocked.
- PostgreSQL. The runtime role is least-privilege: no superuser, no database creation, and no
CREATEon the public schema. State transitions use row locks and single-row conditional updates. TLS withverify-fullconnections is configured in Compose and covered by configuration tests only. - Containers. Images are pinned by digest, and the application runs as a non-root user. Compose
drops all Linux capabilities and adds back only the few that PostgreSQL’s startup and the TLS
setup need, and it sets
no-new-privilegeson every service. Every service except the API runs with a read-only root filesystem. - CI. The pipeline runs the tests and security evaluations, a dependency audit, a Gitleaks secret scan, and a runtime-image SBOM. Every action is pinned to a commit SHA.
- Residual risk. Because the model writes the ticket text, a successful prompt injection could influence that wording. The mitigations are injection detection on inputs and retrieved evidence, and human review of the exact, fingerprinted ticket before it is created.
Key design decisions
Deterministic risk, advisory AI
Risk is computed in code from KEV status, exposure, asset criticality, EPSS, and CVSS. The model only receives the result afterwards, and it cannot lower the score, change the deadline, skip review, or create a ticket. That makes every decision reproducible and auditable, and it means a prompt injection cannot downgrade a critical finding.
Tenant isolation in the application layer
Tenancy is enforced in the store layer on every read and state change, and cross-tenant tests run against PostgreSQL. The database does not enforce it yet. PostgreSQL row-level security is the next defense-in-depth step before any real multi-tenant deployment.
SQLite locally, PostgreSQL in production
SQLite keeps the demo free of credentials and services. PostgreSQL provides one shared authority across instances, for atomic claims and reconciliation. In production, a missing or incompatible schema fails closed. The service never silently falls back to SQLite.
Pattern-based injection detection
Pattern matching is predictable and easy to test, but safety does not depend on it. The model has no authority to approve or execute, so detection is one layer, and server-controlled authority is the actual boundary.
Approval bound to the exact ticket
An approval covers a SHA-256 fingerprint of the proposed ticket, serialized as canonical JSON. Any change to the ticket invalidates the approval. Only one execution can claim a workflow, and an external call that fails is not retried automatically.
Testing and evaluation
These results come from a run on 2026-12-01 at commit 557ec2b, using the commands CI uses, in a
clean environment with Python 3.14.6 and PostgreSQL 16.15.
Margin note: CI runs PostgreSQL 17. This verification used 16.15, the version available in the environment.
- Test suite (
pytest): 1943 passed, 0 failed, 0 skipped. That includes 93 PostgreSQL integration tests covering claim races, stale reconciliation, and cross-tenant denial. - Security evaluation (
vm_agent.py security-eval): 136 of 136 cases across 10 evaluators, and 7 of 7 standardized attack scenarios. - Dependency audit (
pip-auditwith CI’s flags): no known vulnerabilities in the pinned dependencies.
The security evaluation is a regression suite of synthetic adversarial cases written for this project. It checks that known attack patterns stay blocked and benign cases stay allowed. It is not a detection rate or a benchmark, and it says nothing about attacks it does not contain.
Some things have not been tested:
- Integrations: Tenable, ServiceNow, and Entra ID are tested only against simulated responses, and the OpenAI path needs a key.
- The Compose stack: it is covered by configuration tests only.
- The TLS-init container: its hardened setup has been exercised only with a stand-in image.
What I’d do differently
- Row-level security from the start, so the database enforces tenancy as well as the application.
- Authorize knowledge before embedding, not just before building the model’s context.
- Enterprise OIDC instead of demo bearer tokens.
- Move the mock ticket ledger out of the image’s data directory, so the API container can run with a read-only root filesystem too.
How it was built
I directed the security model, the trust boundaries, and which threats the tests cover. I built the project with AI coding assistants: primarily OpenAI’s Codex, and Anthropic’s Claude for later changes, including the dependency fix and the container hardening. I reviewed its code through tests, adversarial evaluations, CI security scans, and by reading the diffs.
Run it yourself
The demo needs no Tenable or OpenAI credentials and uses synthetic data. Neither command approves anything or calls an external system. CI uses Python 3.14.
git clone https://github.com/shabaaz3000-oss/ai-vulnerability-management-agent.git
cd ai-vulnerability-management-agent
python3 -m venv .venv && source .venv/bin/activate
python -m pip install -r requirements.txt
python vm_agent.py demo # score, advise and propose a ticket for a synthetic finding
python vm_agent.py security-eval # run the synthetic adversarial regression suite
Current status
Active, as a portfolio and engineering demonstration. It is not production-ready, and it has never processed real scanner data or connected to a live ServiceNow instance. The known limitations are:
- Tenancy: enforced in the application, with no database row-level security.
- API container: it keeps a writable root filesystem, because of the mock ticket ledger.
- TLS-init container: its hardened configuration has been tested only with a stand-in image.
- Authentication: demo bearer tokens rather than enterprise OIDC.
- Injection detection: pattern-based.
- Knowledge authorization: knowledge is authorized before the model’s context is built, not before embedding.
Evidence ledger
What exists today, kept separate from what is still in progress or not yet measured.
Shipped
- Deterministic risk engine; model output is advisory and cannot change risk, SLA, review or approval (tests pass at 557ec2b, 2026-12-01).
- Human approval bound to a SHA-256 fingerprint of the exact ticket, consumed once (tests pass).
- Single atomic execution claim in PostgreSQL; uncertain outcomes go to NEEDS_REVIEW, not a retry (tests pass on PostgreSQL 16).
- Tenant isolation in the application and store layer, with cross-tenant tests against PostgreSQL (tests pass).
- Pattern-based prompt-injection detection and RAG quarantine (tests pass).
- Test suite: 1943 passed, 0 failed, 0 skipped at 557ec2b on 2026-12-01 (pytest, Python 3.14.6, PostgreSQL 16.15).
- Security regression suite: 136 of 136 synthetic cases and 7 of 7 attack scenarios at 557ec2b on 2026-12-01.
- pip-audit with CI flags: no known vulnerabilities in pinned dependencies at 557ec2b on 2026-12-01.
- Credential-free demo runs with synthetic data (exit 0 at 557ec2b).
In progress
Nothing claimed.
Not yet evaluated
- Live Tenable, ServiceNow, Microsoft Entra ID and OpenAI integrations (mocked or not run; never used with real systems).
- The Compose stack: PostgreSQL TLS, hardened service runtimes, Prometheus and Grafana (configuration tests only).
- The hardened TLS-init container with the real image (exercised only with a stand-in).
- CI runtime-image SBOM and Gitleaks jobs (configured in CI; not run in this verification).
- Behavior with real scanner data, real multi-tenant traffic, or multi-host load.