iOS: previous-run native crash reports can bypass SetBeforeSend

Open
#5,765 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
49/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Read src/Sentry/SentrySdk.cs and src/Sentry/Platforms/Cocoa/SentrySdk.cs, especially InitHub and ProcessOnBeforeSend, then inspect SentryEventHelper.DoBeforeSend and related tests. Reproduce how a previous-run native crash report is processed before the managed Hub exists. Done when BeforeSend runs for that report while scope event processors are skipped until the Hub is ready, with tests covering the behavior.

Written by the indexing model from the issue text.

Description

Bug Platform: iOS State: Needs Discussion

On iOS / Mac Catalyst, native crash reports from the previous run can be sent without the user's SetBeforeSend (or managed event processors) running.

InitHub initializes the Cocoa SDK before the managed Hub exists. The Cocoa SDK can process stored crash reports during that window (confirmed here). They reach ProcessOnBeforeSend, where CurrentHub is still a DisabledHub, which returns the event unchanged:

// If the SDK is disabled, there are no event processors or before send to run.
if (hub is DisabledHub)
{
    return evt;
}

The previous-run crash is the one event most likely to carry data a user's BeforeSend is meant to redact. The docs for OnCrashedLastRun also say that event can be dropped by SetBeforeSend.

Possible fix

SentryEventHelper.DoBeforeSend only needs options, not the hub. When the hub isn't ready, still convert the event and run BeforeSend; skip only the scope event processors. Event processors added via options.AddEventProcessor could run too.

Reported in #5733.

Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.