Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[security] CVE-2013-0340 "Billion Laughs" fixed in Expat >=2.4.0: Update vendored copy to expat 2.4.1 #88560

Closed
vstinner opened this issue Jun 11, 2021 · 20 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes extension-modules C modules in the Modules dir type-security A security issue

Comments

@vstinner
Copy link
Member

BPO 44394
Nosy @scoder, @vstinner, @ned-deily, @ambv, @hartwork, @pablogsal, @miss-islington
PRs
  • bpo-44394: Update libexpat copy to 2.4.1 #26945
  • [3.10] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) #28031
  • [3.9] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) #28032
  • [3.8] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) #28033
  • [3.7] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) #28042
  • [3.6] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) (GH-28042) #28080
  • bpo-44394: Ensure libexpat is linked against libm #28617
  • [3.9] bpo-44394: Ensure libexpat is linked against libm (GH-28617) #28619
  • [3.8] bpo-44394: Ensure libexpat is linked against libm (GH-28617) #28620
  • [3.10] bpo-44394: Ensure libexpat is linked against libm (GH-28617) #28621
  • bpo-44394: [typo] s/libexpact/libexpat/ in setup.py #28624
  • [3.9] bpo-44394: [typo] s/libexpact/libexpat/ in setup.py (GH-28624) #28627
  • Files
  • cpython_rebuild_expat_dir.sh
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-08-31.07:05:24.142>
    created_at = <Date 2021-06-11.14:14:07.254>
    labels = ['type-security', '3.8', '3.9', '3.10', '3.11', 'extension-modules', '3.7']
    title = '[security] CVE-2013-0340 "Billion Laughs" fixed in Expat >=2.4.0: Update vendored copy to expat 2.4.1'
    updated_at = <Date 2022-01-01.17:11:10.030>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2022-01-01.17:11:10.030>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-31.07:05:24.142>
    closer = 'ned.deily'
    components = ['Extension Modules']
    creation = <Date 2021-06-11.14:14:07.254>
    creator = 'vstinner'
    dependencies = []
    files = ['50129']
    hgrepos = []
    issue_num = 44394
    keywords = ['patch']
    message_count = 20.0
    messages = ['395634', '395642', '395649', '396688', '400534', '400537', '400538', '400539', '400547', '400601', '400691', '400694', '400695', '402783', '402797', '402869', '402872', '402875', '402880', '409459']
    nosy_count = 7.0
    nosy_names = ['scoder', 'vstinner', 'ned.deily', 'lukasz.langa', 'sping', 'pablogsal', 'miss-islington']
    pr_nums = ['26945', '28031', '28032', '28033', '28042', '28080', '28617', '28619', '28620', '28621', '28624', '28627']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'security'
    url = 'https://bugs.python.org/issue44394'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    @vstinner
    Copy link
    Member Author

    Our vendored copy of Modules/expat/ should be updated to Expat 2.4.1 to retrieve the fix for the security vulnerabily CVE-2013-0340 "Billion Laughs":
    https://blog.hartwork.org/posts/cve-2013-0340-billion-laughs-fixed-in-expat-2-4-0/

    The table of vulnerabilities in Python XML parsers should be updated as well:
    https://docs.python.org/dev/library/xml.html#xml-vulnerabilities

    My outdated notes on Modules/expat/: copy of libexpat

    https://pythondev.readthedocs.io/files.html

    @vstinner vstinner added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes extension-modules C modules in the Modules dir type-security A security issue labels Jun 11, 2021
    @gvanrossum
    Copy link
    Member

    (From PSRT list, Sebastian:)

    Please note that the vulnerability fix also added two new functions to
    the API that would be great to have xml.parsers.expat expose to the
    users for full control. These are:

    • XML_SetBillionLaughsAttackProtectionMaximumAmplification and
    • XML_SetBillionLaughsAttackProtectionActivationThreshold

    Module xml.parsers.expat.errors and its docs also needs 6 new error code
    entries to be complete:

    /* Added in 2.0. */
    38 XML_ERROR_RESERVED_PREFIX_XML
    39 XML_ERROR_RESERVED_PREFIX_XMLNS
    40 XML_ERROR_RESERVED_NAMESPACE_URI

    /* Added in 2.2.1. */
    41 XML_ERROR_INVALID_ARGUMENT

    /* Added in 2.3.0. */
    42 XML_ERROR_NO_BUFFER

    /* Added in 2.4.0. */
    43 XML_ERROR_AMPLIFICATION_LIMIT_BREACH

    With regard to the table of vulnerabilities mentioned in the ticket,
    please note that vulnerability "quadratic blowup" is also fixed by

    =2.4.0. Personally, I consider it a flavor of Billion Laughs and all
    know variations are covered, including that one.

    @hartwork
    Copy link
    Mannequin

    hartwork mannequin commented Jun 11, 2021

    FTR that^^ Sebastian is me :)

    @hartwork hartwork mannequin changed the title [security] CVE-2013-0340 "Billion Laughs" fixed in Expat >=2.4.0: Updated to vendoed copy to expat 2.4.1 [security] CVE-2013-0340 "Billion Laughs" fixed in Expat >=2.4.0: Update vendored copy to expat 2.4.1 Jun 11, 2021
    @hartwork hartwork mannequin changed the title [security] CVE-2013-0340 "Billion Laughs" fixed in Expat >=2.4.0: Updated to vendoed copy to expat 2.4.1 [security] CVE-2013-0340 "Billion Laughs" fixed in Expat >=2.4.0: Update vendored copy to expat 2.4.1 Jun 11, 2021
    @vstinner
    Copy link
    Member Author

    Attached cpython_rebuild_expat_dir.sh script updates Modules/expat/ to our libexpat copy to 2.4.1. I used it to create attached PR 26945.

    @ambv
    Copy link
    Contributor

    ambv commented Aug 29, 2021

    New changeset 3fc5d84 by Victor Stinner in branch 'main':
    bpo-44394: Update libexpat copy to 2.4.1 (GH-26945)
    3fc5d84

    @ambv
    Copy link
    Contributor

    ambv commented Aug 29, 2021

    New changeset c9c2a0b by Miss Islington (bot) in branch '3.8':
    bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) (GH-28033)
    c9c2a0b

    @miss-islington
    Copy link
    Contributor

    New changeset 2706785 by Miss Islington (bot) in branch '3.10':
    bpo-44394: Update libexpat copy to 2.4.1 (GH-26945)
    2706785

    @ambv
    Copy link
    Contributor

    ambv commented Aug 29, 2021

    New changeset 007221a by Miss Islington (bot) in branch '3.9':
    bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) (GH-28032)
    007221a

    @ambv
    Copy link
    Contributor

    ambv commented Aug 29, 2021

    3.6 will need a separate backport because it's using expat 2.2.6 at the moment (from b2260e5).

    3.7 conflicted since it didn't include local changes to the vendored 2.2.8 that were introduced in 3.8+. I fixed that, the backport is up.

    @vstinner
    Copy link
    Member Author

    I created https://python-security.readthedocs.io/vuln/expat-billion-laughs.html to track this vulnerability.

    @ned-deily
    Copy link
    Member

    New changeset 79101b8 by Łukasz Langa in branch '3.7':
    [3.7] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) (GH-28042)
    79101b8

    @ned-deily
    Copy link
    Member

    New changeset 910886a by Ned Deily in branch '3.6':
    [3.6] bpo-44394: Update libexpat copy to 2.4.1 (GH-26945) (GH-28042) (GH-28080)
    910886a

    @ned-deily
    Copy link
    Member

    PRs merged in 3.7 branch for release in 3.7.12 and in 3.6 branch for release in 3.6.15.

    @pablogsal
    Copy link
    Member

    The backport to 3.8 broke 3.8.12 in AIX:

    0/Modules/_decimal/libmpdec/sixstep.o build/temp.aix-7.1-3.8/tmp/python3.8-3.8.12-0/Modules/_decimal/libmpdec/transpose.o -L. -L/opt/bb/lib -L/opt/bb/lib64 -R/opt/bb/lib64 -lm -o build/lib.aix-7.1-3.8/_decimal.cpython-38.so

    *** WARNING: renaming "pyexpat" since importing it failed: rtld: 0712-001 Symbol _isnanf was referenced
    from module build/lib.aix-7.1-3.8/pyexpat.cpython-38.so(), but a runtime definition of the symbol was not found.

    @hartwork
    Copy link
    Mannequin

    hartwork mannequin commented Sep 28, 2021

    For the AIX link error that Pablo brought up, there is merged pull request libexpat/libexpat#510 upstream.

    @pablogsal
    Copy link
    Member

    New changeset 6c1154b by Pablo Galindo Salgado in branch 'main':
    bpo-44394: Ensure libexpat is linked against libm (GH-28617)
    6c1154b

    @miss-islington
    Copy link
    Contributor

    New changeset fafa213 by Miss Islington (bot) in branch '3.9':
    bpo-44394: Ensure libexpat is linked against libm (GH-28617)
    fafa213

    @ambv
    Copy link
    Contributor

    ambv commented Sep 29, 2021

    New changeset 412ae8a by Miss Islington (bot) in branch '3.10':
    [3.10] bpo-44394: Ensure libexpat is linked against libm (GH-28617) (GH-28621)
    412ae8a

    @ambv
    Copy link
    Contributor

    ambv commented Sep 29, 2021

    New changeset 90004fc by Miss Islington (bot) in branch '3.8':
    [3.8] bpo-44394: Ensure libexpat is linked against libm (GH-28617) (GH-28620)
    90004fc

    @scoder
    Copy link
    Contributor

    scoder commented Jan 1, 2022

    I'd like to ask for clarification regarding bpo-45321, which adds the missing error constants to the expat module. I consider those new features – it seems inappropriate to add new module constants in the middle of a release series. However, in this ticket here, the libexpat version was updated all the way back to Py3.6, to solve a security issue.

    Should we also backport the error constants then?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes extension-modules C modules in the Modules dir type-security A security issue
    Projects
    None yet
    Development

    No branches or pull requests

    7 participants