The WebMCP Security Checklist: Protecting Client-Side Agent Tools Before Release
When you expose structured actions on a web page via WebMCP (document.modelContext), you eliminate brittle DOM scraping—but you also change the threat model of your frontend. A client-side tool contract sits directly be
When you expose structured actions on a web page via WebMCP (document.modelContext), you eliminate brittle DOM scraping—but you also change the threat model of your frontend.
A client-side tool contract sits directly between untrusted model inputs / page content and authenticated browser sessions. Treating a JSON Schema or consequentialHint as a security boundary is a recipe for cross-account bugs, replay attacks, and prompt-injected mutations.
In Part 2 of Building for the Agentic Web, let's walk through the concrete release gates from our open-source security checklist repository.
raghav453
/
webmcp-security-checklist
WebMCP security checklist and 15 negative-test cases for authorization, prompt injection, human approval, cancellation and replay protection.
WebMCP security checklist
Plan and record 15 negative tests for authorization, unsafe outputs, human approval, replay, cancellation and lifecycle cleanup. Use the original threat model alongside your application's actual server controls.
Open the security test worksheet · Full checklist · Download test matrix CSV · Threat model
Start a concrete review
- Pick one protected or consequential tool. Use fictional accounts and an isolated service you control.
- Download the matrix, or filter the browser worksheet by access, data, approval, replay or lifecycle.
- Run the relevant tests. Record observed state and sanitized evidence, not just a success message.
- Export the review JSON for your team. A pass needs evidence; a not-applicable case needs a reason.
The worksheet records your outcomes. It does not probe a website, run security tests or certify security. Our local draft example demonstrates refusal and local approval, not server authorization.
Review a tool
- Map assets and boundaries in…
1. Never Trust Client-Side Hints as Enforcement
Two flags commonly misunderstood by early builders:
-
readOnlyHint: true: Tells a caller the tool does not mutate state. Your server and handler still need to guarantee no side effects occur. -
consequentialHint: true: Signals that a mutation needs user review. It is not authorization—an untrusted caller or compromised script can bypass client-side UX if the backend doesn't enforce auth.
Rule of Thumb
Every consequential mutation still requires server-side authentication, principal/resource authorization checks, CSRF/origin validation, and atomic idempotency.
2. Bind Human Confirmation to Exact Payloads (Not Agent Booleans)
Never accept an agent-supplied parameter like { confirmed: true } as proof of human consent. Instead:
- Generate a proposed action preview in your UI showing the exact payload, target resource, and principal.
- Require explicit human approval bound to:
- the exact payload hash / fields,
- the intended operation,
- the active user principal, and
- a short freshness window (expire/cancel on timeout, navigation, or session change).
- Propagate
AbortSignalso a user cancellation or route unmount immediately aborts pending execution.
async function executeWithReview(input, { signal, reviewFn }) {
if (signal?.aborted) {
throw new DOMException("Canceled before review", "AbortError");
}
const proposal = Object.freeze({
action: "create_draft",
payload: validateAndSanitize(input),
});
const approved = await reviewFn(proposal, signal);
if (!approved || signal?.aborted) {
return { status: "canceled", committed: false };
}
// Backend must still re-verify session, principal, and idempotency key
return commitProposalToServer(proposal);
}
3. Separate Untrusted Content From Caller Instructions
If a read tool returns user-generated text (reviews, support tickets, CMS blocks), treat returned strings strictly as data:
- Render results with safe text APIs (
textContent), neverinnerHTMLor HTML injection. - Do not allow returned tool payloads to dynamically register new tools or alter confirmation prompts.
- Minimize returned fields: never leak internal tokens, hidden metadata, or another user's IDs.
4. Essential Release Gates Before Any Pilot
Before exposing any consequential tool in production:
- Contracts & Bounds: Reject wrong types, unknown properties, oversized strings, and out-of-range numbers inside the handler.
-
Lifecycle Teardown: Unregister tools via
AbortSignalon logout, account switch, or route unmount so stale contexts cannot execute. - Atomic Idempotency: Enforce idempotency keys on mutation endpoints and reject key reuse with a mismatched payload.
-
Explicit Failure Outcomes: Return explicit
denied,canceled,empty, orfailedstates—never silent fallbacks or false-success objects.
Interactive Security & Readiness Tools
- Interactive Security Worksheet: raghav453.github.io/webmcp-security-checklist
- WebMCP Readiness Assessment: raghav453.github.io/webmcp-readiness-checklist
- Architecture & Security Overview: WebMCPly Security Notes (WebMCPly is currently in pre-launch; early access & docs).
What security edge case worries you most with browser-side agent tools—cross-origin discovery, stale session tokens, or prompt-injected payloads? Drop your thoughts in the comments.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.
