Commit 586842f
feat: sanitize non-EVM account addresses from Sentry events (#43337)
## **Description**
Extend Sentry address sanitization beyond EVM addresses to cover Solana,
Tron, Stellar, and Bitcoin (bech32 + legacy) formats.
Also, sanitization now also runs over breadcrumb message/data and report
`extra`/`contexts`, with a recursive walk that handles cyclic references
and non-enumerable `Error` `message`/`stack` fields.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: MetaMask/MetaMask-planning#6680
## **Manual testing steps**
1. Update Extension code base to artificially include evm and non-evm
addresses in the different fields of `Capture UI Error`, like done on
branch
[feat/sanitize-non-evm-addresses-sentry-test](#43338)
2. Update `.metamaskrc`
a. Set SENTRY_DSN_DEV=_dsn_of_your_personal_sentry_account_
b. Set ENABLE_SETTINGS_PAGE_DEV_OPTIONS=true
3. Build Extension with `yarn start --sentry`
4. Go through Extension onboarding and enable metametrics
5. Go to Settings > Debug and click `Capture UI Error`
6. Go to Sentry and confirm the error got captured but all evm and
non-evm addresses are sanitized
<img width="374" height="550" alt="Screenshot 2026-06-08 at 17 14 24"
src="https://github.com/user-attachments/assets/18d27649-2a90-41b0-8040-1c23d0cd1209"
/>
## **Screenshots/Recordings**
### Error message
<img width="826" height="127" alt="Screenshot 2026-06-08 at 18 03 14"
src="https://github.com/user-attachments/assets/2170d929-944f-41ab-b3a7-f7082acfa2f4"
/>
### Stack trace
<img width="782" height="137" alt="Screenshot 2026-06-08 at 18 03 23"
src="https://github.com/user-attachments/assets/64465b98-d0d2-4c8b-a11b-6f0ce3d10002"
/>
### Breadcrumbs
<img width="786" height="864" alt="Screenshot 2026-06-08 at 18 04 40"
src="https://github.com/user-attachments/assets/c828f9d1-48a6-44e8-850b-0706f1d31611"
/>
### Additional data (extra)
<img width="777" height="606" alt="Screenshot 2026-06-08 at 17 28 08"
src="https://github.com/user-attachments/assets/6de88058-22af-47c1-85a9-f6d36c4d2274"
/>
### Context
<img width="778" height="651" alt="Screenshot 2026-06-08 at 19 27 16"
src="https://github.com/user-attachments/assets/bbb3ecc2-9f8b-433d-80dd-c7b4ea5361d6"
/>
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Telemetry-only privacy hardening in `setupSentry`; broad base58
patterns may over-redact some strings but do not affect wallet or auth
flows.
>
> **Overview**
> Expands **Sentry privacy scrubbing** so wallet addresses are stripped
from more payload shapes and chain formats, not only EVM hex in error
text.
>
> **Address formats:** Error-message sanitization now routes through
`sanitizeAddressesFromString`, which masks EVM as `0x**` and adds
regexes for Tron, Stellar, Bitcoin (bech32 and legacy), and Solana (EVM
is applied first so masks are not re-matched).
>
> **Broader coverage:** `rewriteReport` runs new
`sanitizeAddressesFromReportData` on `extra` and `contexts` before app
state is merged in. Breadcrumbs get the same treatment on `message` and
`data` via `sanitizeAddressesFromObject`, which deep-copies strings
(handles cycles, shared arrays, and `Error` `message`/`stack`) so live
console `arguments` are not mutated.
>
> Tests cover each chain in messages, nested `extra`/`contexts`, shared
references, and non-mutating breadcrumb redaction.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9c1292a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b7cc8d0 commit 586842f
2 files changed
Lines changed: 288 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
356 | 364 | | |
357 | 365 | | |
358 | 366 | | |
| |||
374 | 382 | | |
375 | 383 | | |
376 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
377 | 389 | | |
378 | 390 | | |
379 | 391 | | |
| |||
442 | 454 | | |
443 | 455 | | |
444 | 456 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
449 | 563 | | |
450 | 564 | | |
451 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
160 | 277 | | |
161 | 278 | | |
162 | 279 | | |
| |||
350 | 467 | | |
351 | 468 | | |
352 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
353 | 523 | | |
354 | 524 | | |
0 commit comments