Title: EventScrubber's header entries in DEFAULT_DENYLIST never match request headers · Issue #8272 · getsentry/sentry-python · GitHub
Open Graph Title: EventScrubber's header entries in DEFAULT_DENYLIST never match request headers · Issue #8272 · getsentry/sentry-python
X Title: EventScrubber's header entries in DEFAULT_DENYLIST never match request headers · Issue #8272 · getsentry/sentry-python
Description: The "wsgi" entries in DEFAULT_DENYLIST (sentry_sdk/scrubber.py) are spelled with underscores: x_csrftoken, x_api_key, set_cookie, x_forwarded_for, and x_real_ip in DEFAULT_PII_DENYLIST. scrub_dict compares k.lower() against the list, but...
Open Graph Description: The "wsgi" entries in DEFAULT_DENYLIST (sentry_sdk/scrubber.py) are spelled with underscores: x_csrftoken, x_api_key, set_cookie, x_forwarded_for, and x_real_ip in DEFAULT_PII_DENYLIST. scrub_dict ...
X Description: The "wsgi" entries in DEFAULT_DENYLIST (sentry_sdk/scrubber.py) are spelled with underscores: x_csrftoken, x_api_key, set_cookie, x_forwarded_for, and x_real_ip in DEFAULT_PII_DENYLIST. s...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/8272
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"EventScrubber's header entries in DEFAULT_DENYLIST never match request headers","articleBody":"The \"wsgi\" entries in `DEFAULT_DENYLIST` (`sentry_sdk/scrubber.py`) are spelled with underscores: `x_csrftoken`, `x_api_key`, `set_cookie`, `x_forwarded_for`, and `x_real_ip` in `DEFAULT_PII_DENYLIST`. `scrub_dict` compares `k.lower()` against the list, but the request headers it gets are hyphenated. `_werkzeug._get_headers` turns `HTTP_X_CSRFTOKEN` into `X-Csrftoken`, and `_asgi_common._get_headers` keeps the raw `x-api-key`. So `x-csrftoken` is never equal to `x_csrftoken` and these entries never fire on headers. `proxy-authorization` right next to them uses a hyphen, which makes me think the rest are just WSGI environ names that got lowercased.\r\n\r\nWhat reaches Sentry because of it:\r\n\r\n- With the default `send_default_pii=False`, `_filter_headers` strips only the names in `SENSITIVE_ENV_KEYS`, and `X_CSRFTOKEN` isn't one of them. So Django's `X-CSRFToken` header goes out as is, although the scrubber lists it.\r\n- With `send_default_pii=True`, `_filter_headers` keeps everything, and `X-Api-Key` and `X-CSRFToken` aren't scrubbed even though they are in the security denylist that's supposed to apply regardless of PII.\r\n\r\nChecked on master (26ef571): `capture_event` with `{\"X-Csrftoken\": ..., \"x-api-key\": ..., \"Set-Cookie\": ...}` request headers keeps all three values, with `send_default_pii` on and off.\r\n\r\nNormalizing both sides in `EventScrubber` (e.g. `x.lower().replace(\"-\", \"_\")` for the denylist and the same for the key in `scrub_dict`) fixes it, and a user-supplied `denylist=[\"x-api-key\"]` then matches either spelling. One catch I hit while trying it: `x_forwarded_for` is in `DEFAULT_DENYLIST` too, not only in `DEFAULT_PII_DENYLIST`, so once keys match, `X-Forwarded-For` gets scrubbed even with `send_default_pii=True`. `test_request_headers_legacy_pii_passes_headers_through` and `test_request_headers_legacy_no_pii_redacts_sensitive` in `tests/integrations/wsgi/test_wsgi.py` rely on it not matching (the second one's docstring says so). So I'd also drop `x_forwarded_for` from `DEFAULT_DENYLIST` and leave it to the PII list. The no-PII test would then see the scrubber's `[Filtered]` on top of the emptied value from `_filter_headers`, unless you'd rather have the scrubber skip values that are already an `AnnotatedValue`.\r\n\r\nThis scrubs more than today, so I wanted to check the direction before sending a PR. Happy to do it with tests in `tests/test_scrubber.py`.\r\n","author":{"url":"https://github.com/ratomirjovanovic","@type":"Person","name":"ratomirjovanovic"},"datePublished":"2026-11-15T13:43:06Z","url":"https://github.com/getsentry/sentry-python/issues/8272"}
| 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:00dab504-c0fd-9b72-63e8-28d912414fed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 96AE:185321:57C8A8:7ADB65:6B007617 |
| html-safe-nonce | 8c6870e040a153cda2d95fe7744b2728d52510d303c35d8b0c03c339ba428e3c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkFFOjE4NTMyMTo1N0M4QTg6N0FEQjY1OjZCMDA3NjE3IiwidmlzaXRvcl9pZCI6IjI0MTI4NzczNDAyMTM1NTAzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ad32be3543826c757a8355c3e6c7cc80cde63c7421194a9eeda69ee22711912a |
| hovercard-subject-tag | issue:6404714058 |
| 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-python/8272/issue_layout |
| twitter:image | https://opengraph.githubassets.com/71f6de27d92384f7bfa26a1ccbd10714e274f3d1ed92e47461359ed1de20bca9/getsentry/sentry-python/issues/8272 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/71f6de27d92384f7bfa26a1ccbd10714e274f3d1ed92e47461359ed1de20bca9/getsentry/sentry-python/issues/8272 |
| og:image:alt | The "wsgi" entries in DEFAULT_DENYLIST (sentry_sdk/scrubber.py) are spelled with underscores: x_csrftoken, x_api_key, set_cookie, x_forwarded_for, and x_real_ip in DEFAULT_PII_DENYLIST. scrub_dict ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ratomirjovanovic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| 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 | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width