Skip to content

Implement Barrikade security client and pluggable framework#464

Open
Ishaan005 wants to merge 10 commits into
jentic:mainfrom
barrikadelabs:feat/barrikade
Open

Implement Barrikade security client and pluggable framework#464
Ishaan005 wants to merge 10 commits into
jentic:mainfrom
barrikadelabs:feat/barrikade

Conversation

@Ishaan005
Copy link
Copy Markdown

Description

This PR introduces a Security Plugin Registry to jentic-mini's gateway and integrates Barrikade as the primary security plugin.

Instead of hardcoding security logic or relying on redundant, high-latency request-body scans at the egress broker layer (which are already captured by the global SecurityIngressMiddleware at ingress), jentic-mini now implements a modular registry interface that intercepts and scans API response bodies returned by third-party services. This provides critical protection against data leaks, PII exfiltration, and indirect prompt injections before they reach the agent or Arazzo workflow runner.


Architectural Refactor

                  ┌───────────────────────────┐
                  │   Inbound Client Request  │
                  └─────────────┬─────────────┘
                                │
                                ▼
              ┌───────────────────────────────────┐
              │     SecurityIngressMiddleware     │
              └─────────────────┬─────────────────┘
                                │ (scan_ingress)
                                ▼
              ┌───────────────────────────────────┐
              │      security_registry (SL)       │
              └─────────────────┬─────────────────┘
                                │
                    ┌───────────┴───────────┐
                    ▼                       ▼
         ┌─────────────────────┐ ┌─────────────────────┐
         │   BarrikadePlugin   │ │   CustomPlugin      │
         └──────────┬──────────┘ └──────────┬──────────┘
                    │                       │
                    ▼ (scan_text)           ▼
         ┌─────────────────────-┐ ┌─────────────────────-┐
         │ Barrikade API /detect│ │   Custom Classifier  │       
         └─────────────────────-┘ └─────────────────────-┘
  1. Ingress Boundary (Middleware): Scans query parameters and inbound payloads (POST/PUT/etc.) using security_registry.scan_ingress before routing or database execution.
  2. Egress Boundary (Response): Intercepts raw responses inside broker.py right after _upstream_body = await upstream_response.read() and scans them via security_registry.scan_response before delivery.

Summary of Changes

1. Security Registry & Interfaces (src/security/)

  • src/security/plugin.py:
    • Declares slotted SecurityVerdict for lightweight, high-performance classifications.
    • Declares SecurityPlugin abstract base class with default ingress filter (should_scan_ingress), response filter (should_scan_response), and delegating scan_response methods.
  • src/security/registry.py:
    • Implements SecurityRegistry singleton coordinating active plugins.
    • Employs first-block-wins short-circuiting on active scans to optimize Latency and prevent redundant operations.
  • src/security/barrikade.py:
    • Concrete SecurityPlugin subclassing SecurityPlugin. Encapsulates direct HTTP calls to Barrikade’s stateless /v1/detect API.
    • Overrides should_scan_ingress to target only Jentic’s /search, /workflows/{slug}, and broker routing paths.
  • src/security/utils.py:
    • High-performance, isolated text extraction algorithms that recursively traverse nested JSON list/dict query strings and request/response payloads to isolate raw strings.

2. Router Integration (src/routers/)

  • src/routers/broker.py:
    • Completely removed the old, redundant request-egress security block (cutting outbound proxying latency in half).
    • Added response-body scanning directly after upstream reading is complete. Unsafe responses instantly trigger a policy_denied trace and short-circuit with a structured 403 Forbidden response-block verdict.
  • src/main.py:
    • Configured SecurityIngressMiddleware to delegate directly to security_registry without carrying any vendor-specific imports.
    • Registers BarrikadePlugin dynamically in lifespan if BARRIKADE_URL is set in the environment.

3. Tooling & Orchestration

  • compose.barrikade.yml: Added a new Docker Compose stack configuration file overlaying compose.yml to define the local barrikade/api service and link it to Jentic Mini internally.
  • scripts/start-stack.sh: Created an interactive shell script to spin up the Jentic Mini + Barrikade containers (Standard or Full Vite UI Dev stack) instantly.
  • docs/security.md: Created exhaustive system design, lifecycle, configuration, and custom plugin development documentation, linked in docs/README.md.

This change requires real-world testing with live APIs. The foundation is in place and should be reiterated on.

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.

1 participant