Skip to content

#2095 Apply the IP address filter to the requests made by the Playwright browser - #2165

Open
rzo1 wants to merge 3 commits into
apache:mainfrom
rzo1:2095-playwright-ip-filter
Open

rzo1 wants to merge 3 commits into
apache:mainfrom
rzo1:2095-playwright-ip-filter

Conversation

@rzo1

@rzo1 rzo1 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #2095. Depends on #2158 (stacked; review only the last commit until #2158 is merged).

The existing route handler now checks each browser request (page, redirects, subresources) against http.filter.ipaddress.* and aborts rejected ones. Not applied through http.proxy, same as OkHttp. The address is resolved separately from the browser and WebSockets are not checked; both limits are documented.

URL filters are not applied here: main page redirects are already aborted and go through the regular pipeline, and crawl-scope filters on subresources would break rendering.

Release note: with the default exclude list, Playwright topologies crawling loopback or private addresses need to override http.filter.ipaddress.exclude.

@rzo1 rzo1 added this to the 4.0.0 milestone Sep 15, 2026
@rzo1
rzo1 requested review from dpol1 and jnioche September 15, 2026 10:58

@dpol1 dpol1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the URI parsing breaks with the default exclude list and the docs promise more than the handler sees, see inline

}
final URI uri;
try {
uri = new URI(url);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new URI fails on |, [, ] (and { } ^ in a query), which Chromium sends as is, and gives no host for a name with _: with the default exclude list those get aborted as forbidden. HttpUrl.parse takes them all, and a test with one of them?

# to the target, so only its address is known here and a proxy on a private
# address is fine. The proxy's own egress rules decide what it may reach.
# Applies to the okhttp and playwright protocols. Playwright checks each
# request of the browser (page, redirects, subresources) against an address

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redirect hops never go through the handler, only the first url does (the note above page.route says it, and a 302 on an image and on the main page confirmed it), so this should list redirects with websockets as not checked. same block still says okhttp only, and the adoc line on failing with an IOException doesn't hold for a blocked subresource.

} else if (resourceTypesToSkip.contains(
route.request().resourceType())) {
route.abort();
} else if (!isAllowedAddress(route.request().url())) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the handler also misses what a service worker fetches (playwright suggests setServiceWorkers(BLOCK) when routing) and popups, which open unblocked with no handler at all unless the route sits on the context. block them or document them, your call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playwright protocol applies neither the IP filter nor the URL filters to the requests it makes

2 participants