Skip to content

fix(pii): Correctly handle cookies - #6380

Merged
loewenheim merged 3 commits into
masterfrom
sebastian/cookies-pii
Sep 15, 2026
Merged

loewenheim merged 3 commits into
masterfrom
sebastian/cookies-pii

Conversation

@loewenheim

@loewenheim loewenheim commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

In #5456 we made cookie scrubbing overzealous—applying "@anything:filter" to http.request.header.cookie leads to that field always being completely deleted, even if it is an array that only contains some sensitive cookies, or none at all.

Instead, we go back to the previous behavior of only applying "@anything:filter" to individual sensitive cookies, and handle the catch-all key with a separate rule that matches a regex.

Fixes RELAY-279. Fixes #6371.

In #5456 we made cookie scrubbing
overzealous—applying `"@anything:filter"` to `http.request.header.cookie`
leads to that field always being completely deleted, even if it is an
array that only contains _some_ sensitive cookies.

Instead, we go back to the previous behavior of only applying
`"@anything:filter"` to _individual_ sensitive cookies, and handling
the catch-all key with a separate rule that matches a regex.

Fixes RELAY-279. Fixes #6371.
@loewenheim
loewenheim requested a review from a team as a code owner September 14, 2026 16:26
@linear-code

linear-code Bot commented Sep 14, 2026

Copy link
Copy Markdown

RELAY-279

Comment thread relay-pii/src/regexes.rs Resolved
{
"data": {
"http.request.header.cookie": "[Filtered]",
"http.request.header.cookie": "session=[Filtered]",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually better than before even for existing cases.

"": {
"rem": [
[
"@anything:filter",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One small blemish on this fix is that cookies will now sometimes be marked as @anything:filter and sometimes as cookies:filter, depending on whether they were sent individually or as part of a collection. I can't see an easy fix for this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cookies:filter provides more information to the user so I think this is fine.

Comment thread relay-pii/src/regexes.rs

pub static ANYTHING_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(".*").unwrap());

pub static SENSITIVE_COOKIE_NAMES: &[&str] = &[

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This list needs to live somewhere; both this file and convert.rs need it. Not sure where it's better to put it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 36af3eb. Configure here.

Comment thread relay-pii/src/regexes.rs Resolved
Comment thread relay-pii/src/regexes.rs Resolved
"": {
"rem": [
[
"@anything:filter",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cookies:filter provides more information to the user so I think this is fine.

@loewenheim
loewenheim added this pull request to the merge queue Sep 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 15, 2026
@loewenheim
loewenheim added this pull request to the merge queue Sep 15, 2026
Merged via the queue into master with commit 9817a00 Sep 15, 2026
36 checks passed
@loewenheim
loewenheim deleted the sebastian/cookies-pii branch September 15, 2026 11:09
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.

Handle http.(request|response).header.cookie like other string array attributes

2 participants