Skip to content

fix : prevent bun response headers from leaking into transaction telemetry#19811

Closed
naaa760 wants to merge 1 commit intogetsentry:developfrom
naaa760:fix/sec-resp-leak-trn-cont
Closed

fix : prevent bun response headers from leaking into transaction telemetry#19811
naaa760 wants to merge 1 commit intogetsentry:developfrom
naaa760:fix/sec-resp-leak-trn-cont

Conversation

@naaa760
Copy link
Contributor

@naaa760 naaa760 commented Mar 15, 2026

  • What: Stop storing Bun response headers on the isolation scope.

  • Why: Response headers (including Set-Cookie) could leak into transaction telemetry.

  • How: Only keep status_code in the Bun response context, no headers.

fix : #19790

Copy link

@cursor cursor bot left a comment

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.

if (response?.status) {
setHttpStatus(span, response.status);
isolationScope.setContext('response', {
headers: response.headers.toJSON(),
Copy link

Choose a reason for hiding this comment

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

Missing regression test for the header leak fix

Low Severity

This fix PR removes response headers from the isolation scope context but does not include a regression test verifying that the response context set via isolationScope.setContext contains only status_code and no headers. A test asserting the absence of headers in the response context would prevent this leak from being reintroduced. The review rules require fix PRs to include at least one test that covers the regression being fixed.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

@Lms24 Lms24 self-requested a review March 16, 2026 11:54
@Lms24
Copy link
Member

Lms24 commented Mar 16, 2026

Hey @naaa760 thanks for opening this PR! I thought about this a bit and while I think removing the unconditional headers object from the event context makes sense, I also think we should collect the response headers more safely as span attributes instead. We can leverage httpHeadersToSpanAttributes to do this, which already has builtin sensitive data and PII protection. I opened #19821 and #19822 (since it turns out we have the same problem in Deno). Gonna close this PR but again, thanks for contributing!

@Lms24 Lms24 closed this Mar 16, 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.

Security Bug Report - Bun response headers leaked via transaction context (Set-Cookie exfiltration)

2 participants