Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/rest: masks X-AMZ-SECURITY-TOKEN header in decision logs #6423

Merged

Conversation

colinjlacy
Copy link
Contributor

@colinjlacy colinjlacy commented Nov 20, 2023

Why the changes in this PR are needed?

Decision logs had previously been configured to hide the value of the Authorization header, as that is considered sensitive information. However, there are cases when additional headers are provided that contain sensitive information, such as the X-AMZ-SECURITY-TOKEN header. These values were being logged in plaintext, despite being equally sensitive.

What are the changes in this PR?

This PR creates an internal map of headers that should be masked, which can be expanded if additional headers are required. It then loops over the headers in a request, and performs a lookup on the internal map to see if any of them match those that should be masked. If so, it replaces their values with "REDACTED". An existing test was added to check both the header keys that should be masked, as well as a key that should not.

An existing test was modified to check both the header keys that should be masked, as well as a test key that should not.

Notes to assist PR review:

Implementation for this change was discussed in this comment.

Nothing else comes to mind. I've got the basics - tests pass, make check went well, etc. If I'm missing something, please let me know.

Further comments:

Additional work, out of scope for this PR, would be to open a config setting that would allow users to pass in a list of headers that should be masked.

Fixes: #5848

(Replaces #6421)

Copy link

netlify bot commented Nov 20, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 7a4824e
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/6567504b6b89aa0008c955db
😎 Deploy Preview https://deploy-preview-6423--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

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

Hey Colin, great to see you here! 👋 I'll let one of the others have a quick look too, but this is mostly looking ready to me.

plugins/rest/rest.go Outdated Show resolved Hide resolved
plugins/rest/rest_test.go Outdated Show resolved Hide resolved
colinjlacy added a commit to colinjlacy/opa that referenced this pull request Nov 22, 2023
This commit addresses the comments in PR open-policy-agent#6423:
- cleans up the test for the modified functionality
- changes method names to better match new functionality
- sets header values with a more explicit hedaer method
- changes the value type in the header key map for better memory usage

Signed-off-by: Colin Lacy <[email protected]>
colinjlacy added a commit to colinjlacy/opa that referenced this pull request Nov 22, 2023
This commit addresses the comments in PR open-policy-agent#6423:
- cleans up the test for the modified functionality
- changes method names to better match new functionality
- sets header values with a more explicit hedaer method
- changes the value type in the header key map for better memory usage

Signed-off-by: Colin Lacy <[email protected]>
@colinjlacy colinjlacy force-pushed the issue-5848-mask-amzn-header branch from 216c799 to b9bef65 Compare November 22, 2023 13:20
Decision logs had previously been configured to hide the value of the
Authorization header, as that is considered sensitive information.
However, there are cases when additional headers are provided that
contain sensitive information, such as the X-AMZ-SECURITY-TOKEN header.
This PR creates an internal map of headers that should be masked, which
can be expanded if additional headers are required. It then loops over
the headers in a request, and performs a lookup on the internal map
to see if any of them match those that should be masked. If so, it
replaces their values with "REDACTED". An existing test was added to
check both the header keys that should be masked, as well as a key
that should not.

Additional work, out of scope for this PR, would be to open a config
setting that would allow users to pass in a list of headers that should
be masked.

Fixes: open-policy-agent#5848

Signed-off-by: Colin Lacy <[email protected]>
This commit addresses the comments in PR open-policy-agent#6423:
- cleans up the test for the modified functionality
- changes method names to better match new functionality
- sets header values with a more explicit hedaer method
- changes the value type in the header key map for better memory usage

Signed-off-by: Colin Lacy <[email protected]>
@anderseknert anderseknert force-pushed the issue-5848-mask-amzn-header branch from b9bef65 to 7a4824e Compare November 29, 2023 14:52
@anderseknert anderseknert merged commit 0b9bbc5 into open-policy-agent:main Nov 29, 2023
23 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.

OPA debug logs expose X-AMZ-SECURITY-TOKEN header
4 participants