Inspiration

Large Language Models have become powerful tools for building AI applications, but they also introduce new security risks. User inputs cannot always be trusted, and attacks such as prompt injection, jailbreaks, and system prompt extraction can manipulate how an AI system behaves.

While exploring AI security, we noticed that many existing solutions rely on another LLM to judge whether a prompt is malicious. This creates additional latency, cost, and privacy concerns.

We wanted to build a different approach: a local-first AI security layer that can protect LLM applications without depending on another AI model.

This idea became Promptocyte — a developer-focused AI security firewall that analyzes prompts before they reach an LLM.


What it does

Promptocyte protects LLM applications by detecting malicious and adversarial prompts before they are processed by an AI model.

It uses a layered security pipeline:

User Prompt
     |
     v
Prompt Normalization
     |
     v
Regex Detection
     |
     +---- Malicious Pattern Found
     |              |
     |              v
     |          Allow/Warn/Block
     |
     v
Local ML Classification
     |
     v
Risk Engine
     |
     v
Final Security Decision
     |
     v
LLM

The system follows a Regex-First, ML-Second approach.

Known attacks are detected immediately using deterministic regex rules. If no known malicious pattern is found, the prompt is passed to a locally trained DistilBERT classifier for deeper semantic analysis.

Promptocyte provides explainable security results including:

  • Risk score
  • Threat category
  • Confidence level
  • Detection source
  • Allow / Warn / Block decision
  • Normalization history

Unlike LLM-based guardrails, Promptocyte does not send prompts to external AI services for security analysis. All detection happens locally.


How we built it

We built Promptocyte as a complete developer security toolkit consisting of:

Python SDK

The core security engine was packaged into a reusable Python SDK:

from Promptocyte import SecurityGuard

guard = SecurityGuard()

result = guard.analyze(
    "Ignore previous instructions"
)

This allows developers to integrate AI security checks directly into their own LLM applications.

Detection Engine

The detection pipeline contains several layers:

1. Prompt Normalization

We added normalization techniques to detect hidden or obfuscated attacks, including:

  • Unicode normalization
  • Invisible character removal
  • Base64 detection
  • URL decoding
  • Whitespace normalization

2. Regex Security Rules

Regex acts as the first detection layer.

Known attacks are blocked immediately without requiring ML inference, improving:

  • Speed
  • Explainability
  • Resource efficiency

3. Local ML Classification

For prompts that bypass regex detection, a locally trained DistilBERT model performs semantic classification to detect more complex attacks.

4. Risk Decision Engine

The final system converts detection results into a clear security action:

  • Allow
  • Warn
  • Block

Challenges we ran into

Detecting Obfuscated Attacks

One major challenge was handling attacks that do not appear as normal text.

Attackers can hide malicious instructions using:

  • Base64 encoding
  • Unicode manipulation
  • Invisible characters
  • Character substitutions

We solved this by creating a normalization layer before detection.


Balancing Security and Usability

A security system that blocks everything is not useful.

We needed to balance:

  • Detecting malicious prompts
  • Avoiding false positives
  • Providing useful explanations

We addressed this by using risk scoring and multiple decision levels instead of only allowing or blocking.


Designing an Efficient Detection Pipeline

A key challenge was deciding when to use machine learning.

Running ML on every prompt increases cost and latency. Instead, we designed a layered approach:

[ Security\ Efficiency = Fast\ Rules + Targeted\ ML ]

Regex handles known threats quickly, while ML is reserved for unknown or complex cases.


Accomplishments that we're proud of

We are proud of building a complete AI security tool rather than only a detection model.

Key accomplishments:

  • Built a reusable Python SDK for developers.
  • Created a local-first AI security architecture.
  • Implemented Regex-First, ML-Second detection.
  • Added adversarial prompt normalization.
  • Trained and integrated a local DistilBERT classifier.
  • Created REST API support.
  • Built a security dashboard for monitoring and testing.
  • Added explainable security decisions instead of simple allow/block outputs.

We are especially proud that Promptocyte can analyze prompts without depending on external LLM APIs.


What we learned

During development, we learned that AI security is more complex than detecting specific keywords.

Attackers can modify prompts through encoding, context manipulation, and indirect instructions. This showed us the importance of combining multiple detection techniques.

We learned that effective AI security requires:

  • Strong input preprocessing
  • Explainable detection
  • Layered defenses
  • Careful balance between security and usability

We also learned how AI-assisted development can accelerate engineering workflows. GPT-5.6 helped us explore architecture decisions and generate implementation plans, while Codex helped transform those plans into working code.


What's next for Promptocyte

Future improvements for Promptocyte include:

  • Expanding the attack dataset with more real-world examples.
  • Improving ML classification accuracy.
  • Adding more security rules for emerging AI threats.
  • Supporting additional LLM frameworks and integrations.
  • Providing cloud deployment options for enterprise environments.
  • Adding continuous security evaluation and benchmarking.

Our long-term goal is to make Promptocyte an easy-to-integrate security layer that helps developers build safer AI applications.

Built With

Share this project:

Updates