Skip to content

fix(replay)!: Filter captured network headers - #8566

Draft
philprime wants to merge 2 commits into
ref/data-collection-remove-inert-optionsfrom
fix/replay-sensitive-network-headers
Draft

fix(replay)!: Filter captured network headers#8566
philprime wants to merge 2 commits into
ref/data-collection-remove-inert-optionsfrom
fix/replay-sensitive-network-headers

Conversation

@philprime

Copy link
Copy Markdown
Member

📜 Description

Replay network header capture now inherits dataCollection.httpHeaders and dataCollection.cookies by default. Request and response directions remain independent, parsed cookies are serialized separately, and malformed cookie values use the whole-value "[Filtered]" fallback.

The gated Replay header API now uses NetworkHeaderCapture:

  • .inherit follows global header and cookie collection.
  • .headers([...]) selects exactly the listed headers as an integration-level override.

Explicit Replay selection overrides global header selection, including global .off, but it cannot disable the built-in sensitive denylist. Authorization, X-Auth-Token, X-API-Key, and other partial case-insensitive matches are always filtered.

The stable array API and its default-header merge behavior remain unchanged outside the gated code.

💡 Motivation and Context

Replay previously selected configured headers and serialized their values unchanged, which allowed integration overrides to expose credentials and raw cookie values. This aligns Replay with the data-collection specification's integration precedence and mandatory filtering requirements.

Fixes #8554

💚 How did you test it?

  • make format
  • make analyze
  • make generate-public-api
  • make build-ios-v10 FOR_AGENTS=true
  • make build-macos-v10 FOR_AGENTS=true
  • make test-ios-v10 FOR_AGENTS=true ONLY_TESTING=SentryTests/SentryReplayOptionsTests,SentryTests/SentryReplayOptionsNetworkTests,SentryTests/SentryReplayNetworkDetailsHeaderTests,SentryTests/SentryReplayNetworkDetailsIntegrationTests,SentryTests/SentryNetworkTrackerTests
  • make test-ios FOR_AGENTS=true ONLY_TESTING=SentryTests/SentryReplayOptionsTests,SentryTests/SentryReplayOptionsNetworkTests,SentryTests/SentryReplayNetworkDetailsHeaderTests,SentryTests/SentryReplayNetworkDetailsIntegrationTests,SentryTests/SentryNetworkTrackerTests
  • make test-macos-v10 FOR_AGENTS=true TEST_SCHEME=SentryObjCTests ONLY_TESTING=SentryObjCTests/SentryObjCReplayOptionsTests

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • If I added a new public API, I also added it to the SentryObjC wrapper.

Make Replay header capture inherit global data collection by default and use explicit integration overrides when configured. Always filter sensitive header and cookie values before serialization.  BREAKING CHANGE: Gated Replay request and response header options now use NetworkHeaderCapture instead of arrays.  Fixes #8554
@philprime philprime self-assigned this Jul 24, 2026
@philprime philprime added the run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request label Jul 24, 2026
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- Filter captured network headers ([#8566](https://github.com/getsentry/sentry-cocoa/pull/8566))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against af21188

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Swift/Networking/SentryNetworkTracker.swift

@sentry

sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.23.0 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1212.11 ms 1244.29 ms 32.18 ms
Size 24.14 KiB 1.26 MiB 1.24 MiB

Baseline results on branch: philprime/typed-swizzling

Startup times

Revision Plain With Sentry Diff
8eb08df 1211.00 ms 1237.21 ms 26.21 ms
88197b2 1228.98 ms 1266.60 ms 37.62 ms
cfbf8df 1217.66 ms 1255.25 ms 37.59 ms
0cae876 1211.96 ms 1240.32 ms 28.36 ms

App size

Revision Plain With Sentry Diff
8eb08df 24.14 KiB 1.25 MiB 1.23 MiB
88197b2 24.14 KiB 1.25 MiB 1.23 MiB
cfbf8df 24.14 KiB 1.25 MiB 1.23 MiB
0cae876 24.14 KiB 1.25 MiB 1.23 MiB

@philprime philprime removed the run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request label Jul 31, 2026
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.

1 participant