Summary
PrefectHQ Prefect versions up to 3.6.13 contain a missing authentication flaw in the /api/events/in WebSocket endpoint.
Under certain conditions, a remote attacker can interact with this endpoint without proper authentication, potentially sending or injecting events that should be restricted to authenticated clients.
Affected context
This vulnerability appears in Prefect deployments exposing the WebSocket-based events ingestion endpoint at /api/events/in.
It is relevant when the Prefect API is reachable from networks where untrusted clients may exist (e.g., internet-facing or shared internal networks) and when the WebSocket endpoint does not enforce or correctly verify authentication for incoming connections or messages.
The flaw is tied to how authentication and/or session validation is implemented for this specific endpoint, rather than to a particular operating system or hosting model.
Exploit preconditions
- Attack surface: Network-accessible Prefect API server exposing the
/api/events/inWebSocket endpoint. - Required access: Ability to establish a network connection to the Prefect API host and initiate a WebSocket session; no valid user credentials are required if the flaw is present.
- Trigger point: Opening a WebSocket connection and sending crafted event traffic to
/api/events/inwithout following the normal authentication or session-establishment flow. - Why exploitation is possible: The endpoint does not consistently enforce authentication or authorization checks, allowing unauthenticated clients to access functionality that should be restricted to authenticated users or internal components, mapping to CWE-287 (Improper Authentication) and CWE-306 (Missing Authentication for Critical Function).
Why this happens
At its core, the issue stems from incomplete or inconsistent enforcement of authentication on a WebSocket endpoint responsible for ingesting events.
While other HTTP or API routes may require valid credentials, token-based auth, or session cookies, the /api/events/in WebSocket handler appears to either skip these checks or rely on assumptions about trust that are not enforced at runtime.
This behavior aligns with CWE-287: Improper Authentication, where the system fails to verify the identity of a user or client before granting access, and CWE-306: Missing Authentication for Critical Function, since event ingestion is often a privileged capability that can influence workflows, monitoring, or orchestration.
Conceptually, the bug reflects an architectural gap between authentication on traditional HTTP endpoints and equivalent controls on WebSocket-based APIs.
Potential impact
- Unauthenticated clients may send events into the system that can influence orchestration, logs, or monitoring.
- Attackers could spoof or flood events, potentially leading to confusion, operational disruption, or masking of real activity.
- Unauthorized event injection may trigger downstream automation or workflows, indirectly affecting job execution or state transitions depending on how events are consumed.
- Security monitoring or audit trails may be polluted with forged data, complicating incident response and forensics.
- In some deployments, combined with other misconfigurations, this could contribute to privilege escalation or lateral movement by manipulating event-driven behavior.
General mitigation guidance
Mitigation focuses on enforcing strong, consistent authentication and authorization across all communication channels, including WebSocket endpoints:
- Apply the same authentication middleware or framework used for HTTP APIs to WebSocket handlers, ensuring every connection and message is tied to a verified identity.
- Treat event ingestion endpoints as sensitive surfaces: require bearer tokens, API keys, or mutual TLS where appropriate, and validate them on every new connection.
- Introduce explicit authorization checks so only specific roles or service accounts can send events, and validate that event content aligns with the caller's privileges.
- Segment network exposure: restrict access to
/api/events/into trusted internal networks, service meshes, or sidecar proxies rather than exposing it directly to the internet. - Implement rate limiting, quotas, and input validation on event payloads to reduce the blast radius of any abuse and to prevent resource exhaustion.
- Design authentication as "secure by default": newly added real-time or streaming endpoints should require authentication unless explicitly and narrowly justified as public.
How teams detect issues like this
Detection is best approached through a mix of code-level analysis and runtime monitoring:
- Static analysis and code review:
- Search for WebSocket route definitions (e.g.,
/api/events/in) that are not wrapped in the same authentication middleware or decorators used elsewhere. - Flag handlers that access sensitive functionality without verifying user identity, tokens, or session context.
- Use SAST tools or linters configured with rules for CWE-287/CWE-306 to highlight endpoints lacking auth checks.
- Configuration and architecture review:
- Review API gateway, reverse proxy, or service mesh configurations to ensure WebSocket routes are protected by the same auth policies as REST endpoints.
- Validate that documentation and diagrams correctly classify event ingestion as a protected function, not as a public telemetry sink.
- Runtime and log analysis:
- Monitor logs for connections to
/api/events/inwithout associated user or service identities. - Alert on unusual volumes of events from unknown IP ranges or unauthenticated sessions.
- Use security monitoring or WAF tooling capable of inspecting WebSocket traffic patterns for anomalies.
- Security testing:
- Incorporate WebSocket-specific tests into regular penetration tests and CI pipelines, verifying that unauthenticated connections are rejected and that invalid tokens are handled consistently.

