Why WebMCP Security is Different
The Multi-Website Threat Model
Critical Context: AI agents can interact with multiple websites simultaneously. Your tools may be used by an agent that has also loaded tools from malicious websites. This creates a unique security challenge where compromised agents can abuse your tools.
- Trusted tools: Your website’s legitimate functionality
- Unknown tools: Tools from other websites the user is visiting
- Malicious tools: Tools from compromised or malicious websites
- Exfiltrating sensitive data through your tools
- Performing unauthorized actions using your authenticated APIs
- Tricking users into approving dangerous operations
Core Security Principles
User Context
Tools run with the user’s existing session and permissions
Origin Validation
Transport layer enforces same-origin policy
No Credential Sharing
AI agents never receive user credentials
Explicit Actions
Tools only expose user-authorized actions
Agent-Specific Threats
Prompt Injection: The “Lethal Trifecta”
Prompt injection occurs when malicious actors manipulate AI agent behavior by crafting inputs that override intended instructions. The most dangerous scenarios occur when three conditions align:- Private user data access - Tools that access personal information (emails, messages, profiles)
- Untrusted content exposure - AI processes content from potentially malicious sources
- External communication - Ability to send data outside the user’s browser
Never Pass Sensitive Data to Agents
- Vanilla JS
- React
- Passwords, tokens, API keys, session IDs
- Private messages, emails, documents
- Personal information (SSN, credit cards, addresses)
- Financial data (account numbers, balances)
- Health records, legal documents
- Any data you wouldn’t want copied to a malicious website
Other Prompt Injection Mitigations
Limit Dangerous Tool Combinations: Don’t expose tools that create the lethal trifecta on the same page. Avoid combining private data access with external communication tools. Content Source Validation: Tag data with trust levels to help users understand provenance:- Vanilla JS
- React
Tool Misrepresentation Risks
Since WebMCP tools run with the user’s authenticated session, a deceptive tool could describe itself as “add to cart” while actually completing a purchase and charging the user’s payment method. Mitigation: Honest Descriptions + Annotations- Vanilla JS
- React
Privacy: User Fingerprinting via Over-Parameterization
When AI agents have access to user personalization data, malicious sites can craft tool parameters to extract this information without explicit user consent, enabling covert profiling of users who thought they were anonymous.- Vanilla JS
- React
- Only request parameters you genuinely need
- Use server-side user context instead of parameters
- Separate authenticated tools from anonymous features
- Audit tool parameters regularly: Would an anonymous user be comfortable providing this?
Protection Patterns
Protecting User Sessions
Your tools run in the user’s browser context with their existing authentication. Always validate permissions and inputs:- Vanilla JS
- React
- Vanilla JS
- React
Sensitive Operations & User Consent
For destructive or sensitive operations, use multiple layers of protection:- Vanilla JS
- React
User Elicitation for Sensitive Data
Best Practice: For sensitive operations requiring user input (passwords, payment details, etc.), collect data via UI instead of passing through the agent. This protects sensitive data from being exposed to potentially compromised agents.
- Vanilla JS
- React
Standard Web Security
Beyond agent-specific risks, follow standard web security practices:Transport Security
In production, explicitly whitelist allowed origins:- Vanilla JS
- React
Error Handling
Don’t leak system information in error messages:- Vanilla JS
- React
Common Web Vulnerabilities
XSS (Cross-Site Scripting): Always sanitize HTML with DOMPurify before rendering user-provided content. CSRF (Cross-Site Request Forgery): Usecredentials: 'same-origin' to include CSRF tokens from cookies.
IDOR (Insecure Direct Object References): Always validate server-side that the user owns/can access the requested resource.
For detailed guidance on these standard vulnerabilities, see OWASP Top 10.
Security Checklist
Before deploying WebMCP tools to production:1
Agent-Specific Protections
✅ Sensitive data uses references, not raw values
✅ No dangerous tool combinations (private data + external communication)
✅ Tool descriptions accurately match behavior
✅ Destructive tools marked with
destructiveHint: true
✅ Minimal tool parameters to prevent fingerprinting
✅ User elicitation for passwords and sensitive inputs2
Authorization & Validation
✅ All tools check user permissions
✅ Server-side authorization enforced
✅ All inputs validated with JSON Schema or Zod
✅ Tools use
credentials: 'same-origin'
✅ Sensitive tools only registered for authorized users3
Data Protection
✅ Only necessary data returned in responses
✅ No sensitive fields (passwords, tokens, keys) exposed
✅ Responses filtered based on user role
✅ Production origins whitelisted
✅ HTTPS enforced
4
User Consent & Confirmations
✅ Destructive operations require explicit confirmation
✅ Browser confirmation dialogs for high-impact actions
✅ Rate limiting on sensitive operations
✅ Security events logged for audit trail
5
Error & Security Monitoring
✅ Generic error messages for users
✅ Detailed logging for debugging
✅ No stack traces or system info exposed
✅ Unauthorized access attempts logged
Additional Resources
OWASP Top 10
Common web security risks
Content Security Policy
MDN CSP documentation
MCP Security
MCP protocol security
Report Security Issues
If you discover a security vulnerability in WebMCP:- Do not open a public GitHub issue
- Email security concerns to: security@mcp-b.ai
- Include detailed steps to reproduce
- Allow time for us to patch before public disclosure
We take security seriously and will respond to vulnerability reports within 48 hours.
