markdown2 malformed HTML tokenizer CPU denial of service
まだ誰も着手していません。
評価
調査の方向性
lib/markdown2.py の _sorta_html_tokenize_re.split() から始め、添付された proof of concept を使って bash ./poc/run.sh で問題を再現します。タグ分岐の正規表現を調べ、不正なフラグメントが 1 秒のタイムアウトを引き起こさなくなっていることを、期待される HTML トークン化の動作を維持したまま確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
python-markdown2 can spend unbounded CPU in its inline HTML tokenizer when rendering attacker-controlled Markdown containing repeated malformed tag fragments. At the pinned commit, the public markdown2.markdown() path can pass that text to _sorta_html_tokenize_re.split() in lib/markdown2.py, and a roughly 60 KB input deterministically reaches the local one-second timeout oracle. Applications that render untrusted Markdown synchronously can therefore have request workers tied up by a single document.
To Reproduce
INT-regex-markdown2-html-tokenizer-redos.zip
See attached file.
bash ./poc/run.sh
timed_out after 1s
Expected behavior
Tag-branch regex fails to match the malformed fragment in linear time.
Debug info
- Project: markdown2
- Repo: https://github.com/trentm/python-markdown2
- Pinned ref: 28d94df671eb2a149643310513f84bb00a084072
For more details, see README.md of attached file.
- 主要言語
- Python
- スター
- 2.8k
- フォーク
- 459
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 4
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
trentm/python-markdown2 のほかの issue
-
Add py.typed marker オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
trentm/python-markdown2#696 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
trentm/python-markdown2#726 ·
-
Bug
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
trentm/python-markdown2#688 · コメント 4 件 ·
-
Bug
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
trentm/python-markdown2#679 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
trentm/python-markdown2#635 · コメント 2 件 ·
trentm/python-markdown2 の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
stephrobert/dsoxlab#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sublimehq/package_control#1780 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nwg-piotr/nwg-displays#145 ·