[Bug] Potential Billion Laughs Attack Vector via Unrestricted XML Parsing in `ZeepSchemaHelper`

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
security

調査の方向性

googleads/common.py の ZeepSchemaHelper から始め、特に transport.load(endpoint) と lxml.etree.fromstring(data) の呼び出しを確認してください。XML パーサーがどのように設定されているかを見直し、報告されているエンティティ展開と外部ネットワークアクセスのリスクに対するテストカバレッジを追加してください。完了条件は、スキーマが引き続き読み込まれる一方で、信頼できない XML によってエンティティ展開やネットワークアクセスが発生しないことです。

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

説明

Hello Google Ads API Team,

Firstly, thanks so much for your great work!
While using and reviewing the googleads-python-lib, I came across a potential XML parsing issue in the ZeepSchemaHelper class that I'd like to raise for discussion.

I understand that the library is designed to work with trusted WSDL endpoints provided by Google, and this issue is unlikely to be exploitable under normal use. However, for defense-in-depth and potential future-proofing, I wanted to share the finding.

# Affected Source Code: `googleads/common.py`

class ZeepSchemaHelper(GoogleSchemaHelper):
  def __init__(self, endpoint, timeout, proxy_config, namespace_override, cache):
    ...
    transport = _ZeepProxyTransport(timeout, proxy_config, cache)
    
    try:
      data = transport.load(endpoint)  #   [Untrusted Input Source: XML from user-supplied endpoint]
    except requests.exceptions.HTTPError as e:
      raise googleads.errors.GoogleAdsSoapTransportError(str(e))

    self.schema = zeep.xsd.Schema(
        lxml.etree.fromstring(data)    #  [VULNERABILITY SINK: unsafe XML parsing]
    )

This type of attack leverages recursive entity declarations in XML to cause exponential memory usage like the Billion Laughs attack.

We can set

parser = lxml.etree.XMLParser(
    resolve_entities=False,
    load_dtd=False,
    no_network=True
)

to solve this

主要言語
Python
スター
749
フォーク
967
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

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

googleads/googleads-python-lib のほかの issue

googleads/googleads-python-lib の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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