Title: Piping streams into SHA3 without end: false crashes · Issue #28245 · nodejs/node · GitHub
Open Graph Title: Piping streams into SHA3 without end: false crashes · Issue #28245 · nodejs/node
X Title: Piping streams into SHA3 without end: false crashes · Issue #28245 · nodejs/node
Description: Version: 12.4.0 Platform: Windows 10 x64 and Linux 4.4.0-042stab138.1 Subsystem: crypto or deps This code causes a segmentation fault in 12.4.0: const crypto = require('crypto'); const fs = require('fs'); const myOwnCode = fs.createReadS...
Open Graph Description: Version: 12.4.0 Platform: Windows 10 x64 and Linux 4.4.0-042stab138.1 Subsystem: crypto or deps This code causes a segmentation fault in 12.4.0: const crypto = require('crypto'); const fs = require...
X Description: Version: 12.4.0 Platform: Windows 10 x64 and Linux 4.4.0-042stab138.1 Subsystem: crypto or deps This code causes a segmentation fault in 12.4.0: const crypto = require('crypto'); const fs =...
Opengraph URL: https://github.com/nodejs/node/issues/28245
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Piping streams into SHA3 without end: false crashes","articleBody":"\u003c!--\r\nThank you for reporting a possible bug in Node.js.\r\n\r\nPlease fill in as much of the template below as you can.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify the affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you can.\r\n-->\r\n\r\n* **Version**: 12.4.0\r\n* **Platform**: Windows 10 x64 and Linux 4.4.0-042stab138.1\r\n* **Subsystem**: crypto or deps\r\n\r\n\u003c!-- Please provide more details below this comment. -->\r\n\r\nThis code causes a segmentation fault in 12.4.0:\r\n\r\n```javascript\r\nconst crypto = require('crypto');\r\nconst fs = require('fs');\r\n\r\nconst myOwnCode = fs.createReadStream(__filename);\r\nconst copy = fs.createWriteStream(`${__filename}.copy`);\r\nconst hash = crypto.createHash('sha3-512');\r\nmyOwnCode.pipe(hash);\r\nmyOwnCode.pipe(copy).on('finish', () => {\r\n hash.digest();\r\n});\r\n```\r\n\r\nThis seems to be caused by `pipe` calling `hash._flush` when `end` is not set to `false`. This code also causes a segmentation fault:\r\n\r\n```javascript\r\nconst crypto = require('crypto');\r\n\r\nconst hash = crypto.createHash('sha3-512');\r\nhash._flush(() => console.log('Flushed'));\r\nhash.digest();\r\n```\r\n\r\nThis seems to be at least partially caused by the implementation of `_flush`:\r\n\r\nhttps://github.com/nodejs/node/blob/908292cf1f551c614a733d858528ffb13fb3a524/lib/internal/crypto/hash.js#L54-L57\r\n\r\nIt bypasses the `this[kState][kFinalized]` safeguard:\r\n\r\nhttps://github.com/nodejs/node/blob/908292cf1f551c614a733d858528ffb13fb3a524/lib/internal/crypto/hash.js#L79-L91\r\n\r\nNote that this bug only happens when using SHA3, `sha256` seems to be working just fine, so there might also be some weirdness in OpenSSL.\r\n\r\ncc @mcollina @nodejs/crypto @nodejs/streams","author":{"url":"https://github.com/tniessen","@type":"Person","name":"tniessen"},"datePublished":"2019-06-15T13:03:21Z","url":"https://github.com/nodejs/node/issues/28245"}
| 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:55e88d20-9c8a-90e9-b9f1-35b359e7fc2d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A864:5463F:5462B3:7267AB:6AED1F5E |
| html-safe-nonce | 0371efd165a9c029521070b65cc4c7f9fcee01f11ffd5730cb0379ef9afae95e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODY0OjU0NjNGOjU0NjJCMzo3MjY3QUI6NkFFRDFGNUUiLCJ2aXNpdG9yX2lkIjoiNDQ5MjI3ODI2NzE3MDg1Njc5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eb18c727c70778eb0c66a9be17eafd2e9f4fdd7fab3dba8a6a7cbd5316354baa |
| hovercard-subject-tag | issue:456535688 |
| 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/28245/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55f31c20a72be26668d26fe28407d0dae98ae81a2d998ecc22e5a3f3256b5c3c/nodejs/node/issues/28245 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55f31c20a72be26668d26fe28407d0dae98ae81a2d998ecc22e5a3f3256b5c3c/nodejs/node/issues/28245 |
| og:image:alt | Version: 12.4.0 Platform: Windows 10 x64 and Linux 4.4.0-042stab138.1 Subsystem: crypto or deps This code causes a segmentation fault in 12.4.0: const crypto = require('crypto'); const fs = require... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tniessen |
| hostname | github.com |
| expected-hostname | github.com |
| None | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| 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 | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width