Inspiration

The AI revolution has given us incredible autonomous agents, but it has also handed malicious actors a perfect new attack vector. We realized that as AI agents start reading our emails, managing our calendars, and handling our transactions, they become prime targets for prompt injections and data exfiltration. If a single hidden line of white text in an email can hijack an agent into sending unauthorized payments or leaking sensitive API keys, the entire ecosystem is at risk.

We built JanusGate because we believe the future of AI must be secured by a zero-trust architecture. We named it after Janus, the Roman god of gates and transitions—one face watches what enters the system, and the other watches what leaves.

What it does

JanusGate is a high-speed, zero-trust security firewall and audit gateway designed specifically to protect AI agents and human users from sophisticated LLM-based scams, prompt injections, and malicious tool executions.

It acts as an impenetrable middleware layer:

  1. Ingress Protection: Intercepts incoming messages (like emails) and uses a hybrid engine (Heuristics + Semantic Embeddings + LLM Judge) to detect prompt injections and social engineering scams in milliseconds.
  2. Egress Protection (Canary Tripwires): Inspects the output of AI agents before it executes tools. If an agent tries to leak a sensitive API key or a planted "canary token", JanusGate intercepts the action, blocks the tool, and redacts the leak.
  3. Automated Incident Response: Using an n8n automation pipeline, clean messages are summarized by Gemini and logged safely to Airtable. Malicious messages are instantly blocked and trigger a high-priority alert via a Discord Webhook.

How we built it

We built JanusGate with a modern, modular, and highly scalable stack:

  • Backend: A blazing-fast FastAPI Python server deployed in a Docker container on Render. It handles the core inspection logic and the /inspect endpoints.
  • Security Engine: We implemented a multi-layered defense. Layer 1 uses fast Regex/Heuristics. Layer 2 uses Semantic vector embeddings. Layer 3 uses Google's Gemini API as a highly capable LLM Judge for complex, nuanced attacks.
  • Automation Workflow: We deployed a self-hosted n8n instance to orchestrate the real-time flow of data. It listens for emails, queries the JanusGate API, and routes the traffic based on the risk verdict.
  • Integrations: We integrated Airtable for secure, token-based data logging of benign summaries, and Discord for real-time SOC (Security Operations Center) alerts.
  • Dashboard: A sleek Streamlit dashboard provides a live UI to simulate attacks, view metrics, and monitor the tamper-evident audit log.

Challenges we ran into

One of our biggest hurdles was balancing latency with security. LLM evaluations are highly accurate but notoriously slow, and a firewall needs to operate in milliseconds. We solved this by building the hybrid "defense-in-depth" architecture. We use fast heuristics and semantic caching to instantly block obvious attacks, reserving the slower Gemini LLM Judge only for highly ambiguous edge cases.

Additionally, securely handling authentication between n8n and Google Cloud for Google Sheets proved overly complex for a hackathon timeframe. We pivoted dynamically, replacing Google Sheets with Airtable, which allowed us to use robust Personal Access Tokens (PATs) and keep our security posture incredibly tight without compromising delivery.

Accomplishments that we're proud of

We are incredibly proud to have built a truly functional, end-to-end security pipeline rather than just a conceptual mock-up.

  • We achieved a perfect 16-point Chain of Verification (CoVe) on our test suite.
  • The system actively intercepts real-world prompt injection payloads and effectively halts tool execution upon detecting exfiltration attempts.
  • We successfully orchestrated a complex microservice architecture (Render, n8n, Streamlit, Airtable, Discord, Gemini) into one seamless, automated flow.

What we learned

We learned that AI security requires an entirely different paradigm than traditional software security. Traditional WAFs (Web Application Firewalls) look for SQL injections, but AI agents are vulnerable to natural language manipulation. Defending against this requires treating language as code. We also learned the immense power of combining visual node-based orchestrators like n8n with custom-built FastAPI microservices for rapid, robust prototyping.

What's next for JanusGate

The next step is to productize JanusGate into an open-source, drop-in proxy (similar to an API gateway). We want developers to be able to simply point their OpenAI/Gemini SDK base URLs to JanusGate, instantly wrapping their existing AI applications in a zero-trust security envelope with absolutely zero code changes to their core logic. We also plan to train smaller, specialized open-weights models specifically for injection detection to run completely locally, further driving down latency and cost.

Built With

Share this project:

Updates

Submission history