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

feat(bedrock): add checks for guardrails configuration and log encryption #5385

Merged
merged 14 commits into from
Oct 14, 2024

Conversation

sergargar
Copy link
Member

Context

This PR addresses security concerns for Amazon Bedrock by introducing three new checks to strengthen protection against prompt attacks, sensitive data exposure, and log security. These checks aim to mitigate the risks associated with generative AI infrastructures being targeted by adversaries.

Description

This PR adds the following three checks:

  • bedrock_guardrail_prompt_attack_filter_enabled
    Ensures the prompt attack filter is set to the highest strength to protect models from malicious prompts.

  • bedrock_guardrail_sensitive_information_filter_enabled
    Verifies sensitive information filters are enabled to prevent data leakage in model outputs.

  • bedrock_model_invocation_logs_encryption_enabled
    Ensures invocation logs are encrypted with AWS KMS to protect sensitive log data from unauthorized access.

These checks enhance Bedrock's security and data protection.

Checklist

License

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

@sergargar sergargar requested review from a team as code owners October 11, 2024 19:08
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Oct 11, 2024
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 97.45763% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.44%. Comparing base (3c929bd) to head (a50114f).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
.../providers/aws/services/bedrock/bedrock_service.py 94.28% 2 Missing ⚠️
...ders/aws/services/cloudwatch/cloudwatch_service.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #5385    +/-   ##
========================================
  Coverage   89.43%   89.44%            
========================================
  Files        1027     1030     +3     
  Lines       31531    31641   +110     
========================================
+ Hits        28200    28301   +101     
- Misses       3331     3340     +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

for filter in guardrail_info.get("contentPolicy", {}).get("filters", []):
if filter.get("type") == "PROMPT_ATTACK":
guardrail.prompt_attack_filter_strength = filter.get(
"inputStrength", None
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"inputStrength", None
"inputStrength", "NONE"

)


def mock_make_api_call(self, operation_name, kwarg):
Copy link
Member

Choose a reason for hiding this comment

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

I believe that functions should use a name more characteristic of their behaviour than v2 and v3.

return make_api_call(self, operation_name, kwarg)


def mock_make_api_call_v2(self, operation_name, kwarg):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def mock_make_api_call_v2(self, operation_name, kwarg):
def mock_make_api_call_no_filters(self, operation_name, kwarg):

return make_api_call(self, operation_name, kwarg)


def mock_make_api_call_v3(self, operation_name, kwarg):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def mock_make_api_call_v3(self, operation_name, kwarg):
def mock_make_api_call_filter_strength_low(self, operation_name, kwarg):

)


def mock_make_api_call(self, operation_name, kwarg):
Copy link
Member

Choose a reason for hiding this comment

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

Please could change all the mock_make_api_call_vX in all tests for more descriptive names.

@sergargar
Copy link
Member Author

@puchy22, changes done in a50114f

Copy link
Member

@puchy22 puchy22 left a comment

Choose a reason for hiding this comment

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

Awesome!! 💯

@sergargar sergargar merged commit aef4a68 into master Oct 14, 2024
11 checks passed
@sergargar sergargar deleted the PRWLR-5014-add-more-aws-bedrock-checks branch October 14, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants