cd /news/ai-safety/shield-zero-dependency-pii-and-secre… · home › topics › ai-safety › article
[ARTICLE · art-174261] src=github.com ↗ pub= topic=ai-safety verified=true sentiment=↑ positive

Shield – Zero-dependency PII and secret masking for LLMs (MIT

PromptAudit released Shield, an MIT-licensed, zero-dependency TypeScript module that masks PII and secrets in prompts before they reach LLMs and restores the original values in the caller's process memory via shield(), unshield() and withShield(). Shield validates IBANs (ISO 7064 Mod 97), payment cards (Luhn plus brand prefix), US SSNs (SSA rules) and ABA routing numbers (3-7-1), and detects OpenAI/Anthropic sk- keys, AWS AKIA/ASIA keys, GitHub ghp_/github_pat_ tokens, Slack xox tokens, JWTs and PEM private keys, running in browsers, Node, Bun, Deno and edge workers with no network calls or telemetry. PromptAudit states the pattern-based tool does not detect names without a title, free-text addresses or medical terms, and that detection is best-effort rather than a guarantee that no personal data leaves a system.

key takeaway

Shield masks IBANs, cards, SSNs, ABA routing numbers and API keys into placeholders like [API_KEY_1] and restores originals in-process via unshield(), but it is pattern-based and will not catch untitled names, free-text addresses or unknown key formats.

read2 min views3 publishedNov 22, 2026
Shield – Zero-dependency PII and secret masking for LLMs (MIT
Image: Michielbdejong (auto-discovered)

Zero-dependency, fast & reversible PII and secret masking for LLMs & AI agents.

npm install @promptaudit/shield
js
import { withShield } from "@promptaudit/shield";

const answer = await withShield(userPrompt, (safe) => llm.complete(safe));
// The model saw [API_KEY_1], [IBAN_1] … — your user gets the real values back.
You wrote:   Deploy with key sk-proj-AbC123…xyz and refund Mr. John Miller, IBAN CH93 0076 2011 6238 5295 7
Model sees:  Deploy with key [API_KEY_1] and refund Mr. [NAME_1], IBAN [IBAN_1]
You get:     the model's answer with the original values restored in your process memory
  • Zero dependencies. One small TypeScript module. Browser, Node, Bun, Deno, edge workers.
  • Checksum-validated. IBAN (ISO 7064 Mod 97), cards (Luhn + brand prefix), US SSN (SSA rules), ABA routing (3-7-1). Order and serial numbers are not masked by accident.
  • Secrets included. OpenAI/Anthropicsk-… , AWSAKIA… /ASIA… , GitHubghp_… /github_pat_… , Slackxox…- , JWT and PEM private keys.
  • Reversible. Placeholders go out, the map stays in your process memory.
  • Obfuscation-aware. Zero-width characters and full-width digits are normalised first.
  • No network, no telemetry.
Typical Python NLP stack Ad-hoc regex snippets @promptaudit/shield
Runtime Python server varies Browser, Node, Bun, Deno, edge
Dependencies NLP models and packages varies 0
Checksum validation partial rarely IBAN, cards, SSN, ABA
API keys / secrets separate tooling rarely built in
Restore originals manual usually one-way unshield() / withShield()

NLP stacks (e.g. Microsoft Presidio) detect free-text names and addresses, which Shield does not. Choose by need; they can be combined.

Function Purpose
shield(text, detectors?) Returns { masked, map, counts }
unshield(text, map) Restores originals in a model answer
withShield(prompt, call) Mask → call → restore in one step
DEFAULT_DETECTORS Extend with your own { category, pattern, validate? }

IBAN · payment card · US SSN · US routing (with keyword) · e-mail · international phone (+ prefix) · names after Mr./Mrs./Ms./Dr./Prof. · API keys · private keys

  • Pattern-based, not NER: names without a title, free-text addresses and medical terms are not detected.
  • Unknown key formats are not caught.
  • Detection is best-effort. It reduces exposure; it does not guarantee that no personal data leaves your system.
  • No audit trail.

Shield runs inside your code. Teams that must prove what was sent, by whom and when — with browser enforcement for every employee, append-only hash-chained logs and Swiss storage — use the PromptAudit platform.

Try it live: https://promptaudit.ch/shield · MIT © PromptAudit

── more in #ai-safety 4 stories · sorted by recency
── more on @promptaudit 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/shield-zero-dependen…] indexed:0 read:2min 2026-11-22 · —