-
Notifications
You must be signed in to change notification settings - Fork 695
Description
Hi.
I noticed that websocket_bridge in Perfetto uses AddAllowedOrigin() to restrict access to specific origins:
srv.AddAllowedOrigin("http://localhost:10000");
srv.AddAllowedOrigin("http://127.0.0.1:10000");
srv.AddAllowedOrigin("https://ui.perfetto.dev");However, the origin of a HTTP request can be spoofed in multiple ways:
- Non-browser clients: Tools like curl or custom scripts can send arbitrary Origin.
- Browser-based spoofing: By manipulating DNS resolution in the client (e.g., pointing
localhostorui.perfetto.devto another server) and for HTTPS origins disable certificate validation or use a self-signed certificate where the CA is trusted inside the browser.
What I think this means is that the origin check in websocket_bridge provides limited security guarantees for the system running websocket_bridge, even against browser-based attacks, since a malicious client can bypass it entirely by crafting the request as it sees fit. Unlike CORS headers that are intended to protect non-malicious clients by informing the client of any allowed origins - this seems to want to protect the host.
I have two questions:
- What is the threat model that this access control avoids?
- Request: Is it possible to change the behaviour of
websocket_bridgeto allow any HTTP origin by default?
The reason for this request is to allow a Perfetto UI instances hosted inside a corporate network to connect to websocket_bridge without modifying the source code.