Skip to content

gh-136053: Memory Safety Issue in marshal.c TYPE_SLICE Case #136054

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

Conversation

akshat62
Copy link
Contributor

@akshat62 akshat62 commented Jun 27, 2025

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

cc @serhiy-storchaka

Would it be possible to add a test with a maliciously crafted data so that we ensure that the vulnerability can be exploited?

@picnixz
Copy link
Member

picnixz commented Jun 28, 2025

Thanks for the fix but please add a regression test. Even if it's not easily reproducible, I'd like to see a PoC.

@serhiy-storchaka serhiy-storchaka self-requested a review June 28, 2025 09:26
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

The test does not work.

For testing, you need to create at least 2147483646 (0x7ffffffe) references. This is impossible on 32-bit platform, and on 64-bit platforms it will consume at least 16 GiB (and maybe 32 GiB or 64 GiB due to overallocation) only for the list, not counting the referred objects. This is a bigmem test. This will also take a significant amount of time to run. I do not think it is worth to add an expensive test for trivial fix.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@akshat62 akshat62 requested a review from picnixz June 28, 2025 14:14
@akshat62
Copy link
Contributor Author

@picnixz This can be merged.

@serhiy-storchaka serhiy-storchaka merged commit 30ba03e into python:main Jun 29, 2025
40 checks passed
@serhiy-storchaka serhiy-storchaka added 3.14 bugs and security fixes needs backport to 3.14 bugs and security fixes and removed 3.14 bugs and security fixes labels Jun 29, 2025
@miss-islington-app
Copy link

Thanks @akshat62 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 29, 2025
…6054)

Fix a possible crash when deserializing a large marshal data
(at least several GiBs) containing a slice.
(cherry picked from commit 30ba03e)

Co-authored-by: Akshat Gupta <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 29, 2025

GH-136092 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jun 29, 2025
serhiy-storchaka pushed a commit that referenced this pull request Jun 29, 2025
…GH-136092)

Fix a possible crash when deserializing a large marshal data
(at least several GiBs) containing a slice.
(cherry picked from commit 30ba03e)

Co-authored-by: Akshat Gupta <[email protected]>
@picnixz
Copy link
Member

picnixz commented Jun 29, 2025

No 3.13 bp?

@serhiy-storchaka
Copy link
Member

New in 3.14.

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.

5 participants