Summary
A server-side origin validation weakness in PraisonAI's MCP HTTP Stream handling can allow an attacker-controlled web origin to satisfy a localhost allowlist. Under deployments that expose the MCP endpoint without additional authentication or request protections, a webpage may invoke tools and potentially write files that persist agent instructions.
Affected context
The issue occurs in PraisonAI deployments using the MCP HTTP Stream interface before origin validation was corrected. Risk is higher when the endpoint is reachable by browser-based requests, relies on a localhost origin allowlist, permits simple requests without preflight enforcement, and does not require an API key or equivalent authentication for tool invocation.
Exploit preconditions
- Attack surface: MCP HTTP Stream endpoint accessible from a browser or web page
- Required access: Ability to cause a user's browser or another HTTP client to send requests to the endpoint
- Trigger point: Origin validation performed during MCP request handling
- Security condition: The validation logic treats a trusted origin as a prefix rather than requiring an exact, trusted-origin match
- Additional exposure: Tool calls remain available without strong request authentication or equivalent authorization controls
- Why exploitation is possible: An attacker-controlled origin can be accepted as trusted, while simple request content types may avoid browser preflight protections
Why this happens
The underlying bug is an origin comparison flaw. Using a prefix-based check such as startswith for an allowlist can accept domains that merely begin with a trusted hostname, rather than limiting access to the exact origin and its permitted scheme and port.
This maps primarily to CWE-346: Origin Validation Error. The browser-facing request behavior also relates to CWE-352: Cross-Site Request Forgery, because insufficient origin and authorization controls may allow a third-party webpage to cause state-changing requests in a user's browser context.
Potential impact
- An attacker could invoke exposed MCP tools without the intended API-key protection
- Unauthorized tool operations may alter application or agent state
- File-writing tools could persist malicious or misleading agent instructions
- Agent behavior, workflows, or downstream results could be manipulated
- The affected service or connected resources may experience data integrity or confidentiality impacts
General mitigation guidance
Mitigation generally focuses on exact origin validation, strong authorization, and reducing browser-driven state changes.
Common defensive patterns include:
- Compare normalized scheme, host, and port values against an explicit trusted-origin set rather than using prefix matching
- Require authentication and authorization for every tool invocation, including requests from local or trusted-looking origins
- Use anti-CSRF protections with server-side token validation for browser-accessible state-changing endpoints
- Restrict or disable browser access to MCP endpoints when it is not required
- Accept only the request content types and methods required by the protocol, while not treating preflight behavior as the sole security control
- Apply least privilege to file-writing tools and isolate agent instruction stores from sensitive resources
- Use secure defaults that deny unknown origins and require explicit endpoint exposure
How teams detect issues like this
Organizations can look for:
- Static analysis rules identifying prefix, substring, or loosely normalized origin comparisons
- Code review findings where origin checks are used without authentication, CSRF protection, or exact scheme-host-port matching
- Tests covering attacker-controlled domains that share a trusted hostname prefix
- Integration tests verifying that simple cross-origin requests cannot invoke state-changing tools without authorization
- Runtime logs for rejected and accepted origins, unauthenticated tool calls, unusual file writes, and unexpected instruction changes
- Policy checks requiring explicit trusted-origin inventories and authenticated access for administrative or tool-execution endpoints
Automated security review tools may help identify weak origin comparisons and missing authorization checks.

