python / python/cpython

http.cookies: parser accepts key characters that Morsel.set then rejects

オープン
#157,694 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

SimpleCookie.load() extracts cookie names using _LegalKeyChars, which deliberately admits characters RFC 6265 forbids in a token — the comment above it cites MSIE non-compliance as the reason. Morsel.set() then validates with _is_legal_key, built from _LegalChars, which excludes them. Twelve separator characters differ, so any Set-Cookie whose name contains one raises CookieError even though the module's own parser accepted it.

Encountered in the wild: F5 BIG-IP load balancers emit a persistence cookie named for the partition path, /Common/.app/--pool. Browsers accept this...

from http.cookies import SimpleCookie
SimpleCookie('/a/b=1')      # also a@b=1, a,b=1, a(b)=1
CPython versions tested on:

3.14

Operating systems tested on:

Linux

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

この issue では SimpleCookie.load()、Morsel.set()、_LegalKeyChars、_is_legal_key、_LegalChars が挙げられています。まず、これらの parser および validation の経路を追跡し、一覧にある cookie 名を再現してください。受け入れられる名前の動作に一貫性があり、例で CookieError が発生しなくなり、その不一致に対する regression coverage があれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。