fix(s3-deployment): sanitize all log outputs to mitigate CWE-117/93#37670
fix(s3-deployment): sanitize all log outputs to mitigate CWE-117/93#37670jonmiller-iv wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
|
Exemption Request This fix modifies only the Python runtime handler ( An integration test would not validate this change, as the fix affects runtime log sanitization only (no change to deployed infrastructure). Unit tests have been added and updated to cover the new sanitization behavior. The prior merged fix for this same issue (#30746) also only modified |
|
bump to p1 in consist with the issue. |
|
@ Affected tests:
I don't have a CDK integ-test deploy environment set up. "Allow edits from maintainers" is enabled — happy to have someone regen via the internal pipeline, or guide me through the right exemption flow. |
Issue
Closes #37671.
Reason for this change
The partial fix in #30746 only applied
sanitize_message()to 2 log statements (s3_destandold_s3_dest). AWS Inspector continues to flag theCustomCDKBucketDeploymentLambda with CWE-117/93 findings because several other log outputs still use unsanitized user-controlled input.Related prior issues: #28469, #30211
Description of changes
sanitize_message()usage to all remaining unsanitized log outputs inindex.py:cfn_error— now usessanitize_message()instead ofmessage.encode()sanitize_message()aws_command— CLI args logged viasanitize_message()cfn_send— response body logged viasanitize_message()sanitize_message()to handle non-string inputs (dicts, lists) by converting to string before sanitizingDescription of how you validated changes
test_error_loggerandtest_error_logger_encoding_inputto match new sanitized output formattest_error_logger_crlf_injection— verifies\r\ncharacters are stripped from error log outputtest_sanitize_message_non_string— verifies dict inputs are converted and sanitizedtest_sanitize_message_none— verifiesNonepassthroughBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license