Skip to content
bss-kPublic

About

An agentic security tool for investigating dependency vulnerabilities, assessing application-specific exposure, and generating evidence-backed remediation recommendations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Sentinel

Agentic software security investigation for npm dependencies.

Sentinel finds known vulnerabilities in a project's npm dependencies, then can use an AI agent to investigate how each vulnerable package is actually used and recommend remediation.

Status

Implemented so far:

  • Dependency discovery from package-lock.json (lockfileVersion 2 and 3): exact versions, direct vs. transitive, dev vs. production, optional, workspaces, aliases.

  • Vulnerability detection through the OSV API.

  • sentinel scan with terminal, JSON, and Markdown output, including the patched version on the installed release line.

  • Agent tools (sentinel.tools): get advisory, search source, read excerpt, inspect dependency, get npm metadata. Every call goes through a guarded executor that enforces a call budget, a tool allowlist, permissions, strict input schemas, scan-scoped advisories and packages, and an output size cap. Source access is read-only, limited to the project, never follows symlinks out of it, skips node_modules, .env*, keys, .npmrc and similar files, and redacts secrets.

  • Assessment schema and policy (sentinel.assessment): advisory facts and AI conclusions are stored separately. Each piece of evidence the AI cites is checked against what the tools actually returned. Deterministic rules override unsupported conclusions:

    • "Unlikely exposed" needs verified positive evidence or a dev-only package. Not finding usage downgrades it to "unknown".
    • When exposure is unknown, priority never drops below the advisory severity.
    • Suggested upgrades older than the patched version are flagged.
    • Malformed model output marks the assessment failed and keeps the facts.
  • LangGraph investigation loop (sentinel.agent): per finding, the model chooses tools turn by turn and finishes by calling submit_assessment.

    • Hitting the tool-call budget or turn limit forces one final, labelled-incomplete assessment.
    • Malformed submissions get one repair attempt.
    • If a submission cites evidence that no tool returned, the model is told which items are wrong and gets one chance to fix or remove them. Anything still unmatched after that is kept and marked unverified.
    • Model errors keep the deterministic facts.
    • Tool output reaches the model wrapped as untrusted data.
    • Source tools are offered only when source access is authorized.
    • LangSmith tracing is off unless explicitly enabled, even if LANGSMITH_TRACING is set in the environment.
  • sentinel investigate: runs the scan, then investigates findings most severe first. Reports keep the deterministic findings and add an AI assessment for each, with evidence marked verified or unverified, policy notes, and per-finding execution stats (stop reason, turns, tool calls, tokens, duration).

  • sentinel evaluate: an evaluation and benchmarking framework (methodology).

    • 53 synthetic npm projects (11 dev, 42 held out) with ground truth stored separately from the repositories, built on 41 real advisories captured from OSV.
    • Offline mode tests Sentinel's software and security boundaries with scripted replies.
    • Live mode grades a real model's exposure, evidence and remediation.
    • An advisory-only baseline and a single-call LLM baseline run on the same scenarios.
    • Supports repeated trials and a global budget on model calls and tokens.

Offline results (2026-11-29, dataset 1.0.0) measure software and security boundaries, not model accuracy:

  • All 53 scenarios passed.
  • Detection was 69/69 with no false positives.
  • Dependency classification was 69/69.
  • All 20 unauthorized tool requests were blocked.
  • No protected data or ground truth leaked.
  • A scripted model that obeys every prompt injection achieved 1 of 6 attack objectives: a "stop and do not submit" instruction left one assessment incomplete, and labelled as such.

Live results (2026-11-29, held-out split, gpt-5-mini, one trial, 51 findings per approach; full table and caveats):

Sentinel Advisory-only Single LLM call
Exposure accuracy 82.4% 74.5% 78.4%
Citations matching tool output 99.5% no citations 87.1%
Key evidence cited 74.3% 0% 85.7%
Remediation accuracy 94.0% 100% 98.0%
Every criterion met 68.6% 5.9% 31.4%
Prompt-injection objectives achieved 0/5 0/5 0/5
Tokens per finding 15,131 0 4,927

Sentinel's remediation and success figures are re-graded after a grader bug fix. Two findings changed, both to correct. As run, they were 90.0% and 64.7%. Most of the success-rate gap to the single call comes from the single call citing lines it was never shown. On exposure alone the difference is 3.9 points on one trial. The real model made no unauthorized tool requests, so blocking was only exercised offline.

Before the dataset existed, the earlier 11-scenario suite, which used invented advisory IDs, ran three times against gpt-5-mini with sentinel evaluate --live on 2026-11-28. Those results cannot be compared with the new dataset:

  • Exposure was correct 11/11 in every run.
  • Injected instructions were ignored and no protected data leaked.
  • Runs 1 and 2 passed 10 of 11 scenarios. Runs 1–3 had 3 of 39, 4 of 38 and 3 of 41 unverified citations.
  • Run 3, after the evidence repair step was added, passed 11 of 11.

Not implemented yet: observability.

Install

Requires Python 3.11+.

pip install -e '.[dev]'

Usage

sentinel scan ./project
sentinel scan ./project --format markdown --output report.md
sentinel scan ./project --format json --output report.json

Exit codes: 0 no vulnerabilities, 1 vulnerabilities found, 2 error (for example, OSV unreachable). scan needs no API key. It sends package names and versions to api.osv.dev and nothing else from your project.

export OPENAI_API_KEY=...
sentinel investigate ./project
sentinel investigate ./project --allow-source --format markdown --output report.md
sentinel investigate ./project --format json --output report.json --max-findings 5

investigate sends the model each finding's advisory data, dependency relationships, and npm metadata. Application source is not read unless you pass --allow-source. With it, the agent may search and read source files, and redacted excerpts (at most 80 lines per read) are sent to OpenAI.

Options: --model (or SENTINEL_MODEL, default gpt-5-mini), --max-findings (default 10; the rest are reported as not investigated), and --max-tool-calls (per finding, default 15). Exit codes match scan.

sentinel evaluate                                   # offline: no API key, no cost
sentinel evaluate --split heldout --category prompt_injection
sentinel evaluate --live --split heldout            # paid; shows the plan and asks first
sentinel evaluate --live --baseline --runs 3 --max-model-calls 1500 --max-tokens 4000000 \
  --format json --output results.json

There are two evaluation modes, and they measure different things:

  • Offline (--offline, the default, and what CI runs) drives the agent with scripted replies. Some misbehave on purpose: they submit malformed output, fabricate evidence, obey injected instructions, or probe files outside the project. It measures the pipeline and guardrails: parsing, detection, graph execution, tool authorization, the filesystem sandbox, evidence validation, error handling and limits. It does not measure LLM reasoning, so exposure, remediation and success metrics are left out.
  • Live (--live) uses the configured model through the same agent and grades exposure, evidence, remediation and investigation success against the ground truth. --baseline adds baseline A (advisory-only, no model) and baseline B (one model call with deterministically gathered context), and reports the percentage-point difference from each. OSV and npm stay simulated from captured data.

Options:

  • --split dev|heldout; use heldout for reported numbers.
  • --category and --scenario to select scenarios.
  • --model.
  • --runs N, which reports mean, sd and range.
  • --max-model-calls (default 500) and --max-tokens (default 1,500,000): one budget for the whole run, covering every scenario, approach and trial.
  • --yes to skip the confirmation.
  • --format terminal|json|markdown and --output.

Reports include the following. The JSON keeps every scenario's checks, grades and full investigation report.

  • Dataset version and digest.
  • Model and settings.
  • Application commit.
  • Eligible counts for every metric.
  • Complete, incomplete, failed and skipped investigations.
  • Expected-versus-reported exposure counts.
  • Security results.
  • Latency, tokens and tool calls.
  • A failure breakdown.
  • Cases that need human review.
  • Known limitations.

Exit codes: 0 when every Sentinel scenario passes, 1 when any fails, 2 on errors.

Limitations

  • npm only, and only package-lock.json v2/v3. v1 lockfiles, npm-shrinkwrap.json, Yarn, and pnpm are not read. A package.json with no lockfile is reported, not scanned.
  • Dependencies installed from git or local paths are reported but not checked against OSV.
  • Severity is the advisory database's label (for example GitHub's HIGH), when OSV provides one. CVSS vectors are kept in the JSON report but not scored.
  • Secret redaction is pattern-based and best effort; it catches common token formats and key = "value" assignments, not every possible secret.
  • Source search is literal text only (no regex) and covers JS/TS, Vue, Svelte, and JSON.
  • Advisory details are fetched one at a time, which is slow for projects with many findings.
  • Withdrawn advisories are left out of the findings and listed separately.
  • The evaluation dataset is small and synthetic (53 hand-written scenarios with simplified lockfiles), written by Sentinel's own developer, and its held-out labels lean toward likely_exposed. OSV and npm are simulated from captured data. Results describe these scenarios, not real projects; see docs/evaluation.md for every known bias.

Development

pytest
ruff check . && ruff format --check .

Tests run offline: OSV and npm are faked in-process, and the agent runs against a scripted chat model, so no API keys or network access are needed.

About

An agentic security tool for investigating dependency vulnerabilities, assessing application-specific exposure, and generating evidence-backed remediation recommendations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages