python / python/cpython

http.cookiejar.domain_match() matches an interior substring instead of a suffix

未關閉
#150,522 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-bug
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

domain_match(A, B) is documented to return True when A has the form NB, i.e. A ends with B (RFC 2965, section 1: "x.y.com domain-matches .Y.com but not Y.com"). It computes i = A.rfind(B) and only rejects i == -1 or i == 0, so a B that appears as an interior substring of A also matches:

>>> from http.cookiejar import domain_match
>>> domain_match("www.acme.com.evil.org", ".acme.com")
True

www.acme.com.evil.org does not end with .acme.com, so this should be False. The sibling helper user_domain_match() already uses A.endswith(B). This feeds the RFC 2965 (version > 0) cookie domain checks in set_ok_domain/return_ok_domain and is_third_party().

Linked PRs
  • gh-150523

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 http.cookiejar.domain_match() 開始,將其行為與同級的 user_domain_match() 輔助函式以及文件中記載的 RFC 2965 規則進行比較。驗證回報的範例不再與內部子字串相符,並檢查相關的 set_ok_domain、return_ok_domain 和 is_third_party() 路徑;已連結的 PR gh-150523 表示這項工作已在進行中。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
security
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。