-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(aws): add bedrock_full_access_policy_attached security check #10577
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
Open
danibarranqueroo
wants to merge
3
commits into
master
Choose a base branch
from
feat/prowler-630-bedrock-full-access-policy-attached
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
43 changes: 43 additions & 0 deletions
43
...ock/bedrock_full_access_policy_attached/bedrock_full_access_policy_attached.metadata.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| { | ||
| "Provider": "aws", | ||
| "CheckID": "bedrock_full_access_policy_attached", | ||
| "CheckTitle": "IAM role does not have AmazonBedrockFullAccess managed policy attached", | ||
| "CheckType": [ | ||
| "Software and Configuration Checks/AWS Security Best Practices", | ||
| "Software and Configuration Checks/Industry and Regulatory Standards/AWS Foundational Security Best Practices" | ||
| ], | ||
| "ServiceName": "bedrock", | ||
| "SubServiceName": "", | ||
| "ResourceIdTemplate": "", | ||
| "Severity": "high", | ||
| "ResourceType": "AwsIamRole", | ||
| "ResourceGroup": "IAM", | ||
| "Description": "**IAM roles** (excluding service roles) are evaluated for attachment of the AWS-managed `AmazonBedrockFullAccess` policy.\n\nThis policy grants unrestricted access to all Amazon Bedrock actions and resources.", | ||
| "Risk": "The `AmazonBedrockFullAccess` policy grants broad permissions across all Bedrock resources. If a role with this policy is compromised, an attacker could:\n- Invoke any model to exfiltrate data or generate harmful content\n- Modify guardrails, logging, and security configurations\n- Incur significant costs through unrestricted model invocations", | ||
| "RelatedUrl": "", | ||
| "AdditionalURLs": [ | ||
| "https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html", | ||
| "https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege" | ||
| ], | ||
| "Remediation": { | ||
| "Code": { | ||
| "CLI": "aws iam detach-role-policy --role-name <ROLE_NAME> --policy-arn arn:aws:iam::aws:policy/AmazonBedrockFullAccess", | ||
| "NativeIaC": "```yaml\n# CloudFormation: IAM Role without AmazonBedrockFullAccess\nResources:\n <example_resource_name>:\n Type: AWS::IAM::Role\n Properties:\n AssumeRolePolicyDocument:\n Version: '2012-10-17'\n Statement:\n - Effect: Allow\n Principal:\n Service: ec2.amazonaws.com\n Action: sts:AssumeRole\n ManagedPolicyArns: [] # Critical: ensure AmazonBedrockFullAccess is NOT attached\n```", | ||
| "Other": "1. Open the AWS Console and go to IAM > Roles\n2. Select the role flagged by the check\n3. On the Permissions tab, find \"AmazonBedrockFullAccess\" under Attached policies\n4. Click Detach next to \"AmazonBedrockFullAccess\"\n5. Confirm the detach\n6. Attach a scoped policy granting only required Bedrock actions", | ||
| "Terraform": "```hcl\n# IAM Role without AmazonBedrockFullAccess\nresource \"aws_iam_role\" \"<example_resource_name>\" {\n assume_role_policy = <<POLICY\n{\n \"Version\": \"2012-10-17\",\n \"Statement\": [{\n \"Effect\": \"Allow\",\n \"Principal\": {\"Service\": \"ec2.amazonaws.com\"},\n \"Action\": \"sts:AssumeRole\"\n }]\n}\nPOLICY\n\n managed_policy_arns = [] # Critical: ensures AmazonBedrockFullAccess is NOT attached\n}\n```" | ||
| }, | ||
| "Recommendation": { | ||
| "Text": "Apply **least privilege**: replace `AmazonBedrockFullAccess` with a custom policy granting only the specific Bedrock actions required.\n\nUse **permissions boundaries** and **SCPs** to limit the scope of Bedrock permissions. Regularly review access with **IAM Access Analyzer** to identify and remove unused privileges.", | ||
| "Url": "https://hub.prowler.com/check/bedrock_full_access_policy_attached" | ||
| } | ||
| }, | ||
| "Categories": [ | ||
| "gen-ai", | ||
| "identity-access" | ||
| ], | ||
| "DependsOn": [], | ||
| "RelatedTo": [ | ||
| "iam_role_administratoraccess_policy" | ||
| ], | ||
| "Notes": "" | ||
| } |
37 changes: 37 additions & 0 deletions
37
...rvices/bedrock/bedrock_full_access_policy_attached/bedrock_full_access_policy_attached.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from prowler.lib.check.models import Check, Check_Report_AWS | ||
| from prowler.providers.aws.services.iam.iam_client import iam_client | ||
|
|
||
|
|
||
| class bedrock_full_access_policy_attached(Check): | ||
| """Ensure that IAM roles do not have the AmazonBedrockFullAccess managed policy attached. | ||
|
|
||
| This check evaluates whether IAM roles (excluding service roles) have the | ||
| AmazonBedrockFullAccess AWS-managed policy attached, which grants excessive | ||
| permissions and violates the principle of least privilege. | ||
| - PASS: The IAM role does not have the AmazonBedrockFullAccess policy attached. | ||
| - FAIL: The IAM role has the AmazonBedrockFullAccess policy attached. | ||
| """ | ||
|
|
||
| def execute(self) -> list[Check_Report_AWS]: | ||
| """Execute the check logic. | ||
|
|
||
| Returns: | ||
| A list of reports containing the result of the check. | ||
| """ | ||
| findings = [] | ||
| if iam_client.roles: | ||
| for role in iam_client.roles: | ||
| if not role.is_service_role: | ||
| report = Check_Report_AWS( | ||
| metadata=self.metadata(), resource=role | ||
| ) | ||
| report.region = iam_client.region | ||
| report.status = "PASS" | ||
| report.status_extended = f"IAM Role {role.name} does not have AmazonBedrockFullAccess policy attached." | ||
| for policy in role.attached_policies: | ||
| if policy["PolicyName"] == "AmazonBedrockFullAccess": | ||
| report.status = "FAIL" | ||
| report.status_extended = f"IAM Role {role.name} has AmazonBedrockFullAccess policy attached." | ||
| break | ||
| findings.append(report) | ||
| return findings | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is supposed to detect the AWS-managed
AmazonBedrockFullAccesspolicy, but the current implementation only matches onPolicyName. That can lead to false positives if a customer-managed policy exists with the same name. Matching onPolicyArnmakes the check precise and ensures it only flags the AWS-managed policy described in the metadata and remediation.