Skip to content

Request: Allow any origin for websocket_bridge #4547

@helo-xperi

Description

@helo-xperi

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:

  1. Non-browser clients: Tools like curl or custom scripts can send arbitrary Origin.
  2. Browser-based spoofing: By manipulating DNS resolution in the client (e.g., pointing localhost or ui.perfetto.dev to 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:

  1. What is the threat model that this access control avoids?
  2. Request: Is it possible to change the behaviour of websocket_bridge to 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions