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

CDK custom resource CustomCDKBucketDeployment: SecurityHub HIGH notification: CWE-117,93 - Log injection #28469

Closed
eikeon opened this issue Dec 22, 2023 · 2 comments · Fixed by #28599
Labels
@aws-cdk/aws-securityhub Related to AWS Security Hub bug This issue is a bug. effort/small Small work item – less than a day of effort needs-review p1

Comments

@eikeon
Copy link

eikeon commented Dec 22, 2023

Describe the bug

AWS Inspector reports this finding when using aws_s3_deployment.BucketDeployment

Expected Behavior

No AWS Inspector findings from aws_s3_deployment.BucketDeployment

Current Behavior

We're currently getting this one HIGH finding

Reproduction Steps

Have a CDK application that makes use of aws_s3_deployment.BucketDeployment

Possible Solution

The finding suggests the following fix:

@@ -1,2 +1,3 @@
+ with the logs
 os.putenv('AWS_CONFIG_FILE', AWS_CLI_CONFIG_FILE)
 
@@ -4,8 +5,8 @@
 
     def cfn_error(message=None):
-        logger.error("| cfn_error: %s" % message)
+        logger.error("| cfn_error: %s" % urllib.parse.quote(message))
         cfn_send(event, context, CFN_FAILED, reason=message, physicalResourceId=event.get('PhysicalResourceId', None))

Additional Information/Context

No response

CDK CLI Version

2.115.0 (build 58027ee)

Framework Version

No response

Node.js Version

v18.19.0

OS

aws/codebuild/standard:7.0

Language

TypeScript

Language Version

5.3.3

Other information

No response

@eikeon eikeon added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2023
@github-actions github-actions bot added the @aws-cdk/aws-securityhub Related to AWS Security Hub label Dec 22, 2023
@pahud pahud self-assigned this Dec 22, 2023
@pahud
Copy link
Contributor

pahud commented Dec 22, 2023

The suggested fix from SecurityHub is from here:

@pahud pahud added p1 needs-review effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2023
@pahud pahud removed their assignment Dec 22, 2023
paulhcsun added a commit to lpizzinidev/aws-cdk that referenced this issue Jan 30, 2024
paulhcsun added a commit to lpizzinidev/aws-cdk that referenced this issue Feb 22, 2024
@mergify mergify bot closed this as completed in #28599 Feb 23, 2024
mergify bot pushed a commit that referenced this issue Feb 23, 2024
…ulnerability (#28599)

The `bucket-deployment-handler` results vulnerable to [CWE-117](https://cwe.mitre.org/data/definitions/117.html) and [CWE-93](https://cwe.mitre.org/data/definitions/93.html) according to AWS Inspector.
This fix mitigates the vulnerability by sanitizing the logged `message` as suggested on [Veracode](https://community.veracode.com/s/article/How-to-Fix-CWE-117-Improper-Output-Neutralization-for-Logs).

**Note**
Inspector suggestion of using `urllib.parse.quote` would produce unreadable messages, so I opted for `encoded`.

Closes #28469.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-securityhub Related to AWS Security Hub bug This issue is a bug. effort/small Small work item – less than a day of effort needs-review p1
Projects
None yet
2 participants