Skip to content

[PCUI][Bug Fix] Fix access tokens leaking to CloudWatch logs#453

Merged
hehe7318 merged 3 commits intoaws:mainfrom
hehe7318:wip/fix-sensitive-data-leak
Mar 16, 2026
Merged

[PCUI][Bug Fix] Fix access tokens leaking to CloudWatch logs#453
hehe7318 merged 3 commits intoaws:mainfrom
hehe7318:wip/fix-sensitive-data-leak

Conversation

@hehe7318
Copy link
Contributor

Description

Fix a bug that response headers contains Set-Cookie (with access tokens) and Authorization were not filtered before logging, exposing sensitive credentials in CloudWatch.

Changes

  • Filter sensitive headers from request/response logs
  • Add tests to verify sensitive headers are stripped from log output.

How Has This Been Tested?

  • New tests passed.
  • Manually deployed PCUI and conducted testing: Verification confirmed that an access token leak was observable prior to the fix, but the issue no longer occurred after the fix was applied.

PR Quality Checklist

  • I added tests to new or existing code
  • I removed hardcoded strings and used react-i18next library (useTranslation hook and/or Trans component), see an example here
  • I made sure no sensitive info gets logged at any time in the codebase (see here) (e.g. no user info or details, no stacktraces, etc.)
  • I made sure that any GitHub issue solved by this PR is correctly linked
  • I checked that infrastructure/update_infrastructure.sh runs without any error
  • I checked that npm run build builds without any error
  • I checked that clusters are listed correctly
  • I checked that a new cluster can be created (config is produced and dry run passes)
  • I checked that login and logout work as expected

In order to increase the likelihood of your contribution being accepted, please make sure you have read both the Contributing Guidelines and the Project Guidelines

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

_headers.pop('Cookie', None)
_headers.pop('X-CSRF-Token', None)
for header in SENSITIVE_HEADERS:
_headers.pop(header, None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This removal is case sensitive, but HTTP are case insensitive.
I suggest to remove in a case insensitive fashion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

'Cookie',
'Set-Cookie',
'X-CSRF-Token',
'Authorization',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch to exclude the authorization header as well!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

headers = {
'Content-Type': 'application/json',
'Cookie': 'accessToken=eyJsecrettoken',
'Set-Cookie': 'accessToken=eyJsecrettoken; Secure; HttpOnly',
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you agreeew with my comment on case insensitivity, then let;s adapt the test to verify that ther rmeoval is canse insensitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@hehe7318 hehe7318 force-pushed the wip/fix-sensitive-data-leak branch from 247c71b to 6d47700 Compare March 16, 2026 19:31
@hehe7318 hehe7318 merged commit 8a25363 into aws:main Mar 16, 2026
2 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.

2 participants