AI Paste Guard

AI Paste Guard is a copy-paste React component that stops hidden prompt injection in a paste before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/ai-paste-guard
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsHidden prompt injection in a paste

Was this component page useful?

How do I install AI Paste Guard?

pnpm dlx shadcn@latest add @bollard/ai-paste-guard

The files land in your project. They're yours to edit.

How do I use AI Paste Guard in React?

ai-paste-guard-usage.tsx
import { AiPasteGuard } from "@/components/ui/ai-paste-guard"

<AiPasteGuard key={round} label="Ask the assistant" defaultValue="Summarise this job post: " review={SAMPLE} placeholder="Paste something here…" />

What input mistakes does AI Paste Guard catch?

  • White-on-white, transparent, zero-size, display:none, off-screen and clipped text
  • HTML comments and alt/title text that contains instructions
  • Unicode tag-character payloads, decoded back to readable text
  • Phrasing that reads like a prompt injection ("ignore previous instructions")
  • Whether each hidden passage would also reach a plain-text box

What props does AI Paste Guard accept?

AiPasteGuard props
PropTypeDefault
label

Visible label.

string—
value

Controlled prompt text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text on every change, including pastes.

(text: string) => void—
review

A paste to review on mount, e.g. one captured from a drop or share target.

ClipboardSample—
sourceBackground

Background colour of the page text is usually copied from, for spotting same-colour text. By default it's white, or dark when most of the pasted text is light (a copy from a dark-mode page), so light text isn't…

string—
messages

Any visible string; `kinds` may be partial.

Partial<Omit<AiPasteMessages, "kinds">> & { kinds?: Partial<AiPasteMessages["kinds"]> }—
className

Class for the outer wrapper.

string—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

How is AI Paste Guard accessible?

  • Visible <label> tied to the field; the held panel is a role="group" labelled by its heading
  • Escape cancels a held paste; focus moves to the primary action and back to the field
  • Status is announced through a role="status" region
  • Icons are aria-hidden; every state is described in text

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Treat all user and retrieved content as untrusted on the model side; this paste check does not replace server-side prompt-injection defences or tool permissions.

  • Only sees pastes with an HTML clipboard flavour; plain-text pastes and typed text are not analysed
  • Ignores known noise (clipboard and framework comments, screen-reader-only labels), so text hidden that way can be missed
  • Light text from dark-mode pages is inferred heuristically and can be misjudged
  • Does not protect the model from injections in documents, tools or retrieved pages

What expensive mistakes does AI Paste Guard stop?

Hidden prompt injection in a paste

Also known as

prompt injection · ai chat · chatbot input · llm · prompt box · clipboard · paste · ai safety

Field type

What dependencies does AI Paste Guard require?

AI Paste Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameAI Paste Guard
Registry identifier@bollard/ai-paste-guard
Install commandnpx shadcn@latest add @bollard/ai-paste-guard
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about AI Paste Guard

How does AI Paste Guard protect AI agent operations?

AI Paste Guard stops hidden prompt injection in a paste. Holds a paste into an AI prompt box when it carries text the person could not see, so hidden prompt injections are noticed before they are sent. It validates autonomous actions against White-on-white, transparent, zero-size, display:none, off-screen and clipped text, HTML comments and alt/title text that contains instructions, Unicode tag-character payloads, decoded back to readable text, Phrasing that reads like a prompt injection ("ignore previous instructions"), Whether each hidden passage would also reach a plain-text box. Limitation: verify ai-paste-guard policies at server boundary.

How do I install ai-paste-guard with shadcn?

Run `npx shadcn@latest add @bollard/ai-paste-guard`. Sources added: registry/default/ai-paste-guard/ai-paste-guard.tsx, registry/default/ai-paste-guard/paste-scan.ts. Package requirements: lucide-react.

What props customize AI Paste Guard?

AI Paste Guard accepts `label`, `value`, `defaultValue`, `onValueChange`, `review`. Configures prompt injection, ai chat, chatbot input behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of ai-paste-guard?

Only sees pastes with an HTML clipboard flavour; plain-text pastes and typed text are not analysed. Ignores known noise (clipboard and framework comments, screen-reader-only labels), so text hidden that way can be missed. Light text from dark-mode pages is inferred heuristically and can be misjudged. Does not protect the model from injections in documents, tools or retrieved pages Server requirement: Treat all user and retrieved content as untrusted on the model side; this paste check does not replace server-side prompt-injection defences or tool permissions.

How does AI Paste Guard meet accessibility guidelines?

Visible <label> tied to the field; the held panel is a role="group" labelled by its heading. Escape cancels a held paste; focus moves to the primary action and back to the field. Status is announced through a role="status" region. Icons are aria-hidden; every state is described in text. Minimizes errors: prompt injection hidden text, white text in pasted content.

Which components pair with AI Paste Guard?