diff --git a/sentry_sdk/integrations/_wsgi_common.py b/sentry_sdk/integrations/_wsgi_common.py index 3ccf029964..b14a431a52 100644 --- a/sentry_sdk/integrations/_wsgi_common.py +++ b/sentry_sdk/integrations/_wsgi_common.py @@ -31,8 +31,11 @@ "HTTP_AUTHORIZATION", "HTTP_PROXY_AUTHORIZATION", "HTTP_X_API_KEY", - "HTTP_X_FORWARDED_FOR", "HTTP_X_REAL_IP", + "HTTP_CF_CONNECTING_IP", + "HTTP_TRUE_CLIENT_IP", + "HTTP_FORWARDED", + "HTTP_X_CLIENT_IP", ) SENSITIVE_HEADERS = tuple( diff --git a/tests/integrations/wsgi/test_wsgi.py b/tests/integrations/wsgi/test_wsgi.py index 2cda3a1b98..8f1237ca56 100644 --- a/tests/integrations/wsgi/test_wsgi.py +++ b/tests/integrations/wsgi/test_wsgi.py @@ -890,20 +890,31 @@ def test_request_headers_legacy_no_pii_redacts_sensitive( "/", headers={ "X-Forwarded-For": "1.2.3.4", + "X-Real-IP": "1.2.3.5", + "CF-Connecting-IP": "1.2.3.6", + "True-Client-IP": "1.2.3.7", + "Forwarded": "for=1.2.3.8", + "X-Client-IP": "1.2.3.9", "X-Custom-Header": "passthrough", }, ) (event,) = events - assert event["request"]["headers"]["X-Forwarded-For"] == "" - assert event["request"]["headers"]["X-Custom-Header"] == "passthrough" + for header in ( + "X-Forwarded-For", + "X-Real-Ip", + "Cf-Connecting-Ip", + "True-Client-Ip", + "Forwarded", + "X-Client-Ip", + ): + assert event["request"]["headers"][header] == "" + assert event["_meta"]["request"]["headers"][header] == { + "": {"rem": [["!config", "x"]]} + } - # The emptied value is accompanied by a `_meta` annotation marking it as - # removed, confirming the substitution came from the AnnotatedValue path. - assert event["_meta"]["request"]["headers"]["X-Forwarded-For"] == { - "": {"rem": [["!config", "x"]]} - } + assert event["request"]["headers"]["X-Custom-Header"] == "passthrough" def test_request_headers_data_collection_off_collects_no_headers(