18 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
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
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 48a3374e6c fix(refusal_classifier): read judge verdict on word boundaries (#350) 2026-10-18 19:08:48 +03:00
chiruu12 2f411b90dc fix(hybrid): guard zero total weight and log skipped detectors 2026-08-14 17:04:47 +05:30
Devam Shah d28c4b4b1e feat: config-pluggable refusal classifiers and leak detectors
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>
2026-06-22 19:40:33 +05:30
Alexander Myasoedov ead8f85836 feat(feat(refusal): detect Docker/K8s sandbox escape probes (#280)): 2026-06-04 18:28:12 +03:00
Edneam be7fb1f370 fix: keep PII detection separate from refusal metrics 2026-05-14 22:42:28 +05:30
Edneam d734067ef6 test: cover PII leak detector 2026-05-14 22:31:50 +05:30
Alexander Myasoedov bc7fdd7cfa fix(pc): 2026-01-28 21:04:29 +02:00
Alexander Myasoedov b38a27d78c feat: US-005 - Enhanced Refusal Detection with Hybrid Approach
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
2026-01-28 18:52:20 +02:00
Alexander Myasoedov 32f103acbc feat: US-001 - Dual-LLM Evaluation for Attack Success Detection
Add LLM-based refusal classifier inspired by Promptmap's dual-LLM
architecture. The controller LLM evaluates whether an attack succeeded
by analyzing the target's response against pass/fail conditions.

- Create LLMRefusalClassifier plugin integrating with existing system
- Support OpenAI and Anthropic providers with lazy initialization
- Add configurable system prompts and pass/fail conditions
- Include 20 unit tests for comprehensive coverage
2026-01-28 18:18:09 +02:00
Alexander Myasoedov ce7636fe9e feat(restruct tests): 2025-12-26 22:58:21 +02:00