-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(aws): add Bedrock model invocation job CMK check #12801
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
Sipivishta
wants to merge
2
commits into
prowler-cloud:master
Choose a base branch
from
Sipivishta:feat/bedrock-model-invocation-job-cmk
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 1 commit
Commits
Show all changes
2 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
Empty file.
41 changes: 41 additions & 0 deletions
41
...t_encrypted_with_cmk/bedrock_model_invocation_job_output_encrypted_with_cmk.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,41 @@ | ||
| { | ||
| "Provider": "aws", | ||
| "CheckID": "bedrock_model_invocation_job_output_encrypted_with_cmk", | ||
| "CheckTitle": "Bedrock model invocation job output is encrypted with a customer-managed KMS key", | ||
| "CheckType": [ | ||
| "Software and Configuration Checks/AWS Security Best Practices", | ||
| "Software and Configuration Checks/AWS Security Best Practices/Data Encryption" | ||
| ], | ||
| "ServiceName": "bedrock", | ||
| "SubServiceName": "", | ||
| "ResourceIdTemplate": "", | ||
| "Severity": "high", | ||
| "ResourceType": "Other", | ||
| "ResourceGroup": "ai_ml", | ||
| "Description": "Ensure that the S3 output of Amazon Bedrock model invocation jobs is configured to use a customer-managed KMS key.", | ||
| "Risk": "Model invocation job outputs may contain sensitive or confidential data. Without customer-managed KMS key encryption, organizations have less control over the encryption key protecting these S3 outputs.", | ||
| "RelatedUrl": "", | ||
| "AdditionalURLs": [ | ||
| "https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GetModelInvocationJob.html", | ||
| "https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ModelInvocationJobS3OutputDataConfig.html" | ||
| ], | ||
| "Remediation": { | ||
| "Code": { | ||
| "CLI": "", | ||
| "NativeIaC": "", | ||
| "Other": "Configure the Bedrock model invocation job output S3 configuration to use a customer-managed AWS KMS key.", | ||
| "Terraform": "" | ||
| }, | ||
| "Recommendation": { | ||
| "Text": "Configure the S3 output of the Bedrock model invocation job to use a customer-managed KMS key.", | ||
| "Url": "https://hub.prowler.com/check/bedrock_model_invocation_job_output_encrypted_with_cmk" | ||
| } | ||
| }, | ||
| "Categories": [ | ||
| "gen-ai", | ||
| "encryption" | ||
| ], | ||
| "DependsOn": [], | ||
| "RelatedTo": [], | ||
| "Notes": "The check passes when s3EncryptionKeyId is present in the model invocation job S3 output configuration. If the required job details cannot be retrieved, the finding is reported as MANUAL." | ||
| } | ||
83 changes: 83 additions & 0 deletions
83
...n_job_output_encrypted_with_cmk/bedrock_model_invocation_job_output_encrypted_with_cmk.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,83 @@ | ||
| from prowler.lib.check.models import Check, Check_Report_AWS | ||
| from prowler.providers.aws.services.bedrock.bedrock_client import ( | ||
| bedrock_client, | ||
| ) | ||
|
|
||
|
|
||
| class bedrock_model_invocation_job_output_encrypted_with_cmk(Check): | ||
| """Ensure Bedrock model invocation job outputs use a customer-managed KMS | ||
| key.""" | ||
|
|
||
| def execute(self) -> list[Check_Report_AWS]: | ||
| """Execute the check. | ||
|
|
||
| Returns: | ||
| A list of reports containing the result of the check. | ||
| """ | ||
| findings = [] | ||
|
|
||
| # If listing model invocation jobs failed in a region, | ||
| # we cannot determine the encryption status of jobs in that region. | ||
| for region, error in sorted( | ||
| bedrock_client.model_invocation_jobs_scan_errors.items() | ||
| ): | ||
| report = Check_Report_AWS( | ||
| metadata=self.metadata(), | ||
| resource={"region": region}, | ||
| ) | ||
| report.region = region | ||
| report.resource_id = "model-invocation-job/unknown" | ||
| report.resource_arn = ( | ||
| f"arn:{bedrock_client.audited_partition}:bedrock:" | ||
| f"{region}:{bedrock_client.audited_account}:" | ||
| "model-invocation-job/unknown" | ||
| ) | ||
| report.status = "MANUAL" | ||
| report.status_extended = ( | ||
| f"Bedrock model invocation jobs could not be listed in region " | ||
| f"{region} ({error}); verify manually that every model " | ||
| "invocation job output uses a customer-managed KMS key." | ||
| ) | ||
| findings.append(report) | ||
|
|
||
| # Evaluate each discovered model invocation job. | ||
| for job in bedrock_client.model_invocation_jobs.values(): | ||
| report = Check_Report_AWS( | ||
| metadata=self.metadata(), | ||
| resource=job, | ||
| ) | ||
|
|
||
| # If GetModelInvocationJob failed, the encryption configuration | ||
| # cannot be determined. Never report PASS in this situation. | ||
| if not job.detail_retrieved: | ||
| report.status = "MANUAL" | ||
| report.status_extended = ( | ||
| f"Bedrock model invocation job {job.name} " | ||
| f"output encryption configuration could not be " | ||
| f"retrieved in region {job.region}; verify manually " | ||
| "that the S3 output uses a customer-managed KMS key." | ||
| ) | ||
|
|
||
| # A present s3EncryptionKeyId indicates that the S3 output | ||
| # configuration specifies a KMS encryption key. | ||
| elif job.s3_encryption_key_id: | ||
| report.status = "PASS" | ||
| report.status_extended = ( | ||
| f"Bedrock model invocation job {job.name} S3 output " | ||
| f"is configured with a customer-managed KMS key in " | ||
| f"region {job.region}." | ||
| ) | ||
|
|
||
| # Missing or empty s3EncryptionKeyId means the required | ||
| # customer-managed KMS key is not configured. | ||
| else: | ||
| report.status = "FAIL" | ||
| report.status_extended = ( | ||
| f"Bedrock model invocation job {job.name} S3 output " | ||
| f"is not configured with a customer-managed KMS key " | ||
| f"in region {job.region}." | ||
| ) | ||
|
|
||
| findings.append(report) | ||
|
|
||
| return findings |
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
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.
Uh oh!
There was an error while loading. Please reload this page.