Skip to content

Conversation

@alvazjor
Copy link
Contributor

@alvazjor alvazjor commented Oct 23, 2025

Issue # (if applicable)

Closes #.

Reason for this change

In the @aws-cdk/aws-lambda-go-alpha package, user-controlled inputs in goBuildFlags and commandHooks parameters are executed directly in shell commands. This creates a potential command injection vulnerability that allows malicious CDK templates to execute arbitrary commands during cdk synth or cdk deploy on developer machines and CI/CD systems.

Description of changes

This change adds security warnings for commandHooks and goBuildFlags parameters to alert users about potential command injection risks during bundling. The implementation uses CDK annotations to display standardized warnings when these potentially unsafe bundling options are used.

The solution provides consistent security education through CDK's built-in warning system, alerting users whenever goBuildFlags or commandHooks are specified without blocking execution. This maintains full backward compatibility while ensuring users are aware of security implications.

Documentation has been updated with security warnings in JSDoc comments and README, including cross-platform examples and third-party construct safety guidelines.

Describe any new or updated permissions being added

NA

Description of how you validated changes

Added new unit tests

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team October 23, 2025 14:05
@github-actions github-actions bot added the p2 label Oct 23, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 23, 2025
@alvazjor alvazjor force-pushed the alvazjor/lambda-go-doc-update branch 4 times, most recently from 960fd4f to 8bcea28 Compare October 23, 2025 15:42
test('bundling', () => {
Bundling.bundle({
entry,
runtime: Runtime.GO_1_X,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these really required changes ? Seems like runtime has changed, but we don't do anything that changes the runtime right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just deprecated runtimes, since I originally modified this test, I kept that

@kumvprat kumvprat added the pr/do-not-merge This PR should not be merged at this time. label Oct 23, 2025
@alvazjor alvazjor force-pushed the alvazjor/lambda-go-doc-update branch from 8bcea28 to 84feae4 Compare October 24, 2025 10:07
- Add CDK annotations warning about potential security risks
- Warn when goBuildFlags or commandHooks are used during bundling
- Update documentation with security best practices
- Add tests to verify warning generation
@alvazjor alvazjor force-pushed the alvazjor/lambda-go-doc-update branch from 84feae4 to e62d287 Compare October 24, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr/do-not-merge This PR should not be merged at this time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants