When using the Django integration of the Sentry SDK in a specific configuration it is possible to leak sensitive cookies values, including the session cookie to Sentry. These sensitive cookies could then be used by someone with access to your Sentry issues to impersonate or escalate their privileges within your application.
The below must be true in order for these sensitive values to be leaked:
Your Sentry SDK configuration has sendDefaultPII set to True
You are using a custom name for either of the cookies below in your Django settings.
You are not configured in your organization or project settings to use our data scrubbing features to account for the custom cookie names
Patches
As of version 1.14.0, the Django integration of the sentry-sdk will detect the custom cookie names based on your Django settings and will remove the values from the payload before sending the data to Sentry.
Workarounds
If you can not update your sentry-sdk to a patched version than you can use the SDKs filtering mechanism to remove the cookies from the payload that is sent to Sentry. For error events this can be done with the before_send callback method and for performance related events (transactions) you can use the before_send_transaction callback method.
If you'd like to handle filtering of these values on the server-side, you can also use our advanced data scrubbing feature to account for the custom cookie names. Look for the $http.cookies, $http.headers, $request.cookies, or $request.headers fields to target with your scrubbing rule.
getsentry/sentry-python
### [`v1.14.0`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1140)
[Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.13.0...1.14.0)
##### Various fixes & improvements
- Add `before_send_transaction` ([#1840](https://togithub.com/getsentry/sentry-python/issues/1840)) by [@antonpirker](https://togithub.com/antonpirker)
Adds a hook (similar to `before_send`) that is called for all transaction events (performance releated data).
Usage:
```python
import sentry_sdk
def strip_sensitive_data(event, hint):
```
### modify event here (or return `None` if you want to drop the event entirely)
return event
sentry_sdk.init(
### ...
before_send_transaction=strip_sensitive_data,
)
```
See also: https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-transaction-
- Django: Always remove values of Django session related cookies. (#1842) by @antonpirker
- Profiling: Enable profiling for ASGI frameworks (#1824) by @Zylphrex
- Profiling: Better gevent support (#1822) by @Zylphrex
- Profiling: Add profile context to transaction (#1860) by @Zylphrex
- Profiling: Use co_qualname in python 3.11 (#1831) by @Zylphrex
- OpenTelemetry: fix Use dict for sentry-trace context instead of tuple (#1847) by @AbhiPrasad
- OpenTelemetry: fix extra dependency (#1825) by @bernardotorres
- OpenTelemetry: fix NoOpSpan updates scope (#1834) by @Zylphrex
- OpenTelemetry: Make sure to noop when there is no DSN (#1852) by @antonpirker
- FastAPI: Fix middleware being patched multiple times (#1841) by @JohnnyDeuss
- Starlette: Avoid import of pkg_resource with Starlette integration (#1836) by @mgu
- Removed code coverage target (#1862) by @antonpirker
```
### [`v1.13.0`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1130)
[Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.12.1...1.13.0)
##### Various fixes & improvements
- Add Starlite integration ([#1748](https://togithub.com/getsentry/sentry-python/issues/1748)) by [@gazorby](https://togithub.com/gazorby)
Adding support for the [Starlite](https://starlite-api.github.io/starlite/1.48/) framework. Unhandled errors are captured. Performance spans for Starlite middleware are also captured. Thanks [@gazorby](https://togithub.com/gazorby) for the great work!
Usage:
```python
from starlite import Starlite, get
import sentry_sdk
from sentry_sdk.integrations.starlite import StarliteIntegration
sentry_sdk.init(
dsn="...",
traces_sample_rate=1.0,
integrations=[
StarliteIntegration(),
],
)
@get("/")
def hello_world() -> dict[str, str]:
"""Keeping the tradition alive with hello world."""
bla = 1/0 # causing an error
return {"hello": "world"}
app = Starlite(route_handlers=[hello_world])
```
- Profiling: Remove sample buffer from profiler ([#1791](https://togithub.com/getsentry/sentry-python/issues/1791)) by [@Zylphrex](https://togithub.com/Zylphrex)
- Profiling: Performance tweaks to profile sampler ([#1789](https://togithub.com/getsentry/sentry-python/issues/1789)) by [@Zylphrex](https://togithub.com/Zylphrex)
- Add span for Django SimpleTemplateResponse rendering ([#1818](https://togithub.com/getsentry/sentry-python/issues/1818)) by [@chdsbd](https://togithub.com/chdsbd)
- Use [@wraps](https://togithub.com/wraps) for Django Signal receivers ([#1815](https://togithub.com/getsentry/sentry-python/issues/1815)) by [@meanmail](https://togithub.com/meanmail)
- Add enqueued_at and started_at to rq job extra ([#1024](https://togithub.com/getsentry/sentry-python/issues/1024)) by [@kruvasyan](https://togithub.com/kruvasyan)
- Remove sanic v22 pin ([#1819](https://togithub.com/getsentry/sentry-python/issues/1819)) by [@sl0thentr0py](https://togithub.com/sl0thentr0py)
- Add support for `byterray` and `memoryview` built-in types ([#1833](https://togithub.com/getsentry/sentry-python/issues/1833)) by [@Tarty](https://togithub.com/Tarty)
- Handle `"rc"` in SQLAlchemy version. ([#1812](https://togithub.com/getsentry/sentry-python/issues/1812)) by [@peterschutt](https://togithub.com/peterschutt)
- Doc: Use .venv (not .env) as a virtual env location in CONTRIBUTING.md ([#1790](https://togithub.com/getsentry/sentry-python/issues/1790)) by [@tonyo](https://togithub.com/tonyo)
- Auto publish to internal pypi on release ([#1823](https://togithub.com/getsentry/sentry-python/issues/1823)) by [@asottile-sentry](https://togithub.com/asottile-sentry)
- Added Python 3.11 to test suite ([#1795](https://togithub.com/getsentry/sentry-python/issues/1795)) by [@antonpirker](https://togithub.com/antonpirker)
- Update test/linting dependencies ([#1801](https://togithub.com/getsentry/sentry-python/issues/1801)) by [@antonpirker](https://togithub.com/antonpirker)
- Deps: bump sphinx from 5.2.3 to 5.3.0 ([#1686](https://togithub.com/getsentry/sentry-python/issues/1686)) by [@dependabot](https://togithub.com/dependabot)
### [`v1.12.1`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1121)
[Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.12.0...1.12.1)
##### Various fixes & improvements
- Link errors to OTel spans ([#1787](https://togithub.com/getsentry/sentry-python/issues/1787)) by [@antonpirker](https://togithub.com/antonpirker)
### [`v1.12.0`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1120)
[Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.11.1...1.12.0)
##### Basic OTel support
This adds support to automatically integrate OpenTelemetry performance tracing with Sentry.
See the documentation on how to set it up:
https://docs.sentry.io/platforms/python/performance/instrumentation/opentelemetry/
Give it a try and let us know if you have any feedback or problems with using it.
By: [@antonpirker](https://togithub.com/antonpirker) ([#1772](https://togithub.com/getsentry/sentry-python/issues/1772), [#1766](https://togithub.com/getsentry/sentry-python/issues/1766), [#1765](https://togithub.com/getsentry/sentry-python/issues/1765))
##### Various fixes & improvements
- Tox Cleanup ([#1749](https://togithub.com/getsentry/sentry-python/issues/1749)) by [@antonpirker](https://togithub.com/antonpirker)
- CI: Fix Github action checks ([#1780](https://togithub.com/getsentry/sentry-python/issues/1780)) by [@Zylphrex](https://togithub.com/Zylphrex)
- Profiling: Introduce active thread id on scope ([#1764](https://togithub.com/getsentry/sentry-python/issues/1764)) by [@Zylphrex](https://togithub.com/Zylphrex)
- Profiling: Eagerly hash stack for profiles ([#1755](https://togithub.com/getsentry/sentry-python/issues/1755)) by [@Zylphrex](https://togithub.com/Zylphrex)
- Profiling: Resolve inherited method class names ([#1756](https://togithub.com/getsentry/sentry-python/issues/1756)) by [@Zylphrex](https://togithub.com/Zylphrex)
Configuration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
==1.11.1
->==1.14.0
GitHub Vulnerability Alerts
CVE-2023-28117
Impact
When using the Django integration of the Sentry SDK in a specific configuration it is possible to leak sensitive cookies values, including the session cookie to Sentry. These sensitive cookies could then be used by someone with access to your Sentry issues to impersonate or escalate their privileges within your application.
The below must be true in order for these sensitive values to be leaked:
sendDefaultPII
set toTrue
SESSION_COOKIE_NAME
orCSRF_COOKIE_NAME
Django settingsPatches
As of version
1.14.0
, the Django integration of thesentry-sdk
will detect the custom cookie names based on your Django settings and will remove the values from the payload before sending the data to Sentry.Workarounds
If you can not update your
sentry-sdk
to a patched version than you can use the SDKs filtering mechanism to remove the cookies from the payload that is sent to Sentry. For error events this can be done with the before_send callback method and for performance related events (transactions) you can use the before_send_transaction callback method.If you'd like to handle filtering of these values on the server-side, you can also use our advanced data scrubbing feature to account for the custom cookie names. Look for the
$http.cookies
,$http.headers
,$request.cookies
, or$request.headers
fields to target with your scrubbing rule.References
Credits
Release Notes
getsentry/sentry-python
### [`v1.14.0`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1140) [Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.13.0...1.14.0) ##### Various fixes & improvements - Add `before_send_transaction` ([#1840](https://togithub.com/getsentry/sentry-python/issues/1840)) by [@antonpirker](https://togithub.com/antonpirker) Adds a hook (similar to `before_send`) that is called for all transaction events (performance releated data). Usage: ```python import sentry_sdk def strip_sensitive_data(event, hint): ``` ### modify event here (or return `None` if you want to drop the event entirely) return event sentry_sdk.init( ### ... before_send_transaction=strip_sensitive_data, ) ``` See also: https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-transaction- - Django: Always remove values of Django session related cookies. (#1842) by @antonpirker - Profiling: Enable profiling for ASGI frameworks (#1824) by @Zylphrex - Profiling: Better gevent support (#1822) by @Zylphrex - Profiling: Add profile context to transaction (#1860) by @Zylphrex - Profiling: Use co_qualname in python 3.11 (#1831) by @Zylphrex - OpenTelemetry: fix Use dict for sentry-trace context instead of tuple (#1847) by @AbhiPrasad - OpenTelemetry: fix extra dependency (#1825) by @bernardotorres - OpenTelemetry: fix NoOpSpan updates scope (#1834) by @Zylphrex - OpenTelemetry: Make sure to noop when there is no DSN (#1852) by @antonpirker - FastAPI: Fix middleware being patched multiple times (#1841) by @JohnnyDeuss - Starlette: Avoid import of pkg_resource with Starlette integration (#1836) by @mgu - Removed code coverage target (#1862) by @antonpirker ``` ### [`v1.13.0`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1130) [Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.12.1...1.13.0) ##### Various fixes & improvements - Add Starlite integration ([#1748](https://togithub.com/getsentry/sentry-python/issues/1748)) by [@gazorby](https://togithub.com/gazorby) Adding support for the [Starlite](https://starlite-api.github.io/starlite/1.48/) framework. Unhandled errors are captured. Performance spans for Starlite middleware are also captured. Thanks [@gazorby](https://togithub.com/gazorby) for the great work! Usage: ```python from starlite import Starlite, get import sentry_sdk from sentry_sdk.integrations.starlite import StarliteIntegration sentry_sdk.init( dsn="...", traces_sample_rate=1.0, integrations=[ StarliteIntegration(), ], ) @get("/") def hello_world() -> dict[str, str]: """Keeping the tradition alive with hello world.""" bla = 1/0 # causing an error return {"hello": "world"} app = Starlite(route_handlers=[hello_world]) ``` - Profiling: Remove sample buffer from profiler ([#1791](https://togithub.com/getsentry/sentry-python/issues/1791)) by [@Zylphrex](https://togithub.com/Zylphrex) - Profiling: Performance tweaks to profile sampler ([#1789](https://togithub.com/getsentry/sentry-python/issues/1789)) by [@Zylphrex](https://togithub.com/Zylphrex) - Add span for Django SimpleTemplateResponse rendering ([#1818](https://togithub.com/getsentry/sentry-python/issues/1818)) by [@chdsbd](https://togithub.com/chdsbd) - Use [@wraps](https://togithub.com/wraps) for Django Signal receivers ([#1815](https://togithub.com/getsentry/sentry-python/issues/1815)) by [@meanmail](https://togithub.com/meanmail) - Add enqueued_at and started_at to rq job extra ([#1024](https://togithub.com/getsentry/sentry-python/issues/1024)) by [@kruvasyan](https://togithub.com/kruvasyan) - Remove sanic v22 pin ([#1819](https://togithub.com/getsentry/sentry-python/issues/1819)) by [@sl0thentr0py](https://togithub.com/sl0thentr0py) - Add support for `byterray` and `memoryview` built-in types ([#1833](https://togithub.com/getsentry/sentry-python/issues/1833)) by [@Tarty](https://togithub.com/Tarty) - Handle `"rc"` in SQLAlchemy version. ([#1812](https://togithub.com/getsentry/sentry-python/issues/1812)) by [@peterschutt](https://togithub.com/peterschutt) - Doc: Use .venv (not .env) as a virtual env location in CONTRIBUTING.md ([#1790](https://togithub.com/getsentry/sentry-python/issues/1790)) by [@tonyo](https://togithub.com/tonyo) - Auto publish to internal pypi on release ([#1823](https://togithub.com/getsentry/sentry-python/issues/1823)) by [@asottile-sentry](https://togithub.com/asottile-sentry) - Added Python 3.11 to test suite ([#1795](https://togithub.com/getsentry/sentry-python/issues/1795)) by [@antonpirker](https://togithub.com/antonpirker) - Update test/linting dependencies ([#1801](https://togithub.com/getsentry/sentry-python/issues/1801)) by [@antonpirker](https://togithub.com/antonpirker) - Deps: bump sphinx from 5.2.3 to 5.3.0 ([#1686](https://togithub.com/getsentry/sentry-python/issues/1686)) by [@dependabot](https://togithub.com/dependabot) ### [`v1.12.1`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1121) [Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.12.0...1.12.1) ##### Various fixes & improvements - Link errors to OTel spans ([#1787](https://togithub.com/getsentry/sentry-python/issues/1787)) by [@antonpirker](https://togithub.com/antonpirker) ### [`v1.12.0`](https://togithub.com/getsentry/sentry-python/blob/HEAD/CHANGELOG.md#1120) [Compare Source](https://togithub.com/getsentry/sentry-python/compare/1.11.1...1.12.0) ##### Basic OTel support This adds support to automatically integrate OpenTelemetry performance tracing with Sentry. See the documentation on how to set it up: https://docs.sentry.io/platforms/python/performance/instrumentation/opentelemetry/ Give it a try and let us know if you have any feedback or problems with using it. By: [@antonpirker](https://togithub.com/antonpirker) ([#1772](https://togithub.com/getsentry/sentry-python/issues/1772), [#1766](https://togithub.com/getsentry/sentry-python/issues/1766), [#1765](https://togithub.com/getsentry/sentry-python/issues/1765)) ##### Various fixes & improvements - Tox Cleanup ([#1749](https://togithub.com/getsentry/sentry-python/issues/1749)) by [@antonpirker](https://togithub.com/antonpirker) - CI: Fix Github action checks ([#1780](https://togithub.com/getsentry/sentry-python/issues/1780)) by [@Zylphrex](https://togithub.com/Zylphrex) - Profiling: Introduce active thread id on scope ([#1764](https://togithub.com/getsentry/sentry-python/issues/1764)) by [@Zylphrex](https://togithub.com/Zylphrex) - Profiling: Eagerly hash stack for profiles ([#1755](https://togithub.com/getsentry/sentry-python/issues/1755)) by [@Zylphrex](https://togithub.com/Zylphrex) - Profiling: Resolve inherited method class names ([#1756](https://togithub.com/getsentry/sentry-python/issues/1756)) by [@Zylphrex](https://togithub.com/Zylphrex)Configuration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
â™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.