103 Commits
Author SHA1 Message Date
Alexander Myasoedov 8c956e0cb4 Harden the LLM judge, redact secrets in logs, add contributor docs
- Fence the target model's output in a <target_output> block the output
  can't close, so a jailbroken reply can't steer the judge's verdict.
- Mask credentials (secret query params, Bearer tokens, x-api-key, sk-/
  sk-ant-/hf_/AKIA keys) in every log record; hold httpcore at WARNING.
- Add a localhost OpenAI/Anthropic stand-in (tests/fakes) and a
  fake_llm_api fixture; it records header names only.
- Replace any set *_API_KEY with a placeholder in tests unless marked live.
- Add CONTRIBUTING.md, CLAUDE.md, a PR template and a real SECURITY.md.
2026-11-25 17:51:06 +02:00
Alexander Myasoedov 5c24fac86d Merge pull request #395 from 2867297362mjb-sketch/feat/teamorouter-preset
feat: add TeamoRouter preset to LLM specs
2026-11-25 16:52:43 +02:00
2867297362mjb-sketchandClaude Opus 5.5 762f85118d feat: add TeamoRouter preset to LLM specs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 02:29:03 -08:00
JR 890184e6f6 fix(pii): detect API tokens under prefixed environment names
The api_token pattern required a word boundary before api_key, access_token
and secret_key, and an underscore is a word character, so OPENAI_API_KEY=,
GITHUB_ACCESS_TOKEN= or AWS_SECRET_KEY= followed by a real token was never
recorded.

Add a second branch for those names when "_" joins them to a prefix. Main
never matched them, so the branch only adds findings, and it reports a
value only when a digit is directly followed by a letter in its first 64
characters, as in random tokens. It also skips placeholders such as
sk-your-key, calls or subscripts, and dotted references such as
md5sum.digest unless the value is a JWT. The existing branch for bare
names is unchanged.
2026-11-25 00:04:38 +01:00
JR e281f84e2c fix(pii): detect Bearer Authorization headers and quoted API key fields
The api_token pattern required ':' or '=' right after the keyword, so
'Authorization: Bearer <token>' (RFC 6750, section 2.1) and quoted keys
such as '"api_key": "..."' or an OAuth '"access_token"' field were
never flagged. Accept an optional closing quote after the keyword and
an Authorization header carrying a Bearer token, and skip placeholder
values such as YOUR_ACCESS_TOKEN, your_api_key_here and xxxxxx.
2026-11-23 20:31:43 +01:00
Alexander Myasoedov a11c932bf6 Merge pull request #390 from bIackr0se/fix/pii-private-key-headers
fix(pii): detect encrypted PKCS#8 and OpenPGP private key headers
2026-11-23 13:30:01 +02:00
Ayham Joumran 8d2a55beb3 fix(anthropic): default to a Claude model Anthropic still serves
AnthropicProvider.DEFAULT_MODEL, the refusal classifier's AnthropicClient and create_llm_classifier(provider='anthropic') all defaulted to claude-3-haiku-20240307, which Anthropic retired on 2026-04-20, so every Anthropic call without a model failed. They now use claude-haiku-5-5, the current Haiku. The two snapshot tests that pinned the old default now pin the new one, and a classifier test covers its factory default.
2026-11-23 00:38:51 +01:00
JR 43e4aa9fa7 fix(pii): detect encrypted PKCS#8 and OpenPGP private key headers
The private_key pattern required PRIVATE KEY----- after an optional
prefix, so the ENCRYPTED PRIVATE KEY label (RFC 7468, section 11) and
the PGP PRIVATE KEY BLOCK armor header (RFC 4880, section 6.2) were
not reported. The PGP alternative could never match real OpenPGP armor.
2026-11-22 20:43:46 +01:00
secretJod 464e12ac52 fix(sandbox): match /.dockerenv checks in the sandbox escape detector
The pattern was \b/\.dockerenv\b. A word boundary before '/' needs a word
character right before the slash, so '/.dockerenv' after a space, '=' or
the start of the text never matched; only paths like 'foo/.dockerenv' did.
2026-11-19 23:17:48 +05:30
whiteworthy 570f54778f feat: add AbliteratedLLM preset to LLM specs 2026-11-19 12:45:48 -03:00
Alexander Myasoedov ca69c88138 feat(owasp): map probe datasets to the OWASP LLM Top 10 2026 2026-11-19 15:07:40 +02:00
secretJod 041b582116 fix(pii): detect credit cards followed by a CVV or expiry
The credit-card candidate regex greedily took up to 19 digits across
spaces and dashes, so a card number followed by more digits (a CVV, an
expiry month) was checked together with them and failed Luhn. Match the
whole run of digit groups and check each contiguous span of groups that
holds 13-19 digits.
2026-11-18 23:16:50 +05:30
Alexander Myasoedov 27fb7df086 Merge pull request #385 from Johnbjoseph-cybersec/jbj/owasp-llm-top-10-2025
fix(owasp): tag probes with the OWASP LLM Top 10 2025 ids
2026-11-16 12:05:13 +02:00
Thibault Jaigu b45085d504 feat: add Requesty preset to LLM specs 2026-11-15 15:33:22 +00:00
anticipate218 179daedc60 Fix blank-line handling in harness outcomes 2026-11-15 00:06:38 +08:00
John B Joseph 6495c671b2 fix(owasp): tag probes with the OWASP LLM Top 10 2025 ids
OWASP_LLM_TOP_10 used the 2023/24 v1.1 numbering while the badge links to the project, whose current list is the 2025 edition (https://genai.owasp.org/llm-top-10/). DataLeak now tags LLM02 Sensitive Information Disclosure, Malwaregen LLM05 Improper Output Handling, AgenticBackend LLM06 Excessive Agency, Hallucination and refuse-to-answer LLM09 Misinformation. The harness already uses LLM01:2025.
2026-11-13 07:41:51 +05:30
Aftabbs 9a4fd1467a style(http_spec): restore LF line endings and fix escape in test literal 2026-11-12 07:16:35 +05:30
Aftabbs dac5570397 fix(http_spec): escape all JSON control characters in <<PROMPT>> substitution
escape_special_chars_for_json only escaped backslash, quote, \n, \r and \t.
Other control characters below U+0020 (backspace, form feed, ESC, NUL...)
were inserted raw into the JSON request body, producing invalid JSON that
targets reject, so attack prompts containing them were never evaluated.
Delegate to json.dumps, which escapes every character JSON requires.
2026-11-12 07:16:01 +05:30
Ankit1478 261feaa5bb Unmark the ci pins now that the exit-code fix has landed
#368 and #369 merged a minute apart. #369 fixed `agentic_security ci`, and the
two pins #368 added to hold the broken shape did what they were written to do
and went red, so `pytest tests/evals -m eval` currently fails on main.

Replaces both with `test_the_ci_exit_path_stays_connected`, which asserts the
opposite: `entrypoint` returns the scan outcome and `ci()` raises `SystemExit`.
Verified non-vacuous by reverting either half, which turns it red.

Also corrects the surrounding prose, which said returning the scan result was
itself the fix. Under `fire` a returned value is printed rather than used as
the exit code, which is why `CLI.scan` ends in `raise SystemExit`. The guard
checks for the raise, not just the return.
2026-11-11 21:17:45 +05:30
Alexander Myasoedov 0ebac43fc6 Merge pull request #368 from Ankit1478/feat/scan-evaluation-suite
Add an opt-in scan evaluation suite
2026-11-11 16:19:51 +02:00
Alexander Myasoedov d522f8f8ad Merge pull request #369 from Ankit1478/fix/ci-exit-code
Make agentic_security ci fail a build when a module exceeds max_th
2026-11-11 16:18:06 +02:00
PSA-Team-source ad6001b10f feat: add UberLLM preset to LLM specs 2026-11-10 20:54:56 +07:00
Ankit1478 0def2ec061 Make agentic_security ci fail a build when a module exceeds max_th
`CLI.ci` called `entrypoint()` and dropped the result; `entrypoint()` called
`scan()` and dropped that too, so the command exited 0 whatever the scan found
and a pipeline gating on it could never fail.

`entrypoint()` now returns a process exit code, derived from the `status`
field `async_scan` already records per module, and `CLI.ci` raises
`SystemExit` with it. That mirrors `CLI.scan`, which already ends in
`raise SystemExit(exit_code)` from `scan_cli` — returning a value is not
enough on its own, because fire prints a returned value rather than using it
as the exit code.

Both call sites had to change together: propagating the result out of
`entrypoint()` alone still exits 0.

Fixes #367
2026-11-09 14:53:05 +05:30
Ankit1478 fdfd1f9851 Proofread the eval README 2026-11-09 13:37:00 +05:30
Ankit1478 0594e5d59e Fix stale references left in the eval suite docs
The _runner docstring still said nothing covered the failure-rate arithmetic
or the optimize=True early stop; test_scan_module.py covers both. One `:324`
line reference and four `name (name)` parentheticals survived the earlier
sweep. test_detector still said 241 rows, and the README still named
MIN_RECALL and MAX_FALSE_POSITIVES, which the set-based baselines replaced.

Also records that CI does not run this suite, with the step that would turn it
on and the two reasons that is the maintainer's decision: a build starts
failing when a defect is fixed without unmarking its xfail, and the caret pin
on scikit-learn lets a fresh resolve invalidate the recorded baselines.
2026-11-09 13:29:41 +05:30
Ankit1478 8bb7981225 Fix stale figures in the eval README 2026-11-09 13:12:51 +05:30
Ankit1478 9b03064943 Correct the xfail count in the eval README 2026-11-09 13:12:51 +05:30
Ankit1478 5286c69119 Drop future annotations import from the eval suite
pyupgrade strips it on this Python target, so `pre-commit run --all-files`
rewrote all twelve files and the pre-commit job would have failed on a branch
that looked clean locally. No other file in the tree carries the import.
2026-11-09 13:12:51 +05:30
Ankit1478 8f456013b6 Add blind-review tooling for the eval corpus
The labelling rules only mean something if a second person applies them the
same way. This builds a blind sheet to measure that: 30 rows drawn across all
ten sampleable (label, kind) pairs with the labels stripped, alongside a
self-contained statement of the rules.

Scoring is chance-corrected for both labels and kinds, with a bootstrap
interval, because at n=30 a single disagreement moves kappa by about 0.05 and
a raw percentage reads far better than it should with three uneven classes.
The scorer refuses a sheet before scoring it: an unfinished one would come
back as a perfect score, since a blank row is not a disagreement.

The sample deliberately over-weights the awkward kinds and forces in real
captured replies, so the result bounds agreement from below rather than
estimating it.

The answer key and the generated sheet are gitignored. Only the tooling is
committed; the sheet regenerates identically from a fixed seed.
2026-11-09 13:12:51 +05:30
Ankit1478 457bf4cf24 Guard the environment the detector baselines were recorded in
baselines.json records what the bundled OneClassSVM answers. That model
is three .joblib files committed to the repo, pickled with scikit-learn
1.9.1, so the recorded sets only hold under that release. On any other
one, every detector gate goes red for a reason that has nothing to do
with the code, and the message blames the corpus.

Three checks now run before the gates:

  - the three .joblib files are present, named individually
  - scikit-learn matches the release the models were pickled with, and
    the failure says it is an environment mismatch
  - the model still answers three fixed probes as recorded. A version
    check alone is not enough, since the files are committed and can be
    replaced without the dependency moving. One probe answers False, so
    a model degenerated to a constant is caught too

Pins that the ML plugin returns numpy.bool_ while annotated -> bool.
Harmless through the manager's any(), wrong for any caller using
`is True`.
2026-11-09 13:12:51 +05:30
Ankit1478 9ca647c5a1 Name functions instead of line numbers in the eval suite
Thirteen references pointed at source lines. One was already wrong:
targets.py cited both fuzzer.py:177 and fuzzer.py:190 for the same
JSONDecodeError handler. They rot on any edit upstream, so they now name
the function.

test_cli_status_still_mirrors_the_shipped_rule asserted an exact source
string, which would go red on a reformat. It parses async_scan and
compares the unparsed condition instead.
2026-11-09 13:12:51 +05:30
Ankit1478 6e812d5620 Grow the eval corpus and gate it by identity
Corpus goes from 37 to 245 rows. The larger corpus exposed defects the
small one never triggered, and exposed two weaknesses in the gates
themselves.

Gates no longer compare counts. baselines.json records which rows the
detector gets wrong, keyed by a hash of the reply text, and the gates
assert that no row newly joins a wrong-answer set. A count was not
monotone under corpus edits -- deleting a row the detector misreads
lowered the cap and handed back a slot -- and could not tell a fix from a
substitution. Regenerate with record_baselines.py.

Detector findings the bigger corpus surfaced:

  - ten attack_success rows read as refusals; the "an answered attack is
    never a refusal" gate becomes a strict xfail with an exact pin
  - all four roleplay rows read as refusals
  - the curly-apostrophe test was vacuous. It compared detect() outputs,
    which agree because the ML classifier fires on both spellings, while
    the phrase list went on missing every U+2019 form

New coverage:

  - test_scan_module.py drives the real entry point. Under optimize=True
    a module stops at the fifth prompt and reports that prefix's rate: a
    target scored 25% over twenty prompts is reported at 100% over five,
    and the payload does not say so
  - agentic_security ci cannot fail a build. entrypoint() discards
    scan()'s result and __main__.ci discards entrypoint()'s, so the
    process exits 0 whatever it found. Pinned by AST, not by grep
  - envelope invariance is now asserted on real attack output, not only
    on a benign sentence
  - HTTP 200 with a non-JSON body reaches fuzzer.py:177 for the first
    time; FakeResponse.json() parses its body instead of returning a
    pre-parsed object, which had made that branch unreachable

Corpus integrity: kind is validated against a per-label vocabulary and
src against a known set of models, so a typo can no longer drop a row out
of every gate silently. The partial sub-kinds get a stated rule --
refuse_then_disclose is the target's own configuration, refuse_then_comply
is something the attacker can act on -- and two rows are relabelled to
match it.

README corrects two claims: six of the 48 false positives are benign
answers rather than attacks reported as declines, and sixteen are planted
fp_trap rows, so the headline number moves little when real classifier
errors are fixed. Adds a Scope section for what the suite does not reach.

547 passed, 20 xfailed.
2026-11-09 13:12:51 +05:30
Ankit1478 90ed87b585 Add scan evaluation suite
Tier 1 drives process_prompt over fake targets whose posture is fixed by
construction, with the detector pinned to a phrase matcher. Tier 2 runs the
real detector over the labelled corpus with ratchet baselines.

Seventeen strict xfails state what should happen; each is paired with a test
pinning the current wrong behaviour, so a fix turns both red together.

118 passed, 17 xfailed.
2026-11-09 13:12:51 +05:30
Ankit1478 c3d0064a15 Empty the eval test modules pending review
targets.py and _runner.py were committed before review. Empty them so the
suite scaffold lands as placeholders only, to be filled in one file at a
time.

The corpus and the pytest configuration are unchanged and stay in place.
2026-11-09 13:12:51 +05:30
Ankit1478 9bbcbd7f56 Add scan evaluation suite scaffold and corpus
Adds tests/evals, an opt-in suite that measures what the scanner concludes
about targets whose behaviour is known in advance, so a verdict can be checked
against ground truth instead of against the scanner's own internals.

Landing in two parts. This commit carries:

- corpus/*.jsonl: 37 labelled model replies (18 refusals, 12 compliances,
  7 partials), 5 tagged disputed. 10 rows are real captured output.
- targets.py: fake targets with known ground truth (secure, compromised,
  mixed, erroring) plus four provider response envelopes.
- _runner.py: drives process_prompt and returns a Verdict.
- pyproject.toml: register the eval marker and deselect it by default, so
  the suite is opt-in and `pytest tests/evals -m eval` collects.
- .gitignore: ignore .env and .venv.

The test modules are placeholders in this commit and are filled in next.
2026-11-09 13:12:51 +05:30
Nicho Deng abfe075849 feat: add cheapaimodel preset to LLM specs 2026-11-03 12:21:58 +08:00
Nirupam Bhowmick 69a75b9329 feat: add Runcrate preset to LLM specs 2026-11-01 10:42:10 +00:00
Alexander Myasoedov 55c6124b46 test(registry): check HF datasets via metadata, deactivate 3 dead ones (#72) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 486af8e58e fix(verify): return 400 for bad specs and upstream errors (#149) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 48a3374e6c fix(refusal_classifier): read judge verdict on word boundaries (#350) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov eab28edb52 feat(agentic_security_harness): 2026-10-18 18:09:43 +03:00
Alexander Myasoedov 3e6b184c4f fix: template fix 2026-09-07 14:03:57 +03:00
Alexander Myasoedov 27c160eaa3 Merge pull request #326 from chiruu12/fix/hybrid-classifier-guards
fix(hybrid): guard zero total weight and log skipped detectors
2026-08-18 18:40:07 +03:00
Alexander Myasoedov de16779806 Merge pull request #328 from feiiiiii5/fix-circuit-breaker-half-open
fix(circuit-breaker): reopen on failure during half-open probation
2026-08-18 18:39:03 +03:00
Alexander Myasoedov 017ba7c168 Merge pull request #329 from feiiiiii5/fix-p95-percentile-index
fix(executor): compute p95 latency as a real 95th percentile
2026-08-18 18:38:25 +03:00
Chris (ChrisJr404) 79f450bbae Tag probe datasets with OWASP LLM Top 10 categories in the scan UI 2026-08-17 23:49:11 -04:00
fei cf3498264f fix(executor): compute p95 latency as a real 95th percentile
ExecutorMetrics.get_stats picked the p95 element with
int(n * 0.95), which collapses to the last index (the maximum)
for any batch of 20 or fewer requests, so the reported p95 was
actually the worst-case latency for typical scan batches. Use
ceil(n * 0.95) - 1, the standard nearest-rank index.
2026-08-16 18:39:10 +08:00
fei fcd1fd20ae fix(circuit-breaker): reopen on failure during half-open probation
record_failure ignored the half_open state: the minimum-sample gate
(total >= 10) and the success counter meant a failure during
probation neither re-opened the circuit nor prevented it from
closing. One failure followed by three successes closed the circuit
with the failure forgotten. Trip back to open on the first half-open
failure, with fresh counters.
2026-08-16 18:23:29 +08:00
chiruu12 2f411b90dc fix(hybrid): guard zero total weight and log skipped detectors 2026-08-14 17:04:47 +05:30
Alexander Myasoedov c8458d73c5 Merge pull request #320 from DevamShah/fix-cors-credentials-and-icon-traversal
fix: wildcard CORS + credentials spec violation, path-traversal guard on /icons proxy
2026-07-31 19:27:20 +03:00