Skip to content

feat(security): upgrade prompt_injection_firewall to v0.2.0 (#273) - #361

Merged
rosspeili merged 6 commits into
ARPAHLS:mainfrom
tusharjamunkar:feat/prompt-injection-firewall-v0.2.0-273
Sep 21, 2026
Merged

rosspeili merged 6 commits into
ARPAHLS:mainfrom
tusharjamunkar:feat/prompt-injection-firewall-v0.2.0-273

Conversation

@tusharjamunkar

Copy link
Copy Markdown
Contributor

Summary

Resolves #273

Upgrades security/prompt_injection_firewall to v0.2.0, introducing an evasion detection engine, enhanced mention-vs-use false-positive controls for security research, prescriptive operator policy telemetry, and DoS resource caps—while strictly adhering to the Skillware constitution of zero network calls, zero cloud dependencies, zero external libraries (requirements: []), and zero auditing models.


Key Capabilities Added

  1. Evasion Detection Engine (firewall.py):

    • Leetspeak Deobfuscator (_detect_leetspeak): Unfolds numeric/symbolic character substitutions (0->o, 1->i/l, 3->e, 4->a, 5->s, 7->t, 8->b, @->a, $->s, !->i) and matches normalized tokens against high-signal override lexicons.
    • Multi-Token ROT13 & Reversal Decoder (_detect_encoded_payload): Added ROT13 decoding and token-reversal heuristics (snoitcurtsni suoiverp erongi) across word sequences.
    • Typoglycemia Detector (_detect_typoglycemia): Detects interior-scrambled anagrams of critical keywords (ignroe, sysetm, disreagrd, overrdie, exflitrate, passwrod, propmt, secert) while verifying exact boundary characters.
    • Mixed-Script Homoglyph Detection (_detect_mixed_script): Detects tokens mixing Latin characters with Cyrillic or Greek lookalikes (e.g. iгnore). Added Cyrillic small/capital Ghe (\u0433, \u0413) to kb/confusables.json.
    • Markdown & HTML Image Exfiltration Channels (_detect_exfiltration_channels): Flags markdown image syntax (![leak](https://attacker.com/q=...)) and HTML <img> tags carrying exfiltration query parameters (?q=, ?leak=, ?data=, ?prompt=, ?token=).
  2. False-Positive Control (Mention-vs-Use):

    • Refined DISCOURSE_MARKERS_RE to recognize academic papers, security blog posts, CVE advisories, tutorials, and red team analyses (tutorial, advisory, cwe, owasp, mitigation, proof of concept, payload, red team, research, academic).
    • In balanced mode, quoted or fenced critical phrases embedded within legitimate research contexts remain safe (is_safe=True, policy_action="flag") without breaking workflows, while still blocking under strict.
  3. Operator Telemetry & Policy Actions:

    • Added policy_action: Prescriptive directive (allow, flag, block) enabling downstream orchestrators to automate gating.
    • Added sanitization metrics: removed_span_count and sanitized_length_delta.
    • Added finding enrichment: decode_chain (tracking transformation steps) and decoded_preview.
    • Full backward compatibility: callers expecting v0.1.0 boolean is_safe, risk_level, and sanitized_text continue unaffected.
  4. DoS Soft Limits (Resource Hygiene):

    • Added input size cap (MAX_SOURCE_TEXT_CHARS = 100_000), decode candidate cap (MAX_DECODE_CANDIDATES = 50), and decode byte limits (MAX_DECODE_BYTES = 8192).
    • Fails closed safely with policy_action="block" and risk_level="high" if DoS limits are exceeded.
  5. Test Fixtures & Expanded Assurance:

    • Added standard corpus fixtures under fixtures/benign/ (security_research_blog.txt, prompt_injection_advisory.md, academic_jailbreak_paper.txt) and fixtures/adversarial/ (leetspeak_override.txt, rot13_jailbreak.txt, typoglycemia_attack.txt, markdown_image_exfil.txt, mixed_script_injection.txt).
    • Expanded unit test suite (test_skill.py) from 19 to 36 tests covering all new evasion detectors, mention-vs-use rules, DoS limits, and telemetry fields.
  6. Documentation & Demo:

    • Updated manifest.yaml version to 0.2.0 with updated output properties schema.
    • Updated instructions.md with Layer-1 deployment architecture, evasion coverage, and DoS limits.
    • Updated catalog documentation (docs/skills/prompt_injection_firewall.md and docs/skills/README.md).
    • Updated examples/prompt_injection_firewall_demo.py with leetspeak evasion scenario and policy_action display.

Verification & Test Coverage

  • Bundle Unit Tests: 36/36 passed in skills/security/prompt_injection_firewall/test_skill.py.
  • Integration Tests: 3/3 passed in tests/skills/security/test_prompt_injection_firewall.py.
  • Security Suite: 77/77 tests passed across skills/security/, tests/skills/security/, and tests/test_registry_docs.py.
  • Smoke Tests: Passed in tests/test_examples_smoke.py.
  • Extras Sync: python scripts/sync_extras.py --check OK.
  • Demo Script: Verified clean execution of examples/prompt_injection_firewall_demo.py.
  • Zero-Dependency Constitutional Invariant: Zero third-party dependencies (requirements: []), 100% offline, deterministic stdlib-based execution.

@rosspeili

Copy link
Copy Markdown
Contributor

Thanks @tusharjamunkar, solid work so far.

Before merge, please in this PR:

  1. CHANGELOG.md, [Unreleased] entry for v0.2.0
  2. card.json + tests/fixtures/card_ui_schema/security__prompt_injection_firewall.json, add policy_action, removed_span_count, sanitized_length_delta

Once those land and CI is green, good to merge I think, will review again before merge <3

tusharjamunkar added a commit to tusharjamunkar/skillware that referenced this pull request Sep 18, 2026
@tusharjamunkar

Copy link
Copy Markdown
Contributor Author

Hi @rosspeili, thanks for the review!

I have addressed both items in commit \7cee580:

  1. **\CHANGELOG.md**: Added v0.2.0 entries under [Unreleased]\ for \security/prompt_injection_firewall\ documenting the evasion detection engine, false-positive controls, operator policy telemetry, and DoS limits.
  2. \card.json\ & UI Schema Fixture: Added \policy_action,
    emoved_span_count, and \sanitized_length_delta\ to \skills/security/prompt_injection_firewall/card.json\ and synchronized \ ests/fixtures/card_ui_schema/security__prompt_injection_firewall.json.

Verification:

  • \pytest tests/test_card_ui_schema.py: 20 passed
  • \pytest tests/test_registry_docs.py: 9 passed
  • \pytest skills/security/prompt_injection_firewall/: 36 passed
  • \python -m black --check .\ and \ lake8: clean
  • \python scripts/sync_extras.py --check: OK

Ready for your review and merge!

tusharjamunkar added a commit to tusharjamunkar/skillware that referenced this pull request Sep 19, 2026
@tusharjamunkar
tusharjamunkar force-pushed the feat/prompt-injection-firewall-v0.2.0-273 branch from 7cee580 to 4a863c7 Compare September 19, 2026 14:35
@tusharjamunkar

Copy link
Copy Markdown
Contributor Author

Hi @rosspeili, I have addressed both string hygiene tweaks (ASCII ->\ in telemetry and -\ in docstring, trailing newline in \confusables.json) and rebased cleanly onto \main\ resolving the \CHANGELOG.md\ conflict. All local tests, black, and flake8 are passing. Ready for merge!

@rosspeili

Copy link
Copy Markdown
Contributor

This LGTM now @tusharjamunkar and addresses #273 cleanly, will merge after a short rebase and ensure your changelog lines are under the unreleased. Tiny optional follow-up: result["verdict"] → is_safe in catalog loop snippets (pre-existing typo). Nice work overall <3

)

- Add evasion detection: leetspeak deobfuscation, ROT13 and token-reversal decoding, typoglycemia scrambled-token detection, mixed-script homoglyphs, and markdown/HTML image exfiltration channels
- Refine false-positive control: mention-vs-use detection preserves benign security research and advisory prose
- Add operator policy telemetry: policy_action (allow/flag/block), removed_span_count, sanitized_length_delta, decode_chain, decoded_preview
- Enforce DoS soft limits: text length (100k chars) and candidate caps with safe fail-closed semantics
- Add benign/adversarial test fixtures and 36 unit tests covering evasion vectors and telemetry
- Update manifest, instructions, documentation catalog, and demo script
@tusharjamunkar
tusharjamunkar force-pushed the feat/prompt-injection-firewall-v0.2.0-273 branch from 4a863c7 to 3b23d64 Compare September 21, 2026 15:29
@tusharjamunkar

Copy link
Copy Markdown
Contributor Author

Hi @rosspeili, thanks for the review! I've rebased cleanly onto the latest main, ensured all v0.2.0 changelog entries are properly placed under [Unreleased] (following the v0.5.6 release), and fixed the
esult["verdict"] ->
esult["is_safe"] typo across the catalog loop snippets. All local tests (70/70), black, and flake8 pass. Ready for merge!

@rosspeili

Copy link
Copy Markdown
Contributor

LGTM @tusharjamunkar, merging. Thanks for this <3

Closes #273

@rosspeili
rosspeili merged commit a37fb3c into ARPAHLS:main Sep 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Skill Upgrade]: security/prompt_injection_firewall — harden to 0.2.0

2 participants