Skip to content

Commit

Permalink
tracer: Validate Origin on WebSocket connection
Browse files Browse the repository at this point in the history
To prevent abuse from untrusted web contents.
  • Loading branch information
ChiChou authored and oleavr committed Oct 19, 2024
1 parent bd67eb9 commit 03236f2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions frida_tools/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,16 @@ def _handle_asset_request(
self, connection: websockets.asyncio.server.ServerConnection, request: websockets.asyncio.server.Request
):
if request.headers.get("Connection") == "Upgrade":
origin = request.headers.get("Origin")
if origin != f"http://localhost:{self._ui_port}":
self._print(
Fore.RED
+ Style.BRIGHT
+ "Warning"
+ Style.RESET_ALL
+ f": Cross-origin request from {origin} denied"
)
return connection.respond(http.HTTPStatus.FORBIDDEN, "Cross-origin request denied\n")
return

raw_path = request.path.split("?", maxsplit=1)[0]
Expand Down

0 comments on commit 03236f2

Please sign in to comment.