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

(DynamoDB): Table generates policies not compliant with Security Hub #20545

Open
nekvinder opened this issue May 30, 2022 · 2 comments
Open

(DynamoDB): Table generates policies not compliant with Security Hub #20545

nekvinder opened this issue May 30, 2022 · 2 comments
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB ddb-legacy-table This issue has to do with DynamoDB's legacy Table construct. Close after migration guide is out. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@nekvinder
Copy link

nekvinder commented May 30, 2022

Describe the bug

Aws CDK's DynamoDB Table generated resources are not compliant with Security Hub policy IAM.21 - https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-fsbp-controls.html#fsbp-iam-21

The CDK generates a policy with wildcard actions for dynamodb actions as dynamodb:*
The following are the related policy description: DynamoDB replication managed policy for table <table_name>

const onEventHandlerPolicy = new SourceTableAttachedPolicy(this, provider.onEventHandler.role!);
const isCompleteHandlerPolicy = new SourceTableAttachedPolicy(this, provider.isCompleteHandler.role!);
// Permissions in the source region
this.grant(onEventHandlerPolicy, 'dynamodb:*');

Expected Behavior

The attached policies should describe each required action in them.

Current Behavior

The CDK generates a policy with wildcard actions for dynamodb actions as dynamodb:*

Reproduction Steps

  • Use AWS CDK to create a dynamodb table
    const globalTable = new dynamodb.Table(this, 'Table', {
      partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
      replicationRegions: ['us-east-1', 'eu-central-1'],
      billingMode: dynamodb.BillingMode.PROVISIONED,
    });
    
  • Go to AWS Security Hub and watch the above-created resource, it would be non compliant with Security Hub Policy - securityhub-iam-policy-no-statements-with-full-access-****** (arn:aws:config:::config-rule/aws-service-rule/securityhub.amazonaws.com/config-rule-nn****)**

Possible Solution

Put the exact actions required here.

this.grant(onEventHandlerPolicy, 'dynamodb:*');

Additional Information/Context

No response

CDK CLI Version

2.20.0

Framework Version

No response

Node.js Version

14.19.1

OS

Ubuntu 22.04 LTS

Language

Typescript

Language Version

3.9.7

Other information

No response

@nekvinder nekvinder added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 30, 2022
@github-actions github-actions bot added the @aws-cdk/aws-dynamodb Related to Amazon DynamoDB label May 30, 2022
@peterwoodworth peterwoodworth changed the title dynamodb: (DynamoDB): Table generates policies not compliant with Security Hub Jun 1, 2022
@peterwoodworth peterwoodworth added p1 feature-request A feature should be added or improved. effort/medium Medium work item – several days of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 1, 2022
@watany-dev
Copy link
Contributor

After checking the corresponding function, I think that it will probably work if the following two actions are added. i will embark on this.

watany-dev added a commit to watany-dev/aws-cdk that referenced this issue Aug 19, 2022
@Naumel Naumel removed their assignment Jun 28, 2023
@rix0rrr
Copy link
Contributor

rix0rrr commented Sep 21, 2023

This issue was for the existing Table construct, which used custom resources to implement table replication. We no longer recommend the use of the Table construct.

Instead, the TableV2 construct has been released in 2.95.1 (#27023) which maps to the AWS::DynamoDB::GlobalTable resource, has better support for replication and does not suffer from the issue described here.


Be aware that there are additional deployment steps involved in a migration from Table to TableV2. You need to do a RETAIN deployment, a delete deployment, then change the code to use TableV2 and then use cdk import. A link to a full guide will be posted once it is available.

Here are some other resources to get you started (using CfnGlobalTable instead of TableV2) if you want to get going on the migration:

@rix0rrr rix0rrr added the ddb-legacy-table This issue has to do with DynamoDB's legacy Table construct. Close after migration guide is out. label Sep 21, 2023
@pahud pahud added p2 and removed p1 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB ddb-legacy-table This issue has to do with DynamoDB's legacy Table construct. Close after migration guide is out. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants