Skip to content

Redact cookies and sensitive query parameters in HAR output - #1989

Merged
waldekmastykarz merged 4 commits into
dotnet:mainfrom
waldekmastykarz:fix-1954-har-leaks-cookies
Oct 26, 2026
Merged

waldekmastykarz merged 4 commits into
dotnet:mainfrom
waldekmastykarz:fix-1954-har-leaks-cookies

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Closes #1954

With includeSensitiveInformation: false, HarGeneratorPlugin redacted the Cookie/Set-Cookie headers but still wrote raw values to request.cookies / response.cookies, and left sensitive query-string values in url and queryString.

Changes:

  • Cookie values in request.cookies and response.cookies are replaced with REDACTED (names kept).
  • New Http.SensitiveQueryParameters list (e.g. access_token, id_token, refresh_token, code, client_secret, sig, signature, token, key, api_key, password, AWS/GCS signed-URL params). Matching values are redacted in both queryString and request.url; other parameters keep their original encoding.
  • Behavior with includeSensitiveInformation: true is unchanged.

Tests: added integration tests covering redaction on/off.

When includeSensitiveInformation is false, HarGeneratorPlugin now also
redacts values in the request/response cookies arrays and the values of
sensitive query-string parameters (e.g. access_token, code, sig) in both
the request url and queryString.

Closes dotnet#1954

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0f2a9c39-1efc-48ca-829e-a9fd7f817609
Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:56
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner October 21, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

URL reconstruction can alter non-sensitive parameter names that begin with a literal question mark.

1 open issue
What changed in this PR

Closes gaps in HAR redaction by masking cookies and sensitive query values when sensitive information is excluded.

Changes:

  • Redacts cookie values while retaining names.
  • Adds sensitive query-parameter matching for HAR URLs and query arrays.
  • Tests redaction enabled and disabled.
File Description
DevProxy.Plugins/​Models/​Http.cs Defines sensitive query-parameter names.
DevProxy.Plugins/​Generation/​HarGeneratorPlugin.cs Applies cookie and query-value redaction.
DevProxy.Integration.Tests/​GenerationPluginsIntegrationTests.cs Adds redaction integration tests and helpers.

Review effort: Balanced

Comment thread DevProxy.Plugins/Generation/HarGeneratorPlugin.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Query rebuilding can alter valid non-sensitive parameter names instead of preserving the recorded request.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Static review identified no blocking issues in the focused redaction changes and regression coverage; tests were not executed during this review.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes have no unresolved findings and include regression coverage; tests were not executed during this review.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes address the reported leaks with regression coverage and no identified blocking issues; tests were not executed during this review.

No open issues 🎉

Review effort: Balanced

@waldekmastykarz
waldekmastykarz merged commit f5c131f into dotnet:main Oct 26, 2026
4 checks passed
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.

HarGeneratorPlugin leaks cookies and query secrets with includeSensitiveInformation: false

2 participants