Skip to content

feat(scrubbing): adopt denylist defined by Data Collection spec - #1198

Open
solnic wants to merge 1 commit into
fix/scrub-conn-path-paramsfrom
feat/spec-conformant-param-scrubbing
Open

feat(scrubbing): adopt denylist defined by Data Collection spec#1198
solnic wants to merge 1 commit into
fix/scrub-conn-path-paramsfrom
feat/spec-conformant-param-scrubbing

Conversation

@solnic

@solnic solnic commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Now the default sensitive keys are the denylist the Data Collection spec requires, matched as a case-insensitive substring, and config :sentry, scrubber: [param_keys: [...]] extends that list with your own terms.

Before

internal_ref is the row to focus on. Relay does not recognise that name, so it is the one value the panel shows exactly as the SDK left it — and there is no way to make the SDK redact it, because the :param_keys option does not exist yet:

  • internal_refcfgref-20260909-082441-before, in both Body and Query String
  • token, api_key — not in the old denylist
  • PASSWORD — the same term as password, missed because matching was case-sensitive
  • user_password — the same term again, missed because matching required exact equality
pr3-conn-dump-before pr3-request-panel-before

After

Every one of those is redacted, each by a different rule:

  • internal_ref*********, sensitive only because the app configured scrubber: [param_keys: ["internal_ref"]]
  • token — a key the spec denylist adds
  • api_key — matched as a substring of key
  • PASSWORD — matched too
  • user_password — matched as a substring
pr3-conn-dump-after pr3-request-panel-after

@solnic
solnic force-pushed the feat/spec-conformant-param-scrubbing branch from 502b842 to b569ac0 Compare September 7, 2026 14:49
@solnic
solnic force-pushed the feat/spec-conformant-param-scrubbing branch 2 times, most recently from ad98de1 to 052b357 Compare September 8, 2026 11:47
@solnic
solnic force-pushed the feat/spec-conformant-param-scrubbing branch from 052b357 to 4005705 Compare September 8, 2026 12:04
@solnic
solnic marked this pull request as ready for review September 9, 2026 12:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4005705. Configure here.

Comment thread lib/sentry/scrubber.ex
@solnic solnic changed the title feat(scrubbing): adopt the spec param denylist and make it extensible… feat(scrubbing): adopt denylist defined by Data Collection spec Sep 9, 2026
@solnic
solnic force-pushed the feat/spec-conformant-param-scrubbing branch from 4005705 to 9925981 Compare September 9, 2026 12:39
Comment thread lib/sentry/config.ex
`Sentry.Scrubber.default_header_keys/0` and the `:header_scrubber`
option of `Sentry.PlugContext`.

*Available since 14.0.0*.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we gonna have breaking changes because of this, since we're bumping the major version?

Comment thread lib/sentry/config.ex
which is the denylist required by the
[Sentry Data Collection spec](https://develop.sentry.dev/sdk/foundations/client/data-collection/).
The spec defines custom deny-mode terms as additive, so there is no way
to shrink the default list — that is deliberate.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally em-dashes are not spaces (en dashes are). Sadly agents love to space around em dashes

Suggested change
to shrink the default listthat is deliberate.
to shrink the default listthat is deliberate.

Comment thread lib/sentry/config.ex
Terms are matched as case-insensitive substrings of the key name, so
`"ref"` redacts `"internal_ref"` and `"REF_ID"` alike.

This does not affect header scrubbing, which uses its own list — see

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here

@solnic
solnic force-pushed the feat/spec-conformant-param-scrubbing branch from 9925981 to 6b41dab Compare September 10, 2026 13:29
Comment thread lib/sentry/scrubber.ex
Comment on lines +398 to +399
defp configured_param_keys,
do: @default_scrubbed_param_keys ++ Sentry.Config.scrubber()[:param_keys]

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: Sentry.Config.scrubber() returns [] by default. Accessing [:param_keys] on it returns nil, causing an ArgumentError when concatenated with @default_scrubbed_param_keys.
Severity: CRITICAL

Suggested Fix

Ensure that the return value of Sentry.Config.scrubber() is handled safely before key access. Instead of directly accessing keys like config[:param_keys], use Keyword.get(config, :param_keys, []) to provide a default empty list. This will prevent the ArgumentError when concatenating with nil if the key is not present.

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: lib/sentry/scrubber.ex#L398-L399

Potential issue: When the `:scrubber` option is not configured,
`Sentry.Config.scrubber()` returns its default value, an empty list `[]`. The function
`configured_param_keys` then attempts to access `[:param_keys]` on this empty list,
which results in `nil`. This `nil` value is then used in a list concatenation operation
(`@default_scrubbed_param_keys ++ nil`), which raises an `ArgumentError`. This crash
occurs during request handling for any application that has not explicitly configured
the `:scrubber` option, which is the default scenario for most users. A similar issue
exists in `configured_private_allow_list` which accesses `[:conn_private_allow_list]` on
the same empty list.

Also affects:

  • lib/sentry/scrubber.ex:402~403

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants