Skip to content

Commit c4ef73a

Browse files
committed
Merge branch 'fix/security-fixes' into 'develop'
Add security suppressions for cfn_nag and checkov findings See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!574
2 parents 784f6e8 + 5ce902b commit c4ef73a

8 files changed

Lines changed: 47 additions & 2 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Deploy Documentation to GitHub Pages
22

3+
# checkov:skip=CKV2_GHA_1: "Permissions are properly scoped - contents:read, pages:write, id-token:write for GitHub Pages deployment"
4+
35
on:
46
push:
57
branches: [main, develop]

iam-roles/cloudformation-management/IDP-Cloudformation-Service-Role.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Resources:
2424
reason: "Suppressing W76: SPCM for IAM policy document is higher than 25"
2525
- id: F3
2626
reason: "Suppressing F3: wildcard action on named services required for cloudformation service role, to allow CRUD on stack respources"
27+
- id: AwsSolutions-IAM5
28+
reason: "Broad permissions required for non-admin users to deploy IDP stacks via delegated CloudFormation service role"
2729
# checkov:skip=CKV_AWS_110: "CloudFormation service role requires IAM permissions to create Lambda execution roles and service-linked roles during stack deployment. Trust policy restricts to cloudformation.amazonaws.com service principal."
2830
# checkov:skip=CKV_AWS_109: "CloudFormation service role requires IAM policy management permissions to attach policies to created roles during infrastructure deployment. Constrained by trust policy."
2931
# checkov:skip=CKV_AWS_108: "CloudFormation service role requires S3/KMS permissions to create and configure encrypted data buckets for the IDP solution. All buckets use customer-managed KMS encryption."

samples/lambda-hook-inference/GENAIIDP-bedrock-proxy/template.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Conditions:
2929
Resources:
3030
BedrockProxyFunction:
3131
Type: AWS::Serverless::Function
32+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (model ID and log level)"
33+
# checkov:skip=CKV_AWS_116: "DLQ not required for sample Lambda hook function - errors handled by IDP pipeline"
34+
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
35+
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency - sample function for demonstration purposes"
3236
Properties:
3337
FunctionName: GENAIIDP-bedrock-proxy
3438
Runtime: python3.12

samples/lambda-hook-inference/GENAIIDP-sagemaker-hook/template.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Conditions:
2828
Resources:
2929
SageMakerHookFunction:
3030
Type: AWS::Serverless::Function
31+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (endpoint name and log level)"
32+
# checkov:skip=CKV_AWS_116: "DLQ not required for sample Lambda hook function - errors handled by IDP pipeline"
33+
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
34+
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency - sample function for demonstration purposes"
3135
Properties:
3236
FunctionName: GENAIIDP-sagemaker-hook
3337
Runtime: python3.12

samples/lambda-hook-inference/template.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Resources:
3030
# =========================================================================
3131
BedrockProxyFunction:
3232
Type: AWS::Serverless::Function
33+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (model ID and log level)"
34+
# checkov:skip=CKV_AWS_116: "DLQ not required for sample Lambda hook function - errors handled by IDP pipeline"
35+
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
36+
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency - sample function for demonstration purposes"
3337
Properties:
3438
FunctionName: GENAIIDP-bedrock-proxy
3539
Runtime: python3.12
@@ -64,6 +68,10 @@ Resources:
6468
# =========================================================================
6569
SageMakerHookFunction:
6670
Type: AWS::Serverless::Function
71+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (endpoint name and log level)"
72+
# checkov:skip=CKV_AWS_116: "DLQ not required for sample Lambda hook function - errors handled by IDP pipeline"
73+
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
74+
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency - sample function for demonstration purposes"
6775
Properties:
6876
FunctionName: GENAIIDP-sagemaker-hook
6977
Runtime: python3.12

scripts/dsr/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def run_command(cmd, cwd=None):
1414
"""Run shell command and return result."""
1515
try:
16-
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
16+
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True) # nosemgrep: python.lang.security.audit.subprocess-shell-true.subprocess-shell-true - command is hardcoded constant from config file, no user input possible
1717
if result.returncode != 0:
1818
print(f"Error running command: {cmd}")
1919
print(f"Error: {result.stderr}")

scripts/sdlc/cfn/codepipeline-s3.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ Resources:
390390
Metadata:
391391
cfn_nag:
392392
rules_to_suppress:
393+
- id: F4
394+
reason: "logs:* used for CodeBuild to manage logs across multiple stacks with dynamic log group names"
393395
- id: W12
394-
reason: "Logs policy requires * resource to create log groups dynamically"
396+
reason: "Wildcard resource required for CloudWatch Logs to create log groups dynamically across different stacks"
395397
# checkov:skip=CKV_AWS_111: "CloudWatch Logs policies require write access for log creation"
396398
Properties:
397399
PolicyName: CodeBuildLogs
@@ -422,6 +424,15 @@ Resources:
422424

423425
CodeBuildKMSPolicy:
424426
Type: 'AWS::IAM::Policy'
427+
Metadata:
428+
cfn_nag:
429+
rules_to_suppress:
430+
- id: F4
431+
reason: "Broad KMS permissions required for stack life cycle in pipeline account"
432+
- id: W12
433+
reason: "KMS operations require wildcard resource for key discovery during stack deployment."
434+
# checkov:skip=CKV_AWS_111: "Write access required for KMS key management during stack deployment and teardown in SDLC pipeline"
435+
# checkov:skip=CKV_AWS_109: "Wildcard KMS permissions required for dynamic key discovery and management across multiple stacks in pipeline account"
425436
Properties:
426437
PolicyName: CodeBuildKMSAccess
427438
Roles:

template.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,12 @@ Resources:
970970
reason: "Function does not require VPC access as it only interacts with AWS services via APIs"
971971
- id: W92
972972
reason: "Function does not require reserved concurrency as it scales based on demand"
973+
- id: F38
974+
reason: "PassRole permission is required to delegate the execution role to the Bedrock AgentCore Gateway service securely"
975+
- id: F3
976+
reason: "Wildcard actions required for AgentCore Gateway lifecycle management (create, update, delete) and CloudWatch Logs delivery configuration"
977+
- id: W11
978+
reason: "Wildcard resource required as AgentCore Gateway ARNs are dynamically generated and unknown at deployment time"
973979
# checkov:skip=CKV_AWS_116: "DLQ not required for Cfn Custom Resource function"
974980
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
975981
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency as it scales based on demand"
@@ -1092,6 +1098,7 @@ Resources:
10921098
# checkov:skip=CKV_AWS_116: "DLQ not required for Cfn Custom Resource function"
10931099
# checkov:skip=CKV_AWS_117: "Function does not require VPC access"
10941100
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency"
1101+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (log level only)"
10951102
Properties:
10961103
PermissionsBoundary:
10971104
!If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
@@ -3031,6 +3038,7 @@ Resources:
30313038
# checkov:skip=CKV_AWS_116: "DLQ not required for Custom Resource function"
30323039
# checkov:skip=CKV_AWS_117: "Function does not require VPC access"
30333040
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency"
3041+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (log level only)"
30343042
Properties:
30353043
PermissionsBoundary:
30363044
!If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
@@ -4920,6 +4928,7 @@ Resources:
49204928
# checkov:skip=CKV_AWS_116: "DLQ not required for capacity planning function"
49214929
# checkov:skip=CKV_AWS_117: "Function does not require VPC access"
49224930
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency"
4931+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (log level and feature flags)"
49234932
Properties:
49244933
PermissionsBoundary:
49254934
!If [
@@ -4998,6 +5007,7 @@ Resources:
49985007
# checkov:skip=CKV_AWS_116: "DLQ not required"
49995008
# checkov:skip=CKV_AWS_117: "VPC not required"
50005009
# checkov:skip=CKV_AWS_115: "Reserved concurrency not required"
5010+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (log level only)"
50015011
Properties:
50025012
PermissionsBoundary:
50035013
!If [
@@ -6205,6 +6215,7 @@ Resources:
62056215
# checkov:skip=CKV_AWS_116: "DLQ configured for SQS triggered function"
62066216
# checkov:skip=CKV_AWS_117: "Function does not require VPC access as it only interacts with AWS services via APIs"
62076217
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency as it scales based on demand"
6218+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (bucket names and log level)"
62086219
Properties:
62096220
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
62106221
Handler: index.handler
@@ -6749,6 +6760,7 @@ Resources:
67496760
# checkov:skip=CKV_AWS_116: "DLQ not required for AppSync resolver"
67506761
# checkov:skip=CKV_AWS_117: "Function does not require VPC access"
67516762
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency"
6763+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (Cognito pool and group IDs)"
67526764
Properties:
67536765
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
67546766
Handler: index.handler
@@ -6806,6 +6818,7 @@ Resources:
68066818
# checkov:skip=CKV_AWS_116: "DLQ not required for DynamoDB stream processing"
68076819
# checkov:skip=CKV_AWS_117: "Function does not require VPC access"
68086820
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency"
6821+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (Cognito pool and group IDs)"
68096822
Properties:
68106823
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
68116824
Handler: index.handler
@@ -6857,6 +6870,7 @@ Resources:
68576870
# checkov:skip=CKV_AWS_116: "DLQ not required for AppSync resolver"
68586871
# checkov:skip=CKV_AWS_117: "Function does not require VPC access"
68596872
# checkov:skip=CKV_AWS_115: "Function does not require reserved concurrency"
6873+
# checkov:skip=CKV_AWS_173: "Environment variables contain non-sensitive configuration values (DynamoDB table name)"
68606874
Properties:
68616875
PermissionsBoundary: !If [HasPermissionsBoundary, !Ref PermissionsBoundaryArn, !Ref AWS::NoValue]
68626876
Handler: index.handler

0 commit comments

Comments
 (0)