René's URL Explorer Experiment


Title: Heap out-of-bound read in `socket.sendmsg` ancillary parser after re-entrant `__index__` clears the control list · Issue #143637 · python/cpython · GitHub

Open Graph Title: Heap out-of-bound read in `socket.sendmsg` ancillary parser after re-entrant `__index__` clears the control list · Issue #143637 · python/cpython

X Title: Heap out-of-bound read in `socket.sendmsg` ancillary parser after re-entrant `__index__` clears the control list · Issue #143637 · python/cpython

Description: What happened? _socket_socket_sendmsg_impl fast-paths ancillary data with PySequence_Fast, assuming the original list stays stable. Parsing each (level, type, data) tuple calls PyLong_AsLongAndOverflow, which runs __index__; a malicious ...

Open Graph Description: What happened? _socket_socket_sendmsg_impl fast-paths ancillary data with PySequence_Fast, assuming the original list stays stable. Parsing each (level, type, data) tuple calls PyLong_AsLongAndOver...

X Description: What happened? _socket_socket_sendmsg_impl fast-paths ancillary data with PySequence_Fast, assuming the original list stays stable. Parsing each (level, type, data) tuple calls PyLong_AsLongAndOver...

Opengraph URL: https://github.com/python/cpython/issues/143637

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Heap out-of-bound read in `socket.sendmsg` ancillary parser after re-entrant `__index__` clears the control list","articleBody":"### What happened?\n\n`_socket_socket_sendmsg_impl` fast-paths ancillary data with `PySequence_Fast`, assuming the original list stays stable. Parsing each `(level, type, data)` tuple calls `PyLong_AsLongAndOverflow`, which runs `__index__`; a malicious `__index__` can clear the shared list mid-loop, leaving `ncmsgs` and cached element pointers stale. The next `PySequence_Fast_GET_ITEM` then indexes past the shortened list and dereferences freed slots, crashing with a heap OOB read at Modules/socketmodule.c:5005.\n\n**Proof of Concept:**\n\n```python\nimport socket\n\nseq = []\n\nclass Mut:\n    def __init__(self):\n        self.tripped = False\n    def __index__(self):\n        if not self.tripped:\n            self.tripped = True\n            seq.clear()\n        return 0\n\nseq[:] = [\n    (socket.SOL_SOCKET, Mut(), b'x'),\n    (socket.SOL_SOCKET, 0, b'x'),\n]\nleft, right = socket.socketpair()\nleft.sendmsg([b'x'], seq)\n```\n\n**Vulnerable Code Snippet:**\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand\u003c/summary\u003e\n\n```c\n/* Buggy Re-entrant Path */\nlong\nPyLong_AsLongAndOverflow(PyObject *vv, int *overflow)\n{\n    /* ... */\n    if (PyLong_Check(vv)) {\n        v = (PyLongObject *)vv;\n    }\n    else {\n        v = (PyLongObject *)_PyNumber_Index(vv);  /* Reentrant call site */\n        if (v == NULL)\n            return -1;\n        do_decref = 1;\n    }\n    /* ... */\n}\n\nif ((cmsg_fast = PySequence_Fast(cmsg_arg,\n                                 \"sendmsg() argument 2 must be an \"\n                                 \"iterable\")) == NULL)\n    goto finally;\nncmsgs = PySequence_Fast_GET_SIZE(cmsg_fast);\n/* ... */\nwhile (ncmsgbufs \u003c ncmsgs) {\n    if (!PyArg_Parse(PySequence_Fast_GET_ITEM(cmsg_fast, ncmsgbufs),  /* crashing pointer derived */\n                     \"(iiy*):[sendmsg() ancillary data items]\",\n                     \u0026cmsgs[ncmsgbufs].level,\n                     \u0026cmsgs[ncmsgbufs].type,\n                     \u0026cmsgs[ncmsgbufs].data))  /* Crash site */\n        goto finally;\n    /* ... */\n}\n\n/* Clobbering Path */\nstatic void\nlist_clear_impl(PyListObject *a, bool is_resize)\n{\n    PyObject **items = a-\u003eob_item;\n    /* ... */\n\n    Py_ssize_t i = Py_SIZE(a);\n    Py_SET_SIZE(a, 0);\n    FT_ATOMIC_STORE_PTR_RELEASE(a-\u003eob_item, NULL);\n    a-\u003eallocated = 0;\n    while (--i \u003e= 0) {\n        Py_XDECREF(items[i]);  /* state mutate site */\n    }\n    free_list_items(items, use_qsbr);\n}\n```\n\u003c/details\u003e\n\n**Sanitizer Output:**\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand\u003c/summary\u003e\n\n```\nAddressSanitizer:DEADLYSIGNAL\n=================================================================\n==423360==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x73089bf5b108 bp 0x7ffe70547070 sp 0x7ffe70546db0 T0)\n==423360==The signal is caused by a READ memory access.\n==423360==Hint: address points to the zero page.\n    #0 0x73089bf5b108 in _socket_socket_sendmsg_impl Modules/socketmodule.c:5005\n    #1 0x73089bf5b108 in _socket_socket_sendmsg Modules/clinic/socketmodule.c.h:188\n    #2 0x605448f333e7 in _PyObject_VectorcallTstate Include/internal/pycore_call.h:169\n    #3 0x605448f333e7 in PyObject_Vectorcall Objects/call.c:327\n    #4 0x605448de75a2 in _PyEval_EvalFrameDefault Python/generated_cases.c.h:1620\n    #5 0x6054492b1ad6 in _PyEval_EvalFrame Include/internal/pycore_ceval.h:121\n    #6 0x6054492b1ad6 in _PyEval_Vector Python/ceval.c:2001\n    #7 0x6054492b1ad6 in PyEval_EvalCode Python/ceval.c:884\n    #8 0x6054493f716e in run_eval_code_obj Python/pythonrun.c:1365\n    #9 0x6054493f716e in run_mod Python/pythonrun.c:1459\n    #10 0x6054493fbe17 in pyrun_file Python/pythonrun.c:1293\n    #11 0x6054493fbe17 in _PyRun_SimpleFileObject Python/pythonrun.c:521\n    #12 0x6054493fc93c in _PyRun_AnyFileObject Python/pythonrun.c:81\n    #13 0x60544946fe3c in pymain_run_file_obj Modules/main.c:410\n    #14 0x60544946fe3c in pymain_run_file Modules/main.c:429\n    #15 0x60544946fe3c in pymain_run_python Modules/main.c:691\n    #16 0x60544947171e in Py_RunMain Modules/main.c:772\n    #17 0x60544947171e in pymain_main Modules/main.c:802\n    #18 0x60544947171e in Py_BytesMain Modules/main.c:826\n    #19 0x73089c42a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58\n    #20 0x73089c42a28a in __libc_start_main_impl ../csu/libc-start.c:360\n    #21 0x605448e0b634 in _start (/home/jackfromeast/Desktop/entropy/targets/grammar-afl++-latest/targets/cpython/python+0x206634) (BuildId: 4d105290d0ad566a4d6f4f7b2f05fbc9e317b533)\n\nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV Modules/socketmodule.c:5005 in _socket_socket_sendmsg_impl\n==423360==ABORTING\n```\n\u003c/details\u003e\n\n### CPython versions tested on:\n\n\u003cdetails\u003e\n\n| Python Version | Status | Exit Code |\n|---|---|---|\n| `Python 3.9.24+ (heads/3.9:111bbc15b26, Oct 28 2025, 16:51:20) ` | ASAN | 1 |\n| `Python 3.10.19+ (heads/3.10:014261980b1, Oct 28 2025, 16:52:08) [Clang 18.1.3 (1ubuntu1)]` | ASAN | 1 |\n| `Python 3.11.14+ (heads/3.11:88f3f5b5f11, Oct 28 2025, 16:53:08) [Clang 18.1.3 (1ubuntu1)]` | ASAN | 1 |\n| `Python 3.12.12+ (heads/3.12:8cb2092bd8c, Oct 28 2025, 16:54:14) [Clang 18.1.3 (1ubuntu1)]` | ASAN | 1 |\n| `Python 3.13.9+ (heads/3.13:9c8eade20c6, Oct 28 2025, 16:55:18) [Clang 18.1.3 (1ubuntu1)]` | ASAN | 1 |\n| `Python 3.14.0+ (heads/3.14:2e216728038, Oct 28 2025, 16:56:16) [Clang 18.1.3 (1ubuntu1)]` | ASAN | 1 |\n| `Python 3.15.0a1+ (heads/main:f5394c257ce, Oct 28 2025, 19:29:54) [GCC 13.3.0]` | ASAN | 1 |\n\n\u003c/details\u003e\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.15.0a1+ (heads/main:f5394c257ce, Oct 28 2025, 19:29:54) [GCC 13.3.0]\n\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-143892\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/jackfromeast","@type":"Person","name":"jackfromeast"},"datePublished":"2026-01-10T05:09:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/143637/cpython/issues/143637"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8949fbbd-aab0-bce5-568f-9d663c89ce6e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id93E8:1E0146:181D01D:2058981:6969AC9D
html-safe-nonce1f71a1e6b235aaa30c4ac58b9ff68f77082dad596b9c83e384e8ba56862a12f5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0U4OjFFMDE0NjoxODFEMDFEOjIwNTg5ODE6Njk2OUFDOUQiLCJ2aXNpdG9yX2lkIjoiNzE2NjIyMTUwNDI5NzQxMzc4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacce7dd97f00476cdbae30b2bee6ed1d49ed95b3055032bb94bb017797dbd5268f
hovercard-subject-tagissue:3799131372
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/143637/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9ff0060fbc0b456c0287c8c3c40ca3b81d9fd4898b85fabc1696212625061699/python/cpython/issues/143637
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9ff0060fbc0b456c0287c8c3c40ca3b81d9fd4898b85fabc1696212625061699/python/cpython/issues/143637
og:image:altWhat happened? _socket_socket_sendmsg_impl fast-paths ancillary data with PySequence_Fast, assuming the original list stays stable. Parsing each (level, type, data) tuple calls PyLong_AsLongAndOver...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejackfromeast
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/143637#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F143637
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F143637
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/143637
Reloadhttps://github.com/python/cpython/issues/143637
Reloadhttps://github.com/python/cpython/issues/143637
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/143637
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/143637
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/143637
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/143637
Heap out-of-bound read in socket.sendmsg ancillary parser after re-entrant __index__ clears the control listhttps://github.com/python/cpython/issues/143637#top
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%22
https://github.com/jackfromeast
https://github.com/jackfromeast
jackfromeasthttps://github.com/jackfromeast
on Jan 10, 2026https://github.com/python/cpython/issues/143637#issue-3799131372
gh-143637: Fix re-entrant mutation of ancillary data in socket.sendmsg() #143892https://github.com/python/cpython/pull/143892
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.