René's URL Explorer Experiment


Title: Use-after-free in `CleanupHookThunkRun` for every `node::ObjectWrap` alive at teardown · Issue #65195 · nodejs/node · GitHub

Open Graph Title: Use-after-free in `CleanupHookThunkRun` for every `node::ObjectWrap` alive at teardown · Issue #65195 · nodejs/node

X Title: Use-after-free in `CleanupHookThunkRun` for every `node::ObjectWrap` alive at teardown · Issue #65195 · nodejs/node

Description: Version v26.7.0 Platform Linux 6.8.0-100-generic aarch64 Subsystem No response What steps will reproduce the bug? Bug can be reproduced with test/addons/worker-addon-exit from node source (it creates one instance that is still live when ...

Open Graph Description: Version v26.7.0 Platform Linux 6.8.0-100-generic aarch64 Subsystem No response What steps will reproduce the bug? Bug can be reproduced with test/addons/worker-addon-exit from node source (it creat...

X Description: Version v26.7.0 Platform Linux 6.8.0-100-generic aarch64 Subsystem No response What steps will reproduce the bug? Bug can be reproduced with test/addons/worker-addon-exit from node source (it creat...

Opengraph URL: https://github.com/nodejs/node/issues/65195

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use-after-free in `CleanupHookThunkRun` for every `node::ObjectWrap` alive at teardown","articleBody":"### Version\n\nv26.7.0\n\n### Platform\n\n```text\nLinux 6.8.0-100-generic aarch64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nBug can be reproduced with `test/addons/worker-addon-exit` from node source (it creates one instance that is still live when the worker\nEnvironment tears down):\n```console\n$ cd test/addons/worker-addon-exit && npx node-gyp configure build\n$ valgrind --undef-value-errors=no node test.js\n...\n==359== Thread 8 WorkerThread:\n==359== Invalid read of size 8\n==359==    at 0x89C990: node::CleanupHookThunkRun(void*) (in /usr/local/bin/node)\n==359==    by 0x8C6DF7: node::CleanupQueue::Drain() (in /usr/local/bin/node)\n==359==    by 0x91F31B: node::Environment::RunCleanup() (in /usr/local/bin/node)\n==359==    by 0x8986B3: node::FreeEnvironment(node::Environment*) (in /usr/local/bin/node)\n==359==    by 0xAF4AE7: node::worker::Worker::Run() (in /usr/local/bin/node)\n==359==    by 0xAF99CF: node::worker::Worker::StartThread(v8::FunctionCallbackInfo\u003cv8::Value> const&)::$_0::__invoke(void*) (in /usr/local/bin/node)\n==359==    by 0x7CB202F: start_thread (pthread_create.c:442)\n==359==    by 0x7D1BF5B: thread_start (clone.S:79)\n==359==  Address 0x338aba88 is 8 bytes inside a block of size 48 free'd\n==359==    at 0x7858360: operator delete(void*, unsigned long) (vg_replace_malloc.c:935)\n==359==    by 0x89CB47: node::RemoveEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*) (in /usr/local/bin/node)\n==359==    by 0x54C91FB3: MyObject::~MyObject() (in /app/test/addons/worker-addon-exit/build/Release/binding.node)\n==359==    by 0x54C91FF3: MyObject::~MyObject() (in /app/test/addons/worker-addon-exit/build/Release/binding.node)\n==359==    by 0x89C98F: node::CleanupHookThunkRun(void*) (in /usr/local/bin/node)\n==359==    by 0x8C6DF7: node::CleanupQueue::Drain() (in /usr/local/bin/node)\n==359==    by 0x91F31B: node::Environment::RunCleanup() (in /usr/local/bin/node)\n==359==    by 0x8986B3: node::FreeEnvironment(node::Environment*) (in /usr/local/bin/node)\n==359==    by 0xAF4AE7: node::worker::Worker::Run() (in /usr/local/bin/node)\n==359==    by 0xAF99CF: node::worker::Worker::StartThread(v8::FunctionCallbackInfo\u003cv8::Value> const&)::$_0::__invoke(void*) (in /usr/local/bin/node)\n==359==    by 0x7CB202F: start_thread (pthread_create.c:442)\n==359==    by 0x7D1BF5B: thread_start (clone.S:79)\n==359==  Block was alloc'd at\n==359==    at 0x7855828: operator new(unsigned long) (vg_replace_malloc.c:422)\n==359==    by 0x89DB73: std::pair\u003cstd::__detail::_Node_iterator\u003cnode::CleanupHookThunk, true, true>, bool> std::_Hashtable\u003cnode::CleanupHookThunk, node::CleanupHookThunk, std::allocator\u003cnode::CleanupHookThunk>, std::__detail::_Identity, std::equal_to\u003cnode::CleanupHookThunk>, node::CleanupHookThunkHash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits\u003ctrue, true, true> >::_M_insert_unique\u003cnode::CleanupHookThunk, node::CleanupHookThunk, std::__detail::_AllocNode\u003cstd::allocator\u003cstd::__detail::_Hash_node\u003cnode::CleanupHookThunk, true> > > >(node::CleanupHookThunk&&, node::CleanupHookThunk&&, std::__detail::_AllocNode\u003cstd::allocator\u003cstd::__detail::_Hash_node\u003cnode::CleanupHookThunk, true> > > const&) (in /usr/local/bin/node)\n==359==    by 0x89C8DB: node::AddEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*) (in /usr/local/bin/node)\n==359==    by 0x54C92053: MyObject::MyObject(double) (in /app/test/addons/worker-addon-exit/build/Release/binding.node)\n==359==    by 0x54C921BF: MyObject::New(v8::FunctionCallbackInfo\u003cv8::Value> const&) (in /app/test/addons/worker-addon-exit/build/Release/binding.node)\n==359==    by 0xCAAE2F: v8::internal::FunctionCallbackArguments::CallOrConstruct(v8::internal::Isolate*, v8::internal::Tagged\u003cv8::internal::FunctionTemplateInfo>, bool) (in /usr/local/bin/node)\n==359==    by 0xCAA4E3: v8::internal::Builtin_HandleApiConstruct(int, unsigned long*, v8::internal::Isolate*) (in /usr/local/bin/node)\n==359==    by 0x1A32BCB: Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit (in /usr/local/bin/node)\n```\n\n### How often does it reproduce? Is there a required condition?\n\n100%, deterministic\n\n### What is the expected behavior? Why is that the expected behavior?\n\nDeleting an `ObjectWrap` from the environment cleanup drain should not read freed memory. Since #63642, `~ObjectWrap` calls `RemoveEnvironmentCleanupHook`, so this is now the ordinary teardown path for every `ObjectWrap`-based addon, not an edge case.\n\n### What do you see instead?\n\n```\n==359== Thread 8 WorkerThread:\n==359== Invalid read of size 8\n==359==    at 0x89C990: node::CleanupHookThunkRun(void*) (in /usr/local/bin/node)\n==359==    by 0x8C6DF7: node::CleanupQueue::Drain() (in /usr/local/bin/node)\n```\n\nThe process still exits 0, so this is silent unless you run under valgrind.\n\n### Additional information\n\n#### Cause\n\n`src/api/hooks.cc`:\n\n```cpp\nstatic void CleanupHookThunkRun(void* arg) {\n  const CleanupHookThunk* thunk = static_cast\u003cCleanupHookThunk*>(arg);\n  thunk->fun(thunk->arg);                                               // (1)\n  RemoveEnvironmentCleanupHook(thunk->isolate, thunk->fun, thunk->arg); // (2)\n}\n```\n\n(1) is `ObjectWrap::CleanupHook`, i.e. `delete wrap`. `~ObjectWrap` calls `RemoveEnvironmentCleanupHook` itself, which does `registry->erase(result)` and destroys the `CleanupHookThunk` node that `thunk` points into. (2) then reads `thunk->isolate` / `thunk->fun` / `thunk->arg` out of that freed node. The second removal is also redundant.\n\nIntroduced by #63985, which added the registry, in combination with #63642, which made `~ObjectWrap` remove its own hook. \n\n#### Suggested fix\n\nCache the fields before the callback can invalidate the node:\n\n```cpp\nstatic void CleanupHookThunkRun(void* arg) {\n  const CleanupHookThunk* thunk = static_cast\u003cCleanupHookThunk*>(arg);\n  Isolate* isolate = thunk->isolate;\n  CleanupHook fun = thunk->fun;\n  void* fun_arg = thunk->arg;\n  fun(fun_arg);\n  RemoveEnvironmentCleanupHook(isolate, fun, fun_arg);\n}\n```\n","author":{"url":"https://github.com/nsavoire","@type":"Person","name":"nsavoire"},"datePublished":"2026-08-10T14:48:42Z","url":"https://github.com/nodejs/node/issues/65195"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c289dd7a-08a6-8a7b-ce14-51c7ac59d47f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA900:3C34F7:401D31:53BD12:6AED2183
html-safe-nonce68325eb79e82d2a3326a90c1157e0b76e858c71487ba4e01c75e14d70d6bdbd9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTAwOjNDMzRGNzo0MDFEMzE6NTNCRDEyOjZBRUQyMTgzIiwidmlzaXRvcl9pZCI6IjY2MzI4OTM2NzQwNTQwMzM3OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac14bf87517afaf152b68a684aa58af28bf377c592bf7a280dabf31e16bfa7a619
hovercard-subject-tagissue:5111340253
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/nodejs/node/65195/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3c10369434368516e8f7c5cbd6678881ed2af2a589e350959cd334620fbf5da7/nodejs/node/issues/65195
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3c10369434368516e8f7c5cbd6678881ed2af2a589e350959cd334620fbf5da7/nodejs/node/issues/65195
og:image:altVersion v26.7.0 Platform Linux 6.8.0-100-generic aarch64 Subsystem No response What steps will reproduce the bug? Bug can be reproduced with test/addons/worker-addon-exit from node source (it creat...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamensavoire
hostnamegithub.com
expected-hostnamegithub.com
Nonee3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
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
release707a24b346ac8a82878b9c084efaa38a997660cb
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/65195#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F65195
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F65195
Sign uphttps://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=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/65195
Reloadhttps://github.com/nodejs/node/issues/65195
Reloadhttps://github.com/nodejs/node/issues/65195
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65195
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65195
#65630https://github.com/nodejs/node/pull/65630
Use-after-free in CleanupHookThunkRun for every node::ObjectWrap alive at teardownhttps://github.com/nodejs/node/issues/65195#top
#65630https://github.com/nodejs/node/pull/65630
https://github.com/nsavoire
nsavoirehttps://github.com/nsavoire
on Aug 10, 2026https://github.com/nodejs/node/issues/65195#issue-5111340253
#63642https://github.com/nodejs/node/pull/63642
#63985https://github.com/nodejs/node/pull/63985
#63642https://github.com/nodejs/node/pull/63642
kriscendobothttps://github.com/kriscendobot
on Aug 17, 2026https://github.com/nodejs/node/issues/65195#event-29542406799
ci: pin Node 24.x matrix to 24.18.0 (worker-teardown crash)https://github.com/endojs/endo-but-for-bots/commit/a5882399ca9d76a187f81a01e302680b021ffa9a
a588239https://github.com/endojs/endo-but-for-bots/commit/a5882399ca9d76a187f81a01e302680b021ffa9a
ci: pin Node 24.x matrix to 24.18.0 (worker-teardown crash)https://github.com/endojs/endo-but-for-bots/commit/692f4803142f41c6af1718f9e04e83674d2cfc79
692f480https://github.com/endojs/endo-but-for-bots/commit/692f4803142f41c6af1718f9e04e83674d2cfc79
everett1992https://github.com/everett1992
on Aug 28, 2026https://github.com/nodejs/node/issues/65195#event-30186875160
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/everett1992/node/commit/f84e6fdd5ca24d8b203146751d2bd806e925c0c0
f84e6fdhttps://github.com/everett1992/node/commit/f84e6fdd5ca24d8b203146751d2bd806e925c0c0
test: add regression test for cleanup hook UAFhttps://github.com/everett1992/node/commit/eb993ffcda879e9a7793c15225ff25921a656670
eb993ffhttps://github.com/everett1992/node/commit/eb993ffcda879e9a7793c15225ff25921a656670
test: add regression test for cleanup hook UAFhttps://github.com/everett1992/node/commit/1ebc614681cc802ac2aaaff446039e4b1fdbe1ca
1ebc614https://github.com/everett1992/node/commit/1ebc614681cc802ac2aaaff446039e4b1fdbe1ca
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/everett1992/node/commit/6dd9a727d06f34c3873ee30b0b507d4d4d4eb541
6dd9a72https://github.com/everett1992/node/commit/6dd9a727d06f34c3873ee30b0b507d4d4d4eb541
test: add regression test for cleanup hook UAFhttps://github.com/everett1992/node/commit/bb42c6da9e6904c3f246d435e32ca4ec90114969
bb42c6dhttps://github.com/everett1992/node/commit/bb42c6da9e6904c3f246d435e32ca4ec90114969
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/everett1992/node/commit/dd2fa31b1d99e5a6710e08ce4139da7c2e344598
dd2fa31https://github.com/everett1992/node/commit/dd2fa31b1d99e5a6710e08ce4139da7c2e344598
test: add regression test for cleanup hook UAFhttps://github.com/everett1992/node/commit/fd325a7fc2b33839c024220aa0c44b9104749686
fd325a7https://github.com/everett1992/node/commit/fd325a7fc2b33839c024220aa0c44b9104749686
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#65630https://github.com/nodejs/node/pull/65630
on Sep 4, 2026https://github.com/nodejs/node/issues/65195#event-30569355750
nodejs-github-bothttps://github.com/nodejs-github-bot
on Sep 4, 2026https://github.com/nodejs/node/issues/65195#event-30569356996
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/nodejs/node/commit/03e2b9bc42ae9c7ed4fbab5509d70fa934863c44
03e2b9bhttps://github.com/nodejs/node/commit/03e2b9bc42ae9c7ed4fbab5509d70fa934863c44
aduh95https://github.com/aduh95
on Sep 7, 2026https://github.com/nodejs/node/issues/65195#event-30701504551
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/nodejs/node/commit/8cfe7ae316bad7fa6a34760c97f190c5c5d736fe
8cfe7aehttps://github.com/nodejs/node/commit/8cfe7ae316bad7fa6a34760c97f190c5c5d736fe
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/nodejs/node/commit/4eb613360ae1b7534c3149c9763c608a851cf00c
4eb6133https://github.com/nodejs/node/commit/4eb613360ae1b7534c3149c9763c608a851cf00c
everett1992https://github.com/everett1992
on Sep 10, 2026https://github.com/nodejs/node/issues/65195#event-30924559568
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/everett1992/node/commit/fa73926c5f6185eeb1293226f4597f49ee15b42c
fa73926https://github.com/everett1992/node/commit/fa73926c5f6185eeb1293226f4597f49ee15b42c
aduh95https://github.com/aduh95
on Sep 15, 2026https://github.com/nodejs/node/issues/65195#event-31161527726
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/nodejs/node/commit/f66ed89136800e575f624946816cdcf3e28e3aa2
f66ed89https://github.com/nodejs/node/commit/f66ed89136800e575f624946816cdcf3e28e3aa2
panvahttps://github.com/panva
on Sep 20, 2026https://github.com/nodejs/node/issues/65195#event-31479689976
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/panva/node/commit/df46f87997337521f0ad0597dc8c0217b0a576b0
df46f87https://github.com/panva/node/commit/df46f87997337521f0ad0597dc8c0217b0a576b0
aduh95https://github.com/aduh95
on Sep 21, 2026https://github.com/nodejs/node/issues/65195#event-31519158068
src: fix use-after-free in CleanupHookThunkRunhttps://github.com/nodejs/node/commit/5570a84048811920fc8dab615dda36bb9d5f88f9
5570a84https://github.com/nodejs/node/commit/5570a84048811920fc8dab615dda36bb9d5f88f9
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/65195
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/65195
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.