hijackPageRequests installs the in-browser SSRF layer: every network request the rendered page issues is validated before it leaves Chromium, mirroring the dial-time guard of the plain HTTP path.
(page *rod.Page)
| 365 | // request the rendered page issues is validated before it leaves Chromium, |
| 366 | // mirroring the dial-time guard of the plain HTTP path. |
| 367 | func hijackPageRequests(page *rod.Page) error { |
| 368 | router := page.HijackRequests() |
| 369 | err := router.Add("*", "", func(h *rod.Hijack) { |
| 370 | if renderRequestAllowed(h.Request.URL().String()) { |
| 371 | h.ContinueRequest(&proto.FetchContinueRequest{}) |
| 372 | return |
| 373 | } |
| 374 | h.Response.Fail(proto.NetworkErrorReasonBlockedByClient) |
| 375 | }) |
| 376 | if err != nil { |
| 377 | return fmt.Errorf("installing request guard: %w", err) |
| 378 | } |
| 379 | go router.Run() |
| 380 | return nil |
| 381 | } |
| 382 | |
| 383 | // ── SSRF policy for in-page sub-requests ──────────────────────────── |
| 384 |
no test coverage detected