Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class DataCollectionUserOptions(TypedDict, total=False):
graphql: "GraphQLCollectionUserOptions"
gen_ai: "GenAICollectionUserOptions"
database: "DatabaseCollectionUserOptions"
queues: bool
stack_frame_variables: bool
frame_context_lines: int

Expand All @@ -206,6 +207,7 @@ class DataCollection(TypedDict):
graphql: "GraphQLCollectionBehaviour"
gen_ai: "GenAICollectionBehaviour"
database: "DatabaseCollectionBehaviour"
queues: bool
stack_frame_variables: bool
frame_context_lines: int

Expand Down
2 changes: 2 additions & 0 deletions sentry_sdk/data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def _map_from_send_default_pii(
"graphql": {"document": send_default_pii, "variables": send_default_pii},
"gen_ai": {"inputs": send_default_pii, "outputs": send_default_pii},
"database": {"query_params": send_default_pii},
"queues": send_default_pii,
"stack_frame_variables": include_local_variables,
"frame_context_lines": (
_DEFAULT_FRAME_CONTEXT_LINES if include_source_context else 0
Expand Down Expand Up @@ -157,6 +158,7 @@ def _resolve_explicit(
"graphql": _graphql_from_value(d.get("graphql") or {}),
"gen_ai": _gen_ai_from_value(d.get("gen_ai") or {}),
"database": _database_from_value(d.get("database") or {}),
"queues": d.get("queues", True),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The new data_collection['queues'] setting is ignored by queue integrations. They continue to use should_send_default_pii(), potentially leaking data against the user's explicit configuration.
Severity: HIGH

Suggested Fix

Update the queue integrations (RQ, Huey, ARQ, Celery) to check the data_collection['queues'] setting from the client options. The logic should respect this new flag and not send queue arguments if it is set to False, regardless of the send_default_pii setting.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: sentry_sdk/data_collection.py#L161

Potential issue: The new `data_collection['queues']` configuration option is introduced
but not used by any of the queue integrations (RQ, Huey, ARQ, Celery). These
integrations continue to rely solely on `should_send_default_pii()` to decide whether to
capture job arguments and keyword arguments. This creates a situation where a user might
explicitly set `data_collection={'queues': False}` expecting to prevent sensitive data
from being sent, but the SDK will silently ignore this setting and leak the data if
`send_default_pii` is `True`. This is a functional data leakage vulnerability as the
feature does not work as documented.

Also affects:

  • sentry_sdk/integrations/celery/__init__.py:146
  • sentry_sdk/integrations/rq.py:188
  • sentry_sdk/integrations/huey.py:130
  • sentry_sdk/integrations/arq.py:177

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It hasn't be implemented yet, but it will be

"stack_frame_variables": stack_frame_variables,
"frame_context_lines": frame_context_lines,
}
Expand Down
11 changes: 8 additions & 3 deletions tests/test_data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _get(dc, path):
"query_params.mode": "off",
"http_headers.request.mode": "denylist",
"http_bodies": _ALL_HTTP_BODY_TYPES,
"queues": False,
"frame_context_lines": 5,
},
id="no_options_collects_no_pii",
Expand All @@ -97,12 +98,13 @@ def _get(dc, path):
"gen_ai.outputs": True,
"cookies.mode": "denylist",
"query_params.mode": "denylist",
"queues": True,
},
id="send_default_pii_true_collects_pii",
),
pytest.param(
{"send_default_pii": False},
{"user_info": False, "cookies.mode": "off"},
{"user_info": False, "cookies.mode": "off", "queues": False},
id="send_default_pii_false_collects_no_pii",
),
pytest.param(
Expand All @@ -114,6 +116,7 @@ def _get(dc, path):
"cookies.mode": "denylist",
"query_params.mode": "denylist",
"http_bodies": _ALL_HTTP_BODY_TYPES,
"queues": True,
},
id="explicit_data_collection_uses_spec_defaults",
),
Expand Down Expand Up @@ -193,17 +196,19 @@ def _get(dc, path):
"graphql.document": False,
"graphql.variables": False,
"database.query_params": False,
"queues": False,
},
id="legacy_pii_off_gates_graphql_and_database",
id="legacy_pii_off_gates_graphql_database_and_queues",
),
pytest.param(
{"send_default_pii": True},
{
"graphql.document": True,
"graphql.variables": True,
"database.query_params": True,
"queues": True,
},
id="legacy_pii_on_collects_graphql_and_database",
id="legacy_pii_on_collects_graphql_database_and_queues",
),
pytest.param(
{"data_collection": {"graphql": {"variables": False}}},
Expand Down
Loading