Skip to content

fix(scrubbing): apply the url scrubber to conn path and query fields … - #1196

Merged
solnic merged 2 commits into
masterfrom
fix/scrub-url-derived-conn-fields
Sep 11, 2026
Merged

fix(scrubbing): apply the url scrubber to conn path and query fields …#1196
solnic merged 2 commits into
masterfrom
fix/scrub-url-derived-conn-fields

Conversation

@solnic

@solnic solnic commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Now :url_scrubber also handles the conn's own request_path, path_info and query_string, wherever the connection itself is reported. path_info is rebuilt against script_name, so forwarded routers stay correct.

Before

The app's scrubber redacts the token segment of the URL, but the conn embedded in the exception still carries the raw path:

  • request_path/scrubbing-demo/forwarded/reset-password/pathsecret-...
  • path_info — the secret as its own segment
  • query_string — every parameter in the clear
pr1-conn-dump-before

After

The same three fields now come from the scrubbed URL:

  • request_path and path_info — the token segment replaced with the placeholder
  • script_name — still ["scrubbing-demo", "forwarded"], showing path_info was rebuilt against the mount point rather than the whole path
  • query_string — redacted alongside them
pr1-conn-dump-after

Closes #1195

@solnic
solnic force-pushed the fix/scrub-url-derived-conn-fields branch 4 times, most recently from 13d1bf5 to 1810f90 Compare September 8, 2026 12:04
@solnic
solnic marked this pull request as ready for review September 9, 2026 12:13
Comment thread lib/sentry/scrubber.ex
defp scrubbed_uri(conn) do
case get(:url_scrubber).(conn) do
url when is_binary(url) -> URI.parse(url)
_other -> nil

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.

Is this the same behavior we had before? It's a pretty dangerous silent failure mechanism so I’m wondering if we'd at least need a warning log.

@solnic solnic Sep 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@whatyouhide ah great catch - this is now fixed via a658d85 - I also added rescuing from potential failures which follows Sentry spec about user-provided callbacks.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

edit: I rebased the stack so the fixup commit is 665d723 now, sorry for the noise

@solnic
solnic force-pushed the fix/scrub-url-derived-conn-fields branch from a658d85 to 665d723 Compare September 10, 2026 13:29
@solnic
solnic merged commit 9b2280d into master Sep 11, 2026
16 checks passed
@solnic
solnic deleted the fix/scrub-url-derived-conn-fields branch September 11, 2026 12:31
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.

Conn structs in stacktrace frame vars leak credentials via query_string, request_path and path_info

3 participants