fix(browser): scope per-context TLS bypass to LAN mode

The per-context setIgnoreHTTPSErrors was gated on ignoreHttpsErrors alone,
while the Chromium command-line cert flags require both ignoreHttpsErrors AND
allowPrivateNetwork. Setting only PLAYWRIGHT_IGNORE_HTTPS_ERRORS therefore
disabled certificate validation for all browser traffic, including the public
internet (MITM exposure). Gate the per-context bypass on allowPrivateNetwork
too, so ignoring HTTPS errors is scoped to LAN deployments — matching the
command-line path and the documented intent.

Also correct a comment: 192.0.0.192 is Oracle Cloud's IMDS address, not Azure.
This commit is contained in:
matevip 2026-07-02 09:27:09 +08:00
parent 9e33782b7d
commit b9f01db6f7
2 changed files with 5 additions and 2 deletions

View File

@ -360,7 +360,10 @@ public class BrowserLauncher {
Browser.NewContextOptions opts = new Browser.NewContextOptions()
.setViewportSize(props.getViewportWidth(), props.getViewportHeight())
.setLocale("zh-CN");
if (props.isIgnoreHttpsErrors()) {
// Gate the per-context TLS bypass on allowPrivateNetwork too (matching the
// command-line flags above), so ignoring HTTPS errors is scoped to LAN
// deployments and never silently disables cert validation for public traffic.
if (props.isIgnoreHttpsErrors() && props.isAllowPrivateNetwork()) {
opts.setIgnoreHTTPSErrors(true);
}
BrowserContext context = browser.newContext(opts);

View File

@ -47,7 +47,7 @@ public final class UrlSafetyChecker {
"instance-data",
"169.254.169.254", // AWS / Azure / GCP IMDS
"100.100.100.200", // Alibaba Cloud IMDS
"192.0.0.192", // Azure IMDS alternative
"192.0.0.192", // Oracle Cloud IMDS
"0.0.0.0",
"::1"
);