Skip to content

bpo-44394: Update libexpat copy to 2.4.1 #26945

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

Merged
merged 2 commits into from
Aug 29, 2021
Merged

bpo-44394: Update libexpat copy to 2.4.1 #26945

merged 2 commits into from
Aug 29, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 29, 2021

Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

https://bugs.python.org/issue44394

Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.
@vstinner
Copy link
Member Author

cc @tiran: please have a look at the XML vulnerability documentation change. I'm not sure that pyexpat is used by all Python XML parsers.

@vstinner
Copy link
Member Author

I used cpython_rebuild_expat_dir.sh script attached to https://bugs.python.org/issue44394 to created this PR, then I manually reverted the following change:

diff --git a/Modules/expat/expat_external.h b/Modules/expat/expat_external.h
index f2b75dda8e..8829f77091 100644
--- a/Modules/expat/expat_external.h
+++ b/Modules/expat/expat_external.h
-
-/* Namespace external symbols to allow multiple libexpat version to
-   co-exist. */
-#include "pyexpatns.h"
-

I tested this PR with the command: ./configure --cache-file=../python-config.cache --with-pydebug CFLAGS=-O0 --with-system-ffi && make clean && make && ./python -m test -v test_pyexpat.

test_pyexpat pass successfully.

Manual test to ensure that the Python pyexpat module is not linked to the system libexpat:

$ ldd $(./python -c 'import pyexpat; print(pyexpat.__file__)')
	linux-vdso.so.1 (0x00007ffd90b6b000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa78c10c000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fa78bf3d000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa78c193000)

libexpat is not listed in the library dependencies, so it's ok.

@@ -63,19 +63,21 @@ the various modules are vulnerable to them.
========================= ============== =============== ============== ============== ==============
kind sax etree minidom pulldom xmlrpc
========================= ============== =============== ============== ============== ==============
billion laughs **Vulnerable** **Vulnerable** **Vulnerable** **Vulnerable** **Vulnerable**
billion laughs Safe (1) Safe (1) Safe (1) Safe (1) Safe (1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against marking it safe until Python no longer supports libexpat <= 2.4.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. Any ideas how to best communicate it in this table?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vulnerable or Safe depends on the libexpat version, that's what I wrote in the footnote (1). I explain how how to check manually if your Python is vulnerable or not.

@tiran How do you want to explain that it depends on the libexpat version in this table, if you are unhappy with "Safe (1)"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do **Vulnerable** (1) until all relevant Linux distros have fixed libexpat: all supported CentOS streams, Debian stables, RHELs, Ubuntu LTS, etc.

@hartwork
Copy link
Contributor

@vstinner the two new API functions and the new error codes do not seem included, yet. Did you see https://bugs.python.org/msg395642 ?

@hartwork
Copy link
Contributor

Manual test to ensure that the Python pyexpat module is not linked to the system libexpat:

$ ldd $(./python -c 'import pyexpat; print(pyexpat.__file__)')
	linux-vdso.so.1 (0x00007ffd90b6b000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa78c10c000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fa78bf3d000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa78c193000)

libexpat is not listed in the library dependencies, so it's ok.

@vstinner I'm not entirely sure what the idea is with that test but libexpat is listed for me on Linux:

# ldd $(python -c 'import pyexpat; print(pyexpat.__file__)')
        linux-vdso.so.1 (0x00007ffca4502000)
        libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007ffa92b10000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ffa92af1000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ffa92938000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ffa92b73000)

@vstinner
Copy link
Member Author

@vstinner the two new API functions and the new error codes do not seem included, yet. Did you see https://bugs.python.org/msg395642 ?

That's a new feature, it cannot be backported to older Python versions. I'm not interested to write a PR to implement it.

This PR is restricted to updated libexpat so it can be backported to all Python versions which still accept security fixes.

@hartwork
Copy link
Contributor

@vstinner the two new API functions and the new error codes do not seem included, yet. Did you see https://bugs.python.org/msg395642 ?

That's a new feature, it cannot be backported to older Python versions. I'm not interested to write a PR to implement it.

This PR is restricted to updated libexpat so it can be backported to all Python versions which still accept security fixes.

The new API and error codes are part of the security fix.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jul 30, 2021
@ambv ambv removed the stale Stale PR or inactive for long period of time. label Aug 29, 2021
@ambv ambv merged commit 3fc5d84 into python:main Aug 29, 2021
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7, 3.8, 3.9, 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 29, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Łukasz Langa <[email protected]>
(cherry picked from commit 3fc5d84)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Aug 29, 2021
@bedevere-bot
Copy link

GH-28031 is a backport of this pull request to the 3.10 branch.

@bedevere-bot
Copy link

GH-28032 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Aug 29, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 29, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Łukasz Langa <[email protected]>
(cherry picked from commit 3fc5d84)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

GH-28033 is a backport of this pull request to the 3.8 branch.

@miss-islington
Copy link
Contributor

Sorry, @vstinner and @ambv, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 3fc5d84046ddbd66abac5b598956ea34605a4e5d 3.7

@miss-islington
Copy link
Contributor

Sorry @vstinner and @ambv, I had trouble checking out the 3.6 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 3fc5d84046ddbd66abac5b598956ea34605a4e5d 3.6

@ambv
Copy link
Contributor

ambv commented Aug 29, 2021

@ned-deily, this is marked as needing backport to 3.6 and 3.7 as well. Since there's conflicts, please let me know if I should work on that.

ambv pushed a commit that referenced this pull request Aug 29, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Łukasz Langa <[email protected]>
(cherry picked from commit 3fc5d84)

Co-authored-by: Victor Stinner <[email protected]>
miss-islington added a commit that referenced this pull request Aug 29, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Łukasz Langa <[email protected]>
(cherry picked from commit 3fc5d84)

Co-authored-by: Victor Stinner <[email protected]>
ambv pushed a commit that referenced this pull request Aug 29, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Łukasz Langa <[email protected]>
(cherry picked from commit 3fc5d84)

Co-authored-by: Victor Stinner <[email protected]>
ambv pushed a commit to ambv/cpython that referenced this pull request Aug 29, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Łukasz Langa <[email protected]>.
(cherry picked from commit 3fc5d84)

Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot
Copy link

GH-28042 is a backport of this pull request to the 3.7 branch.

@vstinner
Copy link
Member Author

Thanks for the update @ambv! I failed to find time to update this PR this summer ;-)

ned-deily pushed a commit that referenced this pull request Aug 31, 2021
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Victor Stinner <[email protected]>

Co-authored-by: Łukasz Langa <[email protected]>.
(cherry picked from commit 3fc5d84)
ned-deily pushed a commit to ned-deily/cpython that referenced this pull request Aug 31, 2021
…onGH-28042)

Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Victor Stinner <[email protected]>

Co-authored-by: Łukasz Langa <[email protected]>.
(cherry picked from commit 3fc5d84)
ned-deily added a commit that referenced this pull request Aug 31, 2021
…H-28080)

Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the
fix for the CVE-2013-0340 "Billion Laughs" vulnerability. This copy
is most used on Windows and macOS.

Co-authored-by: Victor Stinner <[email protected]>

Co-authored-by: Łukasz Langa <[email protected]>.
(cherry picked from commit 3fc5d84)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants