[Bug] Chromium: launch({ proxy: { username, password } }) credentials are sent to a website's 401 Basic challenge
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- playwright, python, typescript
調査の方向性
Start with CRBrowserContext and CRNetworkManager._onAuthRequired in the Chromium backend, then trace authenticateProxyViaCredentials() and _shouldProvideCredentials(event.request.url); the issue says Firefox and WebKit may need the same check. Find or add coverage for a cached proxy authentication followed by a site's 401 Basic challenge. Done when proxy credentials answer proxy challenges only and are never sent to the site, while configured httpCredentials continue to follow their origin.
索引モデルが issue の本文から書いたものです。
説明
Version
- Playwright 1.62.0 (Python,
playwrightpackage; same code in playwright-corecoreBundle.js) - Chromium (bundled
chromium_headless_shell-1234) - macOS 26.5 (should be platform independent)
Steps to reproduce
Fully local, self-contained script (no external network access): a Basic-auth HTTP proxy on 127.0.0.1 and a site that returns 401 WWW-Authenticate: Basic.
"""Minimal repro: Playwright launch proxy credentials are sent to a site's 401 Basic challenge.
Local only: a tiny HTTP proxy that requires Basic auth (127.0.0.1) and a site that answers 401 Basic.
"""
import asyncio
import base64
import threading
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import urllib.request
from playwright.async_api import async_playwright
PROXY_USER, PROXY_PASS = "proxyuser", "proxy-secret-123"
SEEN = []
class Site(BaseHTTPRequestHandler):
def do_GET(self):
SEEN.append((self.path, self.headers.get("Authorization")))
if self.path.startswith("/protected"):
self.send_response(401)
self.send_header("WWW-Authenticate", 'Basic realm="site"')
self.end_headers()
self.wfile.write(b"no")
return
self.send_response(200)
self.end_headers()
self.wfile.write(b"ok")
def log_message(self, *a):
pass
class Proxy(BaseHTTPRequestHandler):
def do_GET(self):
want = "Basic " + base64.b64encode(f"{PROXY_USER}:{PROXY_PASS}".encode()).decode()
if self.headers.get("Proxy-Authorization") != want:
self.send_response(407)
self.send_header("Proxy-Authenticate", 'Basic realm="proxy"')
self.end_headers()
return
headers = {k: v for k, v in self.headers.items() if k.lower() not in ("proxy-authorization", "proxy-connection")}
req = urllib.request.Request(self.path.replace("site.test", "127.0.0.1"), headers=headers)
try:
resp = urllib.request.urlopen(req)
status, body, rh = resp.status, resp.read(), resp.headers
except urllib.error.HTTPError as e:
status, body, rh = e.code, e.read(), e.headers
self.send_response(status)
for k, v in rh.items():
if k.lower() not in ("transfer-encoding", "connection"):
self.send_header(k, v)
self.end_headers()
self.wfile.write(body)
def log_message(self, *a):
pass
def serve(handler):
srv = ThreadingHTTPServer(("127.0.0.1", 0), handler)
threading.Thread(target=srv.serve_forever, daemon=True).start()
return srv
async def main():
site, proxy = serve(Site), serve(Proxy)
site_url = f"http://site.test:{site.server_port}"
async with async_playwright() as p:
browser = await p.chromium.launch(
proxy={"server": f"http://127.0.0.1:{proxy.server_port}", "username": PROXY_USER, "password": PROXY_PASS},
args=["--proxy-bypass-list=<-loopback>"],
)
page = await browser.new_page()
r1 = await page.goto(site_url + "/warm") # proxy auth happens here (cache becomes warm)
r2 = await page.goto(site_url + "/protected") # site answers 401 Basic
print("warm status", r1.status, "| protected status", r2.status)
await browser.close()
leaked = [a for path, a in SEEN if path.startswith("/protected") and a]
for path, a in SEEN:
print("site saw", path, "Authorization:", (base64.b64decode(a.split()[1]).decode() if a else None))
print("LEAK" if any(PROXY_PASS in base64.b64decode(a.split()[1]).decode() for a in leaked) else "NO LEAK")
asyncio.run(main())
Run: pip install playwright && playwright install chromium && python repro.py
Expected
The proxy credentials are used only for the proxy's 407 Proxy-Authenticate challenge. A site's 401 WWW-Authenticate challenge should get no credentials (or only httpCredentials explicitly configured for that origin).
Actual
The site receives Authorization: Basic base64("proxyuser:proxy-secret-123"):
warm status 200 | protected status 401
site saw /warm Authorization: None
site saw /protected Authorization: None
site saw /protected Authorization: proxyuser:proxy-secret-123 <-- proxy credentials sent to the website
Cause (from reading the source)
CRBrowserContextconstructor callsauthenticateProxyViaCredentials(), which copies the launch proxy credentials intothis._options.httpCredentials = { username, password }with noorigin, overwriting any user-suppliedhttpCredentials.CRNetworkManager._onAuthRequired(event)decides via_shouldProvideCredentials(event.request.url). Without anorigin, that returns true for every request, so it answersFetch.authRequiredwithProvideCredentialsregardless ofevent.authChallenge.source("Proxy"vs"Server").
On a cold cache the single per-request attempt is consumed by the proxy's 407, so the site's 401 gets CancelAuth; once the proxy auth is cached, the site's 401 gets the proxy credentials.
Things tried
new_context(http_credentials={..., "origin": <proxy origin>})together with launch proxy credentials: overwritten by step 1, still leaks.- Proxy credentials only via
http_credentialswith proxy origin (no launch credentials): the origin is compared against the request URL (the site), so the proxy's 407 is not answered. extra_http_headers={"Proxy-Authorization": ...}: for HTTPS this ends up inside the tunnel and is sent to the site, which is worse.
Suggested fix
Keep proxy credentials separate from httpCredentials, and in _onAuthRequired use event.authChallenge.source: answer "Proxy" challenges only with the proxy credentials and "Server" challenges only with httpCredentials (subject to its origin). Firefox/WebKit backends may need the same check.
Security note
Any website the automated browser visits can obtain the proxy credentials by returning 401 Basic. For authenticated corporate/residential proxies this exposes the proxy account.
- 主要言語
- TypeScript
- スター
- 97.4k
- フォーク
- 6.6k
- 平均マージ
- 18時間 53分
- マージ済み PR(30日)
- 307
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/playwright のほかの issue
-
[Feature]: Set `this.name` in `TargetClosedError` constructor再び着手できるかも @LeonxLJX が 42 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンP3-collecting-feedback
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
microsoft/playwright#42522 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: mouse movement deltas is 0 in mouse events in webkit対応中かも @yury-s が今日担当しました。 オープンbrowser-webkit v1.65
microsoft/playwright#43417 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: WebKit (WPE) web process aborts at exit in PlatformDisplay::sharedDisplay() since 1.64 (webkit-2370)対応中かも @yury-s が 1 日前に担当しました。 オープンbrowser-webkit v1.65
microsoft/playwright#43394 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Chromium 149 headless shell crashes in service-worker DevTools resource loading during context teardown対応中かも @yury-s が 1 日前に担当しました。 オープンbrowser-chromium upstream v1.65
microsoft/playwright#43374 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Feature]: Allow `retryStrategy: 'isolated'` in test.describe.configure() for tests requiring zero background workers対応中かも @yury-s が今日担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
microsoft/playwright#43351 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
microsoft/playwright の issue をすべて見る
似ている issue
-
documentation good first issue
難易度 2/5 半日 初心者へのやさしさ 72/100
sujithputta02/Esapay#13 ·
-
Share dialog: the address book's contact count reads "1 contacts" (no singular form in any language)対応中かも @chibenwa が今日担当しました。 オープンai-driven-qa bug claude Cosmetic
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
linagora/twake-contacts-frontend#271 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Koenkk/zigbee2mqtt#33402 ·
メンテナーはふだん 1 日以内に返信
-
dx P2 platform Stellar Wave Wave 10
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
winsznx/routedock#579 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:ui effort:S enhancement priority:P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信