python / python/cpython

Warn about urlsplit()'s `netloc` not being suitable for open redirect checking

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

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

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

説明

>>> from urllib.parse import urlsplit
>>> urlsplit('//example.com')
SplitResult(scheme='', netloc='example.com', path='', query='', fragment='')
>>> urlsplit('///example.com')
SplitResult(scheme='', netloc='', path='/example.com', query='', fragment='')
>>> urlsplit('////example.com')
SplitResult(scheme='', netloc='', path='//example.com', query='', fragment='')

This greatly differs from how browsers interpret it: Location: ////example.com will redirect you to example.com, which makes checking for a non-empty netloc to avoid open redirects useless.

I tested using Firefox (which starts treating it as a netloc starting with 4 slashes). httpie on the other hand does not have this problem, and curl simply rejects such invalid redirects. So it is most likely a a case of browsers simply tolerating garbage instead of refusing it.

I think a warning in the docs that it is not suitable for checking against open redirects may be a nice thing to add...

Linked PRs
  • gh-144448
  • gh-151621

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

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

はじめの一歩

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

調査の方向性

urllib.parse urlsplit() のドキュメントから始め、リンクされている PR gh-144448 と gh-151621 を確認してください。open redirect のチェックに関する文書化された制限を明確にし、そのうえで警告が issue に記載されたブラウザーの動作を正確に反映していることを確認してください。

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

評価

技術スタック
python
領域
documentation, security
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

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

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