Title: ffi: `exportArrayBuffer` type check is fooled by `Symbol.toStringTag` · Issue #66454 · nodejs/node · GitHub
Open Graph Title: ffi: `exportArrayBuffer` type check is fooled by `Symbol.toStringTag` · Issue #66454 · nodejs/node
X Title: ffi: `exportArrayBuffer` type check is fooled by `Symbol.toStringTag` · Issue #66454 · nodejs/node
Description: Version main Platform macOS 26.7.1 Subsystem ffi What steps will reproduce the bug? import ffi from 'node:ffi'; const dest = new ArrayBuffer(8); const ptr = ffi.getRawPointer(dest); // Real ArrayBuffer with a custom tag: rejected. const ...
Open Graph Description: Version main Platform macOS 26.7.1 Subsystem ffi What steps will reproduce the bug? import ffi from 'node:ffi'; const dest = new ArrayBuffer(8); const ptr = ffi.getRawPointer(dest); // Real ArrayBu...
X Description: Version main Platform macOS 26.7.1 Subsystem ffi What steps will reproduce the bug? import ffi from 'node:ffi'; const dest = new ArrayBuffer(8); const ptr = ffi.getRawPointer(dest); // Real...
Opengraph URL: https://github.com/nodejs/node/issues/66454
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: `exportArrayBuffer` type check is fooled by `Symbol.toStringTag`","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nmacOS 26.7.1\n```\n\n### Subsystem\n\nffi\n\n### What steps will reproduce the bug?\n\n```js\nimport ffi from 'node:ffi';\n\nconst dest = new ArrayBuffer(8);\nconst ptr = ffi.getRawPointer(dest);\n\n// Real ArrayBuffer with a custom tag: rejected.\nconst real = new ArrayBuffer(4);\nObject.defineProperty(real, Symbol.toStringTag, { value: 'Custom' });\ntry {\n ffi.exportArrayBuffer(real, ptr, 8);\n} catch (err) {\n console.log('real:', err.code, err.message);\n}\n\n// Fake object tagged as ArrayBuffer: passes the JS check.\nconst fake = { [Symbol.toStringTag]: 'ArrayBuffer', byteLength: 4 };\ntry {\n ffi.exportArrayBuffer(fake, ptr, 8);\n} catch (err) {\n console.log('fake:', err.code, err.message);\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe `arrayBuffer` argument is documented as `{ArrayBuffer}`\nDocs https://github.com/nodejs/node/blob/main/doc/api/ffi.md#ffiexportarraybufferarraybuffer-pointer-length\n\nSo the check should depend on whether the value really is an `ArrayBuffer`, not on its tag. A real `ArrayBuffer` should be copied.\nThe fake object should be rejected in JS with `The \"arrayBuffer\" argument must be an instance of ArrayBuffer`.\n\n### What do you see instead?\n\n```console\nreal: ERR_INVALID_ARG_TYPE The \"arrayBuffer\" argument must be an instance of ArrayBuffer. Received an instance of ArrayBuffer\nfake: ERR_INVALID_ARG_TYPE The first argument must be a Buffer, ArrayBuffer, SharedArrayBuffer, or ArrayBufferView\n```\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-10-02T03:41:48Z","url":"https://github.com/nodejs/node/issues/66454"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cfe6bad2-886e-d2ce-8592-8c6993fc0765 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E046:1E45AC:7920B4:9D7B9A:6AED336A |
| html-safe-nonce | 1f4c062e2928a839ddab3487a03ebeebd7b9cfcb8239c17bc10da639ac6960dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDQ2OjFFNDVBQzo3OTIwQjQ6OUQ3QjlBOjZBRUQzMzZBIiwidmlzaXRvcl9pZCI6IjU5OTg4NjE2NjgyODY1NDI2OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 421d2eb6e079732bbc342298ab62b7c4a4c478c425968914b3b929a22ac2cac6 |
| hovercard-subject-tag | issue:5672548891 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66454/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ded770e629e22a707558ec7737c25070a24f01b56c7f5dd2d4800cfd96931c3c/nodejs/node/issues/66454 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ded770e629e22a707558ec7737c25070a24f01b56c7f5dd2d4800cfd96931c3c/nodejs/node/issues/66454 |
| og:image:alt | Version main Platform macOS 26.7.1 Subsystem ffi What steps will reproduce the bug? import ffi from 'node:ffi'; const dest = new ArrayBuffer(8); const ptr = ffi.getRawPointer(dest); // Real ArrayBu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trivikr |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width