4.2 Ensure Fine-Grained Access Control is implemented
Description
Fine-Grained Access Control (FGAC) on Amazon DynamoDB allows you to control access to data at the row level. Using IAM policies, you can restrict access based on the content within the request. Here is how you can implement FGAC:
Rationale
Fine-Grained access control helps users to create and allow specific permission within that DB.
Impact
N/A
Audit Procedure
Using AWS Console
Create an IAM Role
- Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
- In the navigation pane, choose
Roles and select Create role.
- Choose
AWS service as the type of trusted entity.
- Choose
DynamoDB as the service that will use this role, then click Next: Permissions.
- On the
Attach permissions policies page, choose Next: Tags. You do not need to attach a policy to this role yet.
- On the
Add tags page, choose Next: Review.
- On the
Review page, for Role name, enter a name for your role, such as DynamoDBFineGrainedAccessRole.
- Choose
Create role.
Create an IAM Policy for Fine-Grained Access Control
- In the navigation pane, choose
Policies and select Create policy.
- Choose the
JSON tab.
- Paste the following policy into the policy document field, replacing
us-west-2, 123456789012, myddbtable, HK, and RANGEK with your own values:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:BatchGetItem",
"dynamodb:Query",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem"
],
"Resource": "arn:aws:dynamodb:<us-west-2:123456789012:table/myddbtable>",
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:LeadingKeys": ["${www.amazon.com:user_id}"],
"dynamodb:Attributes": ["<HK>", "<RANGEK>"]
},
"StringEqualsIfExists": {
"dynamodb:Select": "SPECIFIC_ATTRIBUTES"
}
}
}
]
}
In this policy:
dynamodb:LeadingKeys restrict access to only the items where the hash key value is the same as the user's ID.
dynamodb:Attributes restrict access to only the "HK" and "RANGEK" attributes of the items.
dynamodb:Select only allows the SPECIFIC_ATTRIBUTES operator.
- Choose
Next: Tags, add any tags if needed, and then choose Next: Review.
- For
Name, enter a name for your policy, such as DynamoDBFineGrainedAccessPolicy.
- Choose
Create policy.
- Attach the Policy to the Role
- In the navigation pane, choose
Roles.
- Choose the role that you created in the previous step.
- On the
Permissions tab, choose Attach policies.
- In the
Filter policies search box, enter the policy name you created before.
- Select the check box for your policy, then choose
Attach policy.
Note: Fine-grained access control is a powerful feature but can be complex to configure. Be sure to test your setup to ensure it works as expected thoroughly.
Expected Result
Fine-Grained Access Control policies are in place restricting DynamoDB access at the row level based on user identity.
Remediation
Using AWS Console
Follow the same steps as the audit procedure to create IAM roles and policies for Fine-Grained Access Control.
Default Value
By default, Fine-Grained Access Control is not implemented. IAM policies grant table-level access.
References
- https://aws.amazon.com/products/databases/
CIS Controls
| Controls Version |
Control |
IG 1 |
IG 2 |
IG 3 |
| v8 |
3.3 Configure Data Access Control Lists |
x |
x |
x |
| v7 |
14.6 Protect Information through Access Control Lists |
x |
x |
x |
Profile
Level 1 | Manual
1---2name: cis-aws-database-4-23description: Ensure Fine-Grained Access Control is implemented4---56# 4.2 Ensure Fine-Grained Access Control is implemented78## Description910Fine-Grained Access Control (FGAC) on Amazon DynamoDB allows you to control access to data at the row level. Using IAM policies, you can restrict access based on the content within the request. Here is how you can implement FGAC:1112## Rationale1314Fine-Grained access control helps users to create and allow specific permission within that DB.1516## Impact1718N/A1920## Audit Procedure2122### Using AWS Console23241. Create an IAM Role25 - Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.26 - In the navigation pane, choose `Roles` and select `Create role`.27 - Choose `AWS service` as the type of trusted entity.28 - Choose `DynamoDB` as the service that will use this role, then click `Next: Permissions`.29 - On the `Attach permissions policies` page, choose `Next: Tags`. You do not need to attach a policy to this role yet.30 - On the `Add tags` page, choose `Next: Review`.31 - On the `Review` page, for `Role name`, enter a name for your role, such as DynamoDBFineGrainedAccessRole.32 - Choose `Create role`.33342. Create an IAM Policy for Fine-Grained Access Control35 - In the navigation pane, choose `Policies` and select `Create policy`.36 - Choose the `JSON` tab.37 - Paste the following policy into the policy document field, replacing `us-west-2`, `123456789012`, `myddbtable`, `HK`, and `RANGEK` with your own values:3839```json40{41 "Version": "2012-10-17",42 "Statement": [43 {44 "Effect": "Allow",45 "Action": [46 "dynamodb:GetItem",47 "dynamodb:BatchGetItem",48 "dynamodb:Query",49 "dynamodb:PutItem",50 "dynamodb:UpdateItem",51 "dynamodb:DeleteItem"52 ],53 "Resource": "arn:aws:dynamodb:<us-west-2:123456789012:table/myddbtable>",54 "Condition": {55 "ForAllValues:StringEquals": {56 "dynamodb:LeadingKeys": ["${www.amazon.com:user_id}"],57 "dynamodb:Attributes": ["<HK>", "<RANGEK>"]58 },59 "StringEqualsIfExists": {60 "dynamodb:Select": "SPECIFIC_ATTRIBUTES"61 }62 }63 }64 ]65}66```6768In this policy:6970- `dynamodb:LeadingKeys` restrict access to only the items where the hash key value is the same as the user's ID.71- `dynamodb:Attributes` restrict access to only the "HK" and "RANGEK" attributes of the items.72- `dynamodb:Select` only allows the `SPECIFIC_ATTRIBUTES` operator.73- Choose `Next: Tags`, add any tags if needed, and then choose `Next: Review`.74- For `Name`, enter a name for your policy, such as DynamoDBFineGrainedAccessPolicy.75- Choose `Create policy`.76773. Attach the Policy to the Role78 - In the navigation pane, choose `Roles`.79 - Choose the role that you created in the previous step.80 - On the `Permissions` tab, choose `Attach policies`.81 - In the `Filter policies` search box, enter the policy name you created before.82 - Select the check box for your policy, then choose `Attach policy`.8384**Note**: Fine-grained access control is a powerful feature but can be complex to configure. Be sure to test your setup to ensure it works as expected thoroughly.8586## Expected Result8788Fine-Grained Access Control policies are in place restricting DynamoDB access at the row level based on user identity.8990## Remediation9192### Using AWS Console9394Follow the same steps as the audit procedure to create IAM roles and policies for Fine-Grained Access Control.9596## Default Value9798By default, Fine-Grained Access Control is not implemented. IAM policies grant table-level access.99100## References1011021. https://aws.amazon.com/products/databases/103104## CIS Controls105106| Controls Version | Control | IG 1 | IG 2 | IG 3 |107| ---------------- | ----------------------------------------------------- | ---- | ---- | ---- |108| v8 | 3.3 Configure Data Access Control Lists | x | x | x |109| v7 | 14.6 Protect Information through Access Control Lists | x | x | x |110111## Profile112113Level 1 | Manual