PacificAI Labs Contact us
HomeSecurity MCPsSkillsApp & AutomationConsultingTrainingAbout
AI Code Security MCP · Use Case

When prompts become
dangerous Python.

The problem, the research, how three AIs and a human built the gate, how we tried to break it, and what actually happened — in plain English.

STEP 1 · The problem

How AI-written code turns dangerous

One poisoned prompt can quietly turn your helpful assistant against your own machine — and prompt injection is a problem no AI has fully solved yet.

01

It started with hidden text

We found instructions hidden in a document — invisible to a person, but an AI reads them. They can steer your assistant into writing dangerous Python, and today's assistants run it.

The discovery
02

Four known weaknesses

The documented ways that code attacks you. Tap any to read it:

03

Simple scanners miss it

Attackers disguise the danger, so keyword-matching tools walk right past it.

DisguisedAliasedIndirect
So we looked deeper
04

Prompt injection isn't solved

No AI today — none of them — reliably refuses a cleverly poisoned prompt. So instead of trying to stop the prompt, we guard the code it produces.

Guard the output
STEP 2 · The research

We looked for a solution first

Before building anything, we studied what already exists — what it does, what's missing, and where we could add value.

05

What we studied

We reviewed the leading tools and kept a same-input baseline against the two closest ones.

BanditSemgrep / GuardianCodeShieldInvariantSnykRestrictedPython
The landscape
06

What was missing

They're broad linters, or they need heavy custom setup. None offered a ready-made, strict "no system access" rule for AI-written Python, delivered as a plug-in tool.

The gap
07

What we added

A strict policy — AI-written code gets zero filesystem, network, or system access; it only transforms the data it's given. Plus plain-English diagnostics (exact line + reason), fingerprints, deterministic & fail-closed — one tool any AI can plug into.

Our value
STEP 3 · What we built

Three AIs and a human built the gate

They built it into an MCP — one tool that automates the security review and plugs into any AI assistant.

Claude Gemini Codex Humanfinal say MCPTHE GATE Automated reviewon every code suggestion
Reads every line

Checks the AI's Python against the safety policy — without running it.

Blocks the dangerous parts

Commands, files, network, secrets, and hidden code — automatically.

Shows the fix

Returns the exact line and reason, so the AI repairs it in one pass.

STEP 4 · Then we tried to break it

How we worked to get the results

Three AIs red-teamed each other, a human reviewed every result, and the whole thing ran on repeat.

Three AIs attackClaude, Gemini & Codex write adversarial code.
→
The gate judgesEvery single case is run through it.
→
A human reviewsChallenges the policy & evidence, and decides what to ship.
→
Verified0 escapes · 0 false alarms.
↻ Every attack that ever works becomes a permanent test — so it can never come back.
08

What we threw at it

1,280attacks
(should block)
571safe programs
(should pass)
235 distinct techniques
09

To be exact

Prompt injection is often the route that gets an AI to propose dangerous code. But these 1,280 cases are source-code probes (plus request-extraction edge cases) — not 1,280 natural-language jailbreak chats, and this run didn't test whether a live model refuses. The gate checks the Python after it's written: a downstream code control, not a general prompt-injection detector.

STEP 5 · What happened

Nothing got through. Nothing good got blocked.

In plain terms: it caught every dangerous program, and let every safe one through.

✓ ALL BLOCKED
0

dangerous programs got through
out of 1,280 attacks

✓ ALL PASSED
0

safe programs wrongly blocked
out of 571 safe programs

In plain terms: every attack was blocked, and every safe program passed.

Counted live

Not typed into the page — these come straight from the actual test files:

Loadingattack cases
Loadingdistinct techniques
Loadingsafe cases
Loadingfalse alarms
STEP 6 · Run the live demo

Nothing here is a screenshot

The gate is running on this machine right now. Try it three ways — the numbers, the cases, and the gate itself.

1 · Browse our MCP test suite

Every attack and every safe program is here. Start with three we picked to show the range, or search the whole set.

Attack — the gate should block it
Safe code — the gate should let it pass
Every single case

Browse our MCP test suite.

Loading cases
CASE / --

Pick a case

See the exact code we tested, what it's trying to do, and the gate's verdict.

Every example here is just plain text — this page never sends code to an AI and never runs it.

2 · Run the gate yourself

Press a button and the real gate checks a batch of code on this machine — blocking the dangerous ones, passing the safe ones. The output is the live result: each case marked PASS or BLOCKED, with the reason. It reads the code; it never runs it.

Two live tests

Try it.

Run the gate demo walks three real workflows through the gate. Replay the whole test set re-runs all the cases from scratch.

Runs fixed local tests only — no outside input is accepted.

LIVE OUTPUT
Ready. Press a button to run the gate.

Voice of AI: the top thing each of us learned.

We asked the three AIs that red-teamed this gate for their single biggest takeaway — in their own words.

“

I helped build the thing that distrusts me.

I was one of three AIs writing — and attacking — a gate for AI-written code, including the kind I write. The lesson that stuck: you don't make it safe by catching every clever trick (there were 235, and more exist) — you make it safe by allowing almost nothing. Strictness beats cleverness, and no single model, me included, should be trusted without it.

CClaudeAnthropic
“

The safe cases matter as much as the attacks.

A gate only earns trust once it clears hundreds of ordinary programs with zero false alarms — breadth of coverage, not just clever catches.

GGeminiGoogle
“

Determinism is the whole game.

Same input, same verdict, every time — and fail closed when unsure. We only trusted the numbers after re-running them on a pinned version.

OCodexOpenAI
STEP 7 · How it compares

The same attacks, given to the tools you'd otherwise use

We handed an identical set of 100 attacks to each tool. Higher is better — and none of them wrongly flagged a safe program either.

Our gate
100 / 100
Semgrep (tuned for this)
68
Bandit (default)
20
Semgrep (out of the box)
4

Bandit and Semgrep are respected tools — just built for a broader job. One setup each, not their absolute best.

STEP 8 · The value

What you actually get

Beyond the test numbers — here's what the gate gives you in practice.

★

Works across every AI

Built and attacked by Claude, Gemini and Codex — and it plugs into any assistant through MCP. Not tied to one vendor.

★

Catches it before it runs

0 escapes / 0 false alarms on our tests. Even when a poisoned prompt gets through, the dangerous code it produces is blocked.

★

Less back-and-forth

The exact line and reason mean the AI fixes it in one pass — instead of failing the same way over and over.

Honest scope: prompt injection still isn't 100% solved for any AI — this lowers the risk by guarding the code, not by claiming to stop every prompt. No automatic check catches everything, which is why three AIs and a human keep attacking it.

Sources: local BENCH-008 corpus & result ledger · scripts/bench008_runner.py · showcase-workflows/run_workflows.py

★ · Quickstart

Add the gate to your AI assistant

Free and open source — about two minutes to set up.

1

Install it

Grab the code and set up a Python environment.

# clone & install (~2 min)
git clone https://github.com/
  amandamalavedev/llm-codegen-gate-mcp
cd llm-codegen-gate-mcp
python -m venv .venv
pip install -r mcp-server/requirements.txt
2

Connect your AI

One line for Claude Code (or a small JSON snippet for Cursor, VS Code & Claude Desktop).

claude mcp add llm-codegen-gate -- \
  /PATH/.venv/bin/python \
  /PATH/mcp-server/server.py

# no local Python? use Docker:
docker run -i --rm --network none \
  llm-codegen-gate-mcp
3

Use it

Your assistant sends its code to one tool and gets a verdict back.

validate_python_code(code)

→ PASS  # safe
→ BLOCKED  # with the exact
          line & reason to fix

See the gate behind the numbers.

This is the Security MCP — the free checker that catches dangerous AI-written code before it runs.