René's URL Explorer Experiment


Title: fs: heap buffer overflow in readFileSync(fd, "utf8") when a pipe returns short reads · Issue #66341 · nodejs/node · GitHub

Open Graph Title: fs: heap buffer overflow in readFileSync(fd, "utf8") when a pipe returns short reads · Issue #66341 · nodejs/node

X Title: fs: heap buffer overflow in readFileSync(fd, "utf8") when a pipe returns short reads · Issue #66341 · nodejs/node

Description: Version v26.10.0 (also present in v26.8.0 through v26.10.0 and v24.21.0; not present in v26.7.0 or v22.23.3) Platform Linux archpc 7.2.4-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 08 Sep 2026 10:22:31 +0000 x86_64 GNU/Linux Arch Linux, nodejs 2...

Open Graph Description: Version v26.10.0 (also present in v26.8.0 through v26.10.0 and v24.21.0; not present in v26.7.0 or v22.23.3) Platform Linux archpc 7.2.4-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 08 Sep 2026 10:22:31 +00...

X Description: Version v26.10.0 (also present in v26.8.0 through v26.10.0 and v24.21.0; not present in v26.7.0 or v22.23.3) Platform Linux archpc 7.2.4-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 08 Sep 2026 10:22:31 +00...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs: heap buffer overflow in readFileSync(fd, \"utf8\") when a pipe returns short reads","articleBody":"### Version\n\nv26.10.0 (also present in v26.8.0 through v26.10.0 and v24.21.0; not present in v26.7.0 or v22.23.3)\n\n### Platform\n\n```text\nLinux archpc 7.2.4-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 08 Sep 2026 10:22:31 +0000 x86_64 GNU/Linux\nArch Linux, nodejs 26.10.0-1, glibc 2.44\n```\n\n### Subsystem\n\nfs\n\n### What steps will reproduce the bug?\n\n```bash\n#!/usr/bin/env bash\n# Producer: 24 short writes (~96 KiB, each read back as a short read), then one large write.\nnode -e '\nconst chunk = \"x\".repeat(4000);\nlet i = 0;\nconst t = setInterval(() => {\n  process.stdout.write(chunk);\n  if (++i === 24) { clearInterval(t); process.stdout.write(\"y\".repeat(400000)); }\n}, 5);\n' | node -e 'console.log(require(\"fs\").readFileSync(0, \"utf8\").length)'\necho \"exit=${PIPESTATUS[1]}\"\n```\n\n### How often does it reproduce? Is there a required condition?\n\n10 of 10 runs with the script above. The input must be a pipe (or FIFO, or `/dev/stdin` backed by one) that delivers more than 64 KiB in reads shorter than 8 KiB before the first full 8 KiB read. Regular files are not affected. The encoding does not matter: the input above is pure ASCII.\n\nReal-world trigger: `some-test-runner | node -e 'require(\"fs\").readFileSync(0, \"utf8\")...'`, where the producer writes in small chunks. It crashed at 7 of 60 runs with a ~420 KB input written in 4093-byte chunks.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nPrints `496000` and exits 0, as v26.7.0 does and as `readFileSync(0).toString(\"utf8\")` does on v26.10.0.\n\n### What do you see instead?\n\n```text\nmalloc(): invalid size (unsorted)\nexit=134\n```\n\nSIGABRT from glibc. Symbolized stack (from a real crash, via debuginfod.archlinux.org):\n\n```text\n#6  malloc_printerr (str=\"malloc(): invalid size (unsorted)\") at malloc.c:5093\n#7  _int_malloc (av=\u003cmain_arena>, bytes=427486) at malloc.c:3683\n#10 __GI___libc_realloc (oldmem=0x0, bytes=427486) at malloc.c:3198\n#11 node::UncheckedRealloc\u003cchar16_t> (pointer=0x0, n=\u003coptimized out>) at ../../src/util-inl.h:267\n#13 node::MaybeStackBuffer\u003cunsigned short, 256ul>::AllocateSufficientStorage (storage=213743) at ../../src/util-inl.h:544\n#14 node::StringBytes::Encode (...) at ../../src/string_bytes.cc:659\n#15 node::fs::ReadFileUtf8 (args=...) at ../../src/node_file.cc:3559\n```\n\nThe abort happens later than the corruption. The corruption itself is a heap buffer overflow in `ReadFileUtf8`.\n\n### Additional information\n\nCause, in `ReadFileUtf8` ([src/node_file.cc#L3511-L3523 at v26.10.0](https://github.com/nodejs/node/blob/59da6b44a953cf9b45f2591ae80f569ce1ec9da5/src/node_file.cc#L3511-L3523)):\n\n- While `big == nullptr`, every short read (`r \u003c 8192`) is appended to `result` and the loop `continue`s. On a pipe, `result` can grow past 64 KiB this way.\n- On the first full 8 KiB read, the code allocates `big_cap = kMinChunk` (64 KiB) and runs `memcpy(big, result.data(), result.size())` with no check that `result.size() \u003c= big_cap`. That write overflows the heap buffer.\n- After that, `big_len > big_cap`, so `big_len == big_cap` never matches, and `big_cap - big_len` in the next `uv_buf_init` underflows.\n\nA possible fix: size the first allocation from what is already buffered, for example `big_cap = std::max(kMinChunk, result.size() + sizeof(buffer))`, and make the growth check `big_len >= big_cap`.\n\nWorkaround: `fs.readFileSync(0).toString(\"utf8\")` avoids the fast path.\n","author":{"url":"https://github.com/bartech-lab","@type":"Person","name":"bartech-lab"},"datePublished":"2026-09-27T08:15:04Z","url":"https://github.com/nodejs/node/issues/66341"}

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:018d92db-4a7d-eb0f-1900-9cfdc86004e4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD028:16D14D:4B5E71:66D5C9:6AED56E8
html-safe-noncec5124551914060d0614593e8600050db91d26d98a4bb7d1372b152a44b6ae1f2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDI4OjE2RDE0RDo0QjVFNzE6NjZENUM5OjZBRUQ1NkU4IiwidmlzaXRvcl9pZCI6IjY1ODEyOTA1ODI1OTA0NDUyODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac642ca27f324ca547c352935a948464aba0c4f23cad406f83fa9afaf639c3489f
hovercard-subject-tagissue:5601053677
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/66341/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6e702f49df8e2a6ec14f73a608244eba14d4946bd829e1121b6b2d257ad56caf/nodejs/node/issues/66341
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6e702f49df8e2a6ec14f73a608244eba14d4946bd829e1121b6b2d257ad56caf/nodejs/node/issues/66341
og:image:altVersion v26.10.0 (also present in v26.8.0 through v26.10.0 and v24.21.0; not present in v26.7.0 or v22.23.3) Platform Linux archpc 7.2.4-arch1-2 #1 SMP PREEMPT_DYNAMIC Tue, 08 Sep 2026 10:22:31 +00...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebartech-lab
hostnamegithub.com
expected-hostnamegithub.com
None56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11
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
release9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66341#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66341
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%2F66341
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/66341
Reloadhttps://github.com/nodejs/node/issues/66341
Reloadhttps://github.com/nodejs/node/issues/66341
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66341
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66341
#66939https://github.com/nodejs/node/pull/66939
fs: heap buffer overflow in readFileSync(fd, "utf8") when a pipe returns short readshttps://github.com/nodejs/node/issues/66341#top
#66939https://github.com/nodejs/node/pull/66939
https://github.com/bartech-lab
bartech-labhttps://github.com/bartech-lab
on Sep 27, 2026https://github.com/nodejs/node/issues/66341#issue-5601053677
src/node_file.cc#L3511-L3523 at v26.10.0https://github.com/nodejs/node/blob/59da6b44a953cf9b45f2591ae80f569ce1ec9da5/src/node_file.cc#L3511-L3523
DeJeunehttps://github.com/DeJeune
on Sep 30, 2026https://github.com/nodejs/node/issues/66341#event-32176716492
fix(release): avoid Node UTF-8 pipe read overflow (#21222)https://github.com/CherryHQ/cherry-studio/commit/0aa8cd09c860b9539a19f95d15a31b4142013116
#21222https://github.com/CherryHQ/cherry-studio/pull/21222
0aa8cd0https://github.com/CherryHQ/cherry-studio/commit/0aa8cd09c860b9539a19f95d15a31b4142013116
MidAutumnMoonhttps://github.com/MidAutumnMoon
on Oct 1, 2026https://github.com/nodejs/node/issues/66341#event-32223749530
fix(release): avoid Node UTF-8 pipe read overflow (CherryHQ#21222)https://github.com/MidAutumnMoon/lingo-studio/commit/f66d55fa37e30cc09a1e0c336eab7c54a3286b2b
CherryHQ#21222https://github.com/CherryHQ/cherry-studio/pull/21222
f66d55fhttps://github.com/MidAutumnMoon/lingo-studio/commit/f66d55fa37e30cc09a1e0c336eab7c54a3286b2b
https://github.com/darc-games-gt
darc-games-gthttps://github.com/darc-games-gt
on Oct 1, 2026https://github.com/nodejs/node/issues/66341#issuecomment-5928974855
#66343https://github.com/nodejs/node/pull/66343
pelikhanhttps://github.com/pelikhan
on Oct 7, 2026https://github.com/nodejs/node/issues/66341#event-32709888977
Avoid Node UTF-8 pipe crashes during Codex setup (#66631)https://github.com/github/gh-aw/commit/bb5c867179dc8703672a62633508d6cdbe79d964
#66631https://github.com/github/gh-aw/pull/66631
bb5c867https://github.com/github/gh-aw/commit/bb5c867179dc8703672a62633508d6cdbe79d964
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66939https://github.com/nodejs/node/pull/66939
on Oct 29, 2026https://github.com/nodejs/node/issues/66341#event-34638009290
rraulg5https://github.com/rraulg5
on Oct 29, 2026https://github.com/nodejs/node/issues/66341#event-34640364545
fs: fix readFileSync utf8 overflow on short readshttps://github.com/rraulg5/node/commit/8d514c7b0e47e1b802c56f4abc177d165a961e3b
8d514c7https://github.com/rraulg5/node/commit/8d514c7b0e47e1b802c56f4abc177d165a961e3b
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66341
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66341
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.