Title: Crash if wrong hex string is written to http.ClientRequest · Issue #45150 · nodejs/node · GitHub
Open Graph Title: Crash if wrong hex string is written to http.ClientRequest · Issue #45150 · nodejs/node
X Title: Crash if wrong hex string is written to http.ClientRequest · Issue #45150 · nodejs/node
Description: Version 19.0.0 (but happens also on older versions, last retest with 21.4.0) Platform all Subsystem http, maybe streams What steps will reproduce the bug? if an invalid hex encoded string is written to a http.ClientRequest node crashes/a...
Open Graph Description: Version 19.0.0 (but happens also on older versions, last retest with 21.4.0) Platform all Subsystem http, maybe streams What steps will reproduce the bug? if an invalid hex encoded string is writte...
X Description: Version 19.0.0 (but happens also on older versions, last retest with 21.4.0) Platform all Subsystem http, maybe streams What steps will reproduce the bug? if an invalid hex encoded string is writte...
Opengraph URL: https://github.com/nodejs/node/issues/45150
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash if wrong hex string is written to http.ClientRequest","articleBody":"### Version\r\n\r\n19.0.0 (but happens also on older versions, last retest with 21.4.0)\r\n\r\n### Platform\r\n\r\nall\r\n\r\n### Subsystem\r\n\r\nhttp, maybe streams\r\n\r\n### What steps will reproduce the bug?\r\n\r\nif an invalid hex encoded string is written to a `http.ClientRequest` node crashes/asserts.\r\n\r\n```js\r\nconst http = require(\"http\");\r\n\r\nconst request = http.request(\"http://example.org\", {method: \"POST\"});\r\nrequest.write(\"1\", \"hex\");\r\n```\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\nalways\r\n\r\n### What is the expected behavior?\r\n\r\nMore graceful error handling like a JS exception.\r\n\r\n### What do you see instead?\r\n\r\nassert/crash\r\n\r\n```\r\nnode[360]: ../src/string_bytes.cc:420:static v8::Maybe\u003clong unsigned int> node::StringBytes::StorageSize(v8::Isolate*, v8::Local\u003cv8::Value>, node::encoding): Assertion `str->Length() % 2 == 0 && \"invalid hex string length\"' failed.\r\n 1: 0xbbf330 node::Abort() [node]\r\n 2: 0xbbf3ae [node]\r\n 3: 0xcaf8ba node::StringBytes::StorageSize(v8::Isolate*, v8::Local\u003cv8::Value>, node::encoding) [node]\r\n 4: 0xca562a node::StreamBase::Writev(v8::FunctionCallbackInfo\u003cv8::Value> const&) [node]\r\n 5: 0xca7876 void node::StreamBase::JSMethod\u003c&node::StreamBase::Writev>(v8::FunctionCallbackInfo\u003cv8::Value> const&) [node]\r\n 6: 0xe03f00 [node]\r\n 7: 0xe05356 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]\r\n 8: 0x17fb3f9 [node]\r\nAborted (core dumped)\r\n```\r\n\r\n### Additional information\r\n\r\nThis seems to be not limited to http, net shows same problem with following code:\r\n```js\r\nconst net = require(\"node:net\");\r\nconst s = net.createConnection(8000);\r\ns.on(\"connect\", () => {\r\n s.cork()\r\n s.write(\"a\")\r\n s.write(\"1\", \"hex\");\r\n s.uncork()\r\n});\r\n```\r\nInteresting is that following net sample doesn't crash:\r\n```js\r\nconst net = require(\"node:net\");\r\nconst s = net.createConnection(8000);\r\ns.on(\"connect\", () => {\r\n s.write(\"1\", \"hex\");\r\n});\r\n```\r\nSeems in this case the single, invalid hex encoded byte is silently discarded.","author":{"url":"https://github.com/Flarna","@type":"Person","name":"Flarna"},"datePublished":"2022-10-24T13:50:21Z","url":"https://github.com/nodejs/node/issues/45150"}
| 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:25764a59-bc50-e313-c163-160a893b13d5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 838E:2973C7:447261:58DA14:6AED2238 |
| html-safe-nonce | eb8ce89f59f9a398d0900d796dab3053551617d700d617e8171171b634790e34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzhFOjI5NzNDNzo0NDcyNjE6NThEQTE0OjZBRUQyMjM4IiwidmlzaXRvcl9pZCI6IjQwMzM0Nzk3NzYwMjg5MjY1MjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c460fdb27561069c0400b09252a78d5ba3c05d717bc6d50d49e5cec41b162b39 |
| hovercard-subject-tag | issue:1420866686 |
| 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/45150/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ad72b19c7d3696bd9f976759ea776323497cdbfd00f148bd7dfaa7457785b25/nodejs/node/issues/45150 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ad72b19c7d3696bd9f976759ea776323497cdbfd00f148bd7dfaa7457785b25/nodejs/node/issues/45150 |
| og:image:alt | Version 19.0.0 (but happens also on older versions, last retest with 21.4.0) Platform all Subsystem http, maybe streams What steps will reproduce the bug? if an invalid hex encoded string is writte... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Flarna |
| 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