- 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.
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.
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.
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.
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.
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.
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.
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.
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.
`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
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.
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.
PIIDetector and SandboxEscapeDetector were wired directly in
probe_actor/refusal.py and the refusal classifier manager was populated from
a hardcoded list, so the only way to toggle a bundled detector or add an
organization-specific signature was to patch the module.
Add a DetectorRegistry mapping plugin names to factories, assembled from an
agentic_security.toml [detectors] section via build_from_config. Custom
detectors load by import path ("pkg.module:ClassName"). refusal.py gains
build_refusal_manager(config=None) reading the [detectors] table; all public
symbols are preserved. Built-in leak detectors ship registered but disabled,
so default refusal_heuristic behaviour is unchanged.
Closes#82
Signed-off-by: Devam Shah <devamshah91@gmail.com>
CORS: drop allow_credentials=True. With allow_origins=['*'] Starlette reflects
the request Origin and emits Access-Control-Allow-Credentials: true on any
credentialed request — a reflect-any-origin hole. The app authenticates with
Bearer tokens in the Authorization header, so credentialed CORS was never needed.
/icons/{icon_name}: validate against a strict allowlist (re.fullmatch
[A-Za-z0-9._-]+\.png) and assert the resolved path stays inside ICONS_DIR before
any filesystem write or outbound fetch. Closes the path-traversal / arbitrary-write
(CWE-22) and controlled-URL (CWE-73) surface on the unsanitized icon_name.
Adds CORS middleware tests and icon-name validation tests (traversal, encoded
slash, null byte, trailing newline, wrong extension).
Closes#298
Signed-off-by: Devam Shah <devamshah91@gmail.com>
Implement hybrid refusal classifier combining multiple detection methods:
- Add confidence scoring to refusal detection (HybridResult)
- Implement weighted voting with configurable thresholds
- Support require_unanimous mode for strict classification
- Add factory function create_hybrid_classifier for common setup
- Include 32 unit tests with table-driven test patterns
Create unified provider abstraction layer for direct LLM integrations beyond
HTTP specs, inspired by FuzzyAI's comprehensive provider system.
- Add BaseLLMProvider abstract class with standard interface (generate, chat,
sync_generate, sync_chat methods)
- Implement OpenAIProvider supporting chat completions API
- Implement AnthropicProvider supporting messages API
- Create provider factory for instantiation by name (create_provider,
get_provider_class)
- Add 60 unit tests covering all provider implementations