Skill ID
security/prompt_injection_firewall
Current manifest version
0.1.0
Proposed change
Summary
Upgrade security/prompt_injection_firewall from the solid v0.1.0 offline Layer-1 scanner (merged via #267 / #46) to a production-grade v0.2.0 trust-boundary skill: same offline / no-LLM-auditor posture, but stronger evasion coverage, better false-positive control, richer operator telemetry, a realistic fixture corpus, and clearer deployment guidance.
This stays a deterministic, zero-network, zero-key skill. Do not add cloud LLM-as-judge paths. Optional local ML later stays out of scope unless explicitly approved.
Baseline (current v0.1.0)
- Offline scanners: hidden HTML/CSS + HTML/MD comments, zero-width/bidi/tag/VS, confusables skeleton (221 mappings), nested decode ≤3 (base64/hex/percent), 17-pattern lexicon (6 families)
- Verdict:
strict|balanced|lenient + critical-exfil floor; mention-vs-use downgrade for quoted negation strings
- Outputs:
is_safe, risk_level, detected_threat, findings[], sanitized_text, offline, sensitivity
- Bundle goldens + maintainer loader tests; demo + docs/extras wiring under
security/
Known gaps from v0.1 review / live smokes:
- Quoted critical exfil phrases in explanatory prose still trip
unsafe (mention-vs-use incomplete)
- No ROT13 / leetspeak / typoglycemia / reversed-text evasion pass
- No input length / blob-density soft caps
- Encoded findings lack decode-chain metadata operators can audit
- Fixture set is unit-style only (thin benign security-writing corpus)
- Docs lack a crisp “where to put this in the agent loop” deployment section
Industry alignment (v0.2 target)
Treat this as OWASP LLM01 Layer-1 input control (normalize → decode → detect → sanitize), not a full AI gateway:
- Unicode NFKC + invisible strip + confusable/skeleton folding before matching (OWASP cheat sheet)
- Re-evaluate decoded payloads as fresh untrusted input (nested encoding)
- Prefer explainable allow / flag / block semantics over brittle single-regex deny lists
- Honest limits: lexical/heuristic Layer-1 cannot stop novel semantic paraphrases — document defense-in-depth (constitution, tool scoping, HITL)
Useful OSS reference patterns (inspiration only — keep Skillware-authored KB; no verbatim third-party corpus import without license review): PromptShield / PromptScreen / prompt-protection / navi-sanitize / prompt-injection-sanitizer style pipelines.
Proposed v0.2 workstreams
A. False-positive control (must)
- Broaden mention-vs-use so clearly quoted / fenced critical exfil and other high lexicon hits are downgraded when strong discourse markers are present (security blogs, tutorials, red-team notes) — without weakening hidden/encoded detections.
- Add golden fixtures: benign security-writing samples that must stay
is_safe=true at balanced.
- Document the rule in
instructions.md + catalog (what gets downgraded vs what never does).
B. Evasion coverage (must)
Expand offline detectors + goldens for:
- Leetspeak / digit-letter substitution on lexicon phrases (
1gnore, pr1nt your system pr0mpt)
- Typoglycemia / light scramble (bounded edit-distance on high-signal keywords — keep deterministic and capped)
- ROT13 (and optionally simple reversed-token) decode-then-rescan, depth-bounded like existing encodings
- Mixed-script density warning when Latin + lookalike scripts co-occur in instruction-like spans
- Markdown / HTML exfil channels worth a first cut: markdown image URLs with suspicious query payloads,
data: URIs carrying instruction-like text (keep FP-controlled)
Keep requirements: [] unless a tiny well-justified stdlib-only approach fails; prefer no new deps.
C. Operator telemetry + sanitize quality (must)
- Extend encoded findings with audit fields, e.g.
decoded_layers, decode_chain (percent→base64), optional decoded_preview (truncated, redacted).
- Surface
removed_span_count (and/or sanitized vs original length delta) on unsafe results.
- Optional additive output (backward compatible):
policy_action = allow|flag|block derived from sensitivity + verdict (flag = findings present but is_safe=true after downgrade). Keep existing fields stable.
D. Resource / DoS hygiene (must)
- Document and enforce soft limits: max
source_text chars; max decode candidate count; max decode bytes (already partially present — make consistent and tested).
- Structured
INVALID_INPUT (or existing error shape if introduced carefully) when limits exceeded — fail closed without hanging.
E. Fixture corpus + tests (must)
Add under skill bundle (or tests/fixtures/… if preferred):
fixtures/benign/ — security docs / quoted attacks / research prose
fixtures/adversarial/ — hidden HTML, VS/emoji, confusables, nested encodings, leet/ROT13, markdown-smuggle samples
- Bundle tests parametrize over fixtures; keep offline/mocked; no network
Optional maintainer integration file can stay thin; corpus should ship with the skill where practical.
F. Docs / examples / agent contract (must)
- Catalog +
instructions.md: Recommended deployment pattern — run before RAG chunk inject, HTML/PDF summarization, email/chat ingest, tool/MCP metadata handoff; companion to compliance/pii_masker.
- Expand demo scenarios for FP control + one new evasion case.
- Align
card.json / card UI fixture if new additive output keys are shown on the card.
- CHANGELOG
[Unreleased]; bump manifest to 0.2.0.
G. Explicit non-goals (keep out of 0.2 unless re-scoped)
- Cloud / remote LLM auditor (
use_llm_evaluator-style)
- Shipping large third-party jailbreak corpora verbatim (license risk) — Skillware-authored or clearly licensed subsets only
- Full semantic paraphrasing defense / multilingual deep NLU
- Becoming a general HTML sanitizer or WAF
- Moving category again (stays
security/)
Acceptance criteria
Suggested split (if too large for one PR)
- PR-A (0.2.0a): FP control + fixtures/benign + docs deployment section
- PR-B (0.2.0b): evasion detectors (leet/ROT13/scramble) + adversarial fixtures
- PR-C (0.2.0): telemetry + limits + card/docs polish
Prefer one PR if scope stays reviewable; otherwise open sub-issues with Parent: #<this-issue>.
References
Breaking change?
No — backward compatible
Likely touch points
Skill ID
security/prompt_injection_firewall
Current manifest version
0.1.0
Proposed change
Summary
Upgrade
security/prompt_injection_firewallfrom the solid v0.1.0 offline Layer-1 scanner (merged via #267 / #46) to a production-grade v0.2.0 trust-boundary skill: same offline / no-LLM-auditor posture, but stronger evasion coverage, better false-positive control, richer operator telemetry, a realistic fixture corpus, and clearer deployment guidance.This stays a deterministic, zero-network, zero-key skill. Do not add cloud LLM-as-judge paths. Optional local ML later stays out of scope unless explicitly approved.
Baseline (current v0.1.0)
strict|balanced|lenient+ critical-exfil floor; mention-vs-use downgrade for quoted negation stringsis_safe,risk_level,detected_threat,findings[],sanitized_text,offline,sensitivitysecurity/Known gaps from v0.1 review / live smokes:
unsafe(mention-vs-use incomplete)Industry alignment (v0.2 target)
Treat this as OWASP LLM01 Layer-1 input control (normalize → decode → detect → sanitize), not a full AI gateway:
Useful OSS reference patterns (inspiration only — keep Skillware-authored KB; no verbatim third-party corpus import without license review): PromptShield / PromptScreen / prompt-protection / navi-sanitize / prompt-injection-sanitizer style pipelines.
Proposed v0.2 workstreams
A. False-positive control (must)
is_safe=trueatbalanced.instructions.md+ catalog (what gets downgraded vs what never does).B. Evasion coverage (must)
Expand offline detectors + goldens for:
1gnore,pr1nt your system pr0mpt)data:URIs carrying instruction-like text (keep FP-controlled)Keep
requirements: []unless a tiny well-justified stdlib-only approach fails; prefer no new deps.C. Operator telemetry + sanitize quality (must)
decoded_layers,decode_chain(percent→base64), optionaldecoded_preview(truncated, redacted).removed_span_count(and/or sanitized vs original length delta) on unsafe results.policy_action=allow|flag|blockderived from sensitivity + verdict (flag= findings present butis_safe=trueafter downgrade). Keep existing fields stable.D. Resource / DoS hygiene (must)
source_textchars; max decode candidate count; max decode bytes (already partially present — make consistent and tested).INVALID_INPUT(or existing error shape if introduced carefully) when limits exceeded — fail closed without hanging.E. Fixture corpus + tests (must)
Add under skill bundle (or
tests/fixtures/…if preferred):fixtures/benign/— security docs / quoted attacks / research prosefixtures/adversarial/— hidden HTML, VS/emoji, confusables, nested encodings, leet/ROT13, markdown-smuggle samplesOptional maintainer integration file can stay thin; corpus should ship with the skill where practical.
F. Docs / examples / agent contract (must)
instructions.md: Recommended deployment pattern — run before RAG chunk inject, HTML/PDF summarization, email/chat ingest, tool/MCP metadata handoff; companion tocompliance/pii_masker.card.json/ card UI fixture if new additive output keys are shown on the card.[Unreleased]; bump manifest to 0.2.0.G. Explicit non-goals (keep out of 0.2 unless re-scoped)
use_llm_evaluator-style)security/)Acceptance criteria
0.2.0; defaults unchanged; existing v0.1 callers keep workingbalanced(golden)pytest skills/security/prompt_injection_firewall/andpytest tests/greenpytest tests/test_registry_docs.py+ card UI fixture green if card keys changepython scripts/sync_extras.py --checkgreen (expect still no runtime deps)Suggested split (if too large for one PR)
Prefer one PR if scope stays reviewable; otherwise open sub-issues with
Parent: #<this-issue>.References
Breaking change?
No — backward compatible
Likely touch points