googleads / googleads/googleads-python-lib

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

Open
#558 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
749
Forks
967
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in googleads/common.py at ZeepSchemaHelper, especially transport.load(endpoint) and the lxml.etree.fromstring(data) call. Review how the XML parser is configured and add coverage for the reported entity-expansion and external-network risks. Done means the schema still loads while untrusted XML cannot trigger entity expansion or network access.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.