Title: Uncaught "URI malformed" error in baggageHeaderToObject due to invalid percent-encoding in baggage header · Issue #16251 · getsentry/sentry-javascript · GitHub
Open Graph Title: Uncaught "URI malformed" error in baggageHeaderToObject due to invalid percent-encoding in baggage header · Issue #16251 · getsentry/sentry-javascript
X Title: Uncaught "URI malformed" error in baggageHeaderToObject due to invalid percent-encoding in baggage header · Issue #16251 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/16251
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Uncaught \"URI malformed\" error in baggageHeaderToObject due to invalid percent-encoding in baggage header","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSelf-hosted/on-premise\n\n### Which SDK are you using?\n\n@sentry/node - fastify\n\n### SDK Version\n\n9.17.0\n\n### Framework Version\n\nnode.js\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\n**Description:**\nWhen the Sentry SDK for Node.js receives a request with an invalid baggage header (containing malformed percent-encoding, e.g. `%3G` or `%4Z`), it throws an **uncaught URIError: URI malformed** exception. This happens because using function `decodeURIComponent` in `baggageHeaderToObject`\n\nThis causes the entire Node.js process (e.g. Fastify server) to crash before any application-level error handling or middleware can run, making it impossible to sanitize or ignore the header at the application level.\n\n**Relevant Code:**\n[Link here](https://github.com/getsentry/sentry-javascript/blob/8f7599a2938da7b3380187cc5f5247f6dec08e8e/packages/core/src/utils-hoist/baggage.ts#L116)\n\n**Additional Context:**\n\nThis issue cannot be worked around at the application level, since Sentry parses the header before any framework middleware or hooks are executed.\nThe only current workaround is to filter the header at the proxy/load balancer level, which is not always possible.\nThis can be exploited to cause a denial of service by sending malformed headers.\n\n### Steps to Reproduce\n\n1. Start a Node.js server with Sentry SDK enabled (e.g. Fastify, Express).\n2. Send a request with a baggage header containing invalid percent-encoding, e.g.: `%20%3G%4Z`\n3. Observe that the server crashes with a URIError: URI malformed originating from Sentry.\n\n### Expected Result\n\nSentry should gracefully handle invalid percent-encoding in the baggage header. Ideally, it should:\n\nIgnore or skip invalid key-value pairs in the header.\nNot crash the process.\nOptionally log a warning or report the malformed header as a non-fatal event.\n\n### Actual Result\n\nThe process crashes with an uncaught exception:\n```\nURIError: URI malformed\n at decodeURIComponent (\u003canonymous>)\n at baggageHeaderToObject (.../sentry-javascript/packages/core/src/utils-hoist/baggage.ts:116:32)\n ...\n```","author":{"url":"https://github.com/roman-antl-satoshilabs","@type":"Person","name":"roman-antl-satoshilabs"},"datePublished":"2025-05-12T07:57:07Z","url":"https://github.com/getsentry/sentry-javascript/issues/16251"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:48e88679-d268-1b5a-5916-555db1de75b3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B514:25C00B:37C606B:495EC56:6B058F3B |
| html-safe-nonce | 082c07f0c818a7610bb5ff05e7c36d6de48e8a118c1db2ed943c74f414e03844 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTE0OjI1QzAwQjozN0M2MDZCOjQ5NUVDNTY6NkIwNThGM0IiLCJ2aXNpdG9yX2lkIjoiNzM4NzM3ODY4NjE3OTUxMjEyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b919350efcc571b99870f6d184e0ddb8d09cef0e5f5c72ca467ac5634b6bc846 |
| hovercard-subject-tag | issue:3056001560 |
| 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/getsentry/sentry-javascript/16251/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d62b727371173a432885aacef31fd1d3a5757ee3e4324ced69fb9d70d73d08e1/getsentry/sentry-javascript/issues/16251 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d62b727371173a432885aacef31fd1d3a5757ee3e4324ced69fb9d70d73d08e1/getsentry/sentry-javascript/issues/16251 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | roman-antl-satoshilabs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 808d57ad26095794a9e3681aed736bd67e8e82b1f5650d6c1e68f99382f8030c |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| 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 | 62e32c52ec1c22b5bb5c18be1c0c471472c89540 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width