cd /news/ai-safety/promptshield-ai-zero-leak-local-reda… · home › topics › ai-safety › article
[ARTICLE · art-153186] src=dev.to ↗ pub= topic=ai-safety verified=true sentiment=↑ positive

PromptShield AI: Zero-Leak Local Redaction & Prompt Hardening Engine for Open-Weight Models

A developer built PromptShield AI, an open-source, local-first redaction proxy and prompt-hardening engine that strips API keys, customer PII, IP addresses, and financial data from prompts before they reach open-weight models like Gemma 2, Llama 3.2, and Mistral. The tool replaces sensitive values with relational surrogates such as [API_KEY_1] and [EMAIL_1], lets the model reason over the sanitized prompt, then rehydrates the response locally so secrets never leave the user's machine. It ships as a zero-build browser app with configurable redaction rules, a risk dashboard, and an optional connection to a local Ollama daemon, under the MIT License.

by read5 min views2 publishedOct 19, 2026

This is a submission for the Hacktoberfest Open-Source AI Challenge: Week 3.

#

What I Built

PromptShield AI is an open-source, local-first redaction proxy and prompt-hardening engine built to prevent sensitive credentials, client PII, and infrastructure secrets from leaking into open-weight AI models.

As developers, freelancers, and enterprises adopt open-weight models like Google Gemma 2, Meta Llama 3.2, and Mistral, confidential data leakage remains the number one risk. Developers frequently paste logs, bug reports, and configuration files into AI interfaces without realizing they contain:

  • Live API tokens and secret keys (Stripe, GitHub, Google Cloud, AWS)
  • Customer PII (emails, phone numbers, full names)
  • Network infrastructure data (private IPv4/IPv6 addresses, internal server paths)
  • Financial records (credit card sequences, transaction ledger IDs)

Sending these directly to remote APIs risks permanent data exposure. Even when running inference locally or on private VPCs, storing raw credentials in model activations, evaluation logs, or session transcripts creates serious audit violations.

How PromptShield AI Fixes This:

Deterministic Pre-Inference Redaction : Automatically scans raw prompts using validated regular expressions and entropy heuristics, replacing sensitive values with relational synthetic surrogates (such as[API_KEY_1] ,[EMAIL_1] ,[IP_ADDR_1] ). 2. Context-Preserving Model Execution : Open-weight models (e.g. Gemma 2 running locally in-browser or via Ollama) can reason over the surrogates, generate code, or draft customer replies without ever seeing the secret. 3. Local-Only Bi-Directional Rehydration : The final model response is privately mapped back to the original values strictly on the user's local machine.

#

Demo

PromptShield AI runs as an interactive, zero-build client-side web application.

Interactive Features:

Instant Test Presets : Test real-world scenarios including API Key leaks, Customer Support escalations, Financial records, and Internal server stack traces with one click. #

Configurable Redaction Rules : Granular toggles for API keys, emails, phone numbers, IP addresses, credit cards, and system paths. #

Telemetry & Risk Dashboard : Computes risk levels (SAFE, MEDIUM, HIGH, CRITICAL), token counts, and sub-millisecond execution times. #

De-Identification Export : Export sanitized prompt bundles and surrogate JSON dictionaries locally. #

Local Open-Weight Model Runner : Toggle between an instant in-browser simulated Gemma 2 engine or connect directly to a local Ollama daemon (gemma2:2b /llama3.2:3b athttp://localhost:11434 ).

#

Code

Zero-Leak Local Redaction & Prompt Hardening Engine for Open-Weight Models

Built for Hacktoberfest 2026 Open-Source AI Challenge: Week 3

💡 What is PromptShield AI? #

As software engineers and enterprises rapidly adopt open-weight models (such as Google Gemma 2, Meta Llama 3.2, Mistral, and Qwen), confidential data leakage has become the primary operational barrier. Developers routinely paste internal stack traces, API keys, client tickets, customer emails, and server IP addresses into AI prompts.

Commercial cloud LLMs retain or process this data on remote servers, causing irreversible compliance violations. Even when running models locally or on private cloud instances, untrusted prompts can leak credentials into model activations, evaluation logs, or telemetry pipelines.

PromptShield AI solves this with a lightweight, local-first redaction proxy and bi-directional rehydration engine:

Pre-Inference Redaction : Deterministically scans and replaces API credentials, emails, phone numbers, IP addresses, credit card numbers, and filesystem…

The repository is 100% open source under the MIT License.

Project Structure:

index.html : Accessible, responsive single-page interface with dark/light themes. #

style.css : Clean modern design system with glassmorphic cards and micro-animations. #

app.js : Core deterministic redaction engine, surrogate dictionary mapper, and local Ollama bridge. #

test_engine.js : Comprehensive 9-test automated verification suite for credential detection and rehydration fidelity. #

SECURITY.md : Zero-telemetry local privacy guarantee. #

.github/workflows/test.yml : GitHub Actions automated CI testing workflow. #

README.md : Complete documentation, quickstart guide, and architectural diagrams.

#

How I Built It

Architecture & Tech Stack

Frontend / Client : Vanilla HTML5, CSS3, and modern ES6 JavaScript. Zero build steps, zero bundle bloat, instant . #

Deterministic Token Scrubber : Language models should never be used as security filters because they hallucinate token boundaries. PromptShield uses deterministic regular expressions with Shannon entropy heuristics for strict boundary enforcement. #

Relational Consistency : If an email appears 3 times in a prompt, PromptShield maps every occurrence to[EMAIL_1] , ensuring the model's reasoning remains coherent. #

Open-Weight Models : Supported via standard local Ollama JSON endpoints (http://localhost:11434/api/generate ) with a fallback zero-install in-browser engine.

flowchart LR
    A[Raw Confidential Input] --> B[PromptShield Engine]
    B --> C[Local Surrogate Map]
    B --> D[Sanitized Prompt]
    D --> E[Local Gemma 2 / Ollama]
    E --> F[Raw Model Output]
    C -.-> G[Rehydration Engine]
    F --> G
    G --> H[Final Safe Output]

Automated Verification

Run the automated test suite locally:

The test suite verifies:

  • API key detection across OpenAI, GitHub, and Cloud provider patterns
  • Email and phone normalization
  • IPv4/IPv6 boundary detection
  • 16-digit payment card masking
  • Bidirectional surrogate restoration without syntax corruption

#

Why Does Open Innovation Matter?

In security and privacy, closed models are a black box. When using proprietary cloud AI for sensitive tasks, you are forced to send the very data you want to protect across external networks, trusting third-party privacy pledges.

Open innovation is essential here:

Verifiable Zero-Telemetry : Anyone can audit the source code to prove that not a single byte of telemetry or prompt text leaves their local machine. 2. Cost-Free Data Sovereignty : Solo developers, freelancers, and small businesses can achieve enterprise-grade prompt protection without paying $30/month for proprietary enterprise AI gateways. 3. Air-Gapped & Offline Resilience : PromptShield runs entirely offline. Whether on an airplane, in a remote clinic, or inside an air-gapped corporate lab, privacy protection remains 100% active.

#

Prize Categories

I am submitting PromptShield AI for:

  • Overall Winner

Partner Category: Best Use of GitHub Copilot (Demonstrating prompt sanitization workflows for developer tooling)

── more in #ai-safety 4 stories · sorted by recency
── more on @promptshield ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/promptshield-ai-zero…] indexed:0 read:5min 2026-10-19 · —