Skip to content

Commit bf77a86

Browse files
fix(litestar): Copy request info to prevent cookies mutation (#4883)
Prevent mutating cookies on incoming HTTP requests if the cookie name is in the scrubbers denylist. Cookies like `token=...` were replaced with `AnnotatedValue` because a shallow reference of the request information was held by the client. A deep copy is introduced so scrubbing does not interfere with Litestar, and in particular does not break `JWTCookieAuth`. Closes #4882 --------- Co-authored-by: Ivana Kellyer <[email protected]>
1 parent 41f709e commit bf77a86

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sentry_sdk/integrations/litestar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from collections.abc import Set
2+
from copy import deepcopy
3+
24
import sentry_sdk
35
from sentry_sdk.consts import OP
46
from sentry_sdk.integrations import (
@@ -260,7 +262,7 @@ def event_processor(event, _):
260262

261263
event.update(
262264
{
263-
"request": request_info,
265+
"request": deepcopy(request_info),
264266
"transaction": tx_name,
265267
"transaction_info": tx_info,
266268
}

sentry_sdk/integrations/starlite.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from copy import deepcopy
2+
13
import sentry_sdk
24
from sentry_sdk.consts import OP
35
from sentry_sdk.integrations import DidNotEnable, Integration
@@ -237,7 +239,7 @@ def event_processor(event, _):
237239

238240
event.update(
239241
{
240-
"request": request_info,
242+
"request": deepcopy(request_info),
241243
"transaction": tx_name,
242244
"transaction_info": tx_info,
243245
}

0 commit comments

Comments
 (0)