Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces host header validation to ensure that the graph server only accepts requests targeting the loopback interface, mitigating potential DNS-rebinding attacks. This is implemented via a new _host_is_loopback helper method and applied to both GET and POST requests, with corresponding unit tests added. Feedback suggests wrapping the urllib.parse.urlsplit call in a try...except ValueError block to gracefully handle malformed Host headers and prevent unhandled exceptions.
|
Hi @Samin061, Thanks for opening a PR! We'll need to add this to each new test |
|
I'm going to switch this to draft but please mark it ready for review once tests are green |
Guard urlsplit against ValueError on malformed Host headers.
|
Added the skipif decorator to each of the three new host-header tests, matching the rest of the file. Also guarded the urlsplit call against a ValueError on a malformed Host. Marking ready for review. |
|
Hi @Samin061, Please could you resolve the minor coverage gap? |
|
Added two direct tests for |
|
Gemini raised a concern that we should also inspect
Could we add these 2 tests? Gemini suggested this fix
|
Signed-off-by: bibi samina <sam@bugqore.com>
|
Done. Folded the Origin/Referer check into the helper (now |
|
any update? |
GraphServerHandler.do_GET/do_POST served any request that reached the loopback port, so a page in the notebook user's browser can reach the server through DNS rebinding and drive its /post_query handler, which routes into convert_graph_params and builds a BigQuery client with the user's credentials to call list_rows against a caller-supplied api endpoint and table. The widget is legitimately cross-origin because the notebook page and this server run on different ports, so Origin cannot gate the request, but real widget traffic always carries a loopback Host. The handlers now check the Host header and refuse anything that is not localhost, 127.0.0.1, or ::1.