Lambda functions must not be assigned IAM roles whose inline policies grant full administrative privileges, because a compromised function with full permissions can exfiltrate data, modify or delete resources, or escalate privileges across your account. This rule inspects AWS::Lambda::Function resources’ Properties.Role reference (when the role is defined in the same template) and examines the referenced role’s Resources.<role>.Properties.Policies[].PolicyDocument.Statement[]. A statement will be flagged when Effect is Allow and both Action and Resource are * (including arrays that contain *). To remediate, follow least privilege. Replace wildcard actions and resources with explicit actions and scoped ARNs, or attach narrowly scoped managed policies. Inline policies must not simultaneously allow Action: '*' and Resource: '*'.
Secure example (inline role policy scoped to a single S3 bucket):
AWSTemplateFormatVersion:'2010-09-09'Parameters:ExistingSecurityGroups:Type:List<AWS::EC2::SecurityGroup::Id>ExistingVPC:Type:AWS::EC2::VPC::IdDescription:The VPC ID that includes the security groups in the ExistingSecurityGroupsparameter.InstanceType:Type:StringDefault:t2.microAllowedValues:- t2.micro- m1.smallResources:SecurityGroup:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Allow HTTP traffic to the hostVpcId:Ref:ExistingVPCSecurityGroupIngress:- IpProtocol:tcpFromPort:'80'ToPort:'80'CidrIp:0.0.0.0/0SecurityGroupEgress:- IpProtocol:tcpFromPort:'80'ToPort:'80'CidrIp:0.0.0.0/0AllSecurityGroups:Type:Custom::SplitProperties:ServiceToken:!GetAtt AppendItemToListFunction.ArnList:Ref:ExistingSecurityGroupsAppendedItem:Ref:SecurityGroupAppendItemToListFunction:Type:AWS::Lambda::FunctionProperties:Handler:index.handlerRole:!GetAtt LambdaExecutionRole.ArnCode:ZipFile:| var response = require('cfn-response');
exports.handler = function(event, context) {
var responseData = {Value: event.ResourceProperties.List};
responseData.Value.push(event.ResourceProperties.AppendedItem);
response.send(event, context, response.SUCCESS, responseData);
};Runtime:nodejs8.10MyEC2Instance:Type:AWS::EC2::InstanceProperties:ImageId:ami-0ff8a91507f77f867SecurityGroupIds:!GetAtt AllSecurityGroups.ValueInstanceType:Ref:InstanceTypeLambdaExecutionRole:Type:AWS::IAM::RoleProperties:AssumeRolePolicyDocument:Version:'2012-10-17'Statement:- Effect:AllowPrincipal:Service:- lambda.amazonaws.comAction:- sts:AssumeRolePath:"/"Policies:- PolicyName:rootPolicyDocument:Version:'2012-10-17'Statement:- Effect:AllowAction:- iam:ChangePasswordResource:arn:aws:iam::account-ID-without-hyphens:user/Bob
Non-Compliant Code Examples
AWSTemplateFormatVersion:'2010-09-09'Parameters:ExistingSecurityGroups:Type:List<AWS::EC2::SecurityGroup::Id>ExistingVPC:Type:AWS::EC2::VPC::IdDescription:The VPC ID that includes the security groups in the ExistingSecurityGroupsparameter.InstanceType:Type:StringDefault:t2.microAllowedValues:- t2.micro- m1.smallResources:SecurityGroup:Type:AWS::EC2::SecurityGroupProperties:GroupDescription:Allow HTTP traffic to the hostVpcId:Ref:ExistingVPCSecurityGroupIngress:- IpProtocol:tcpFromPort:'80'ToPort:'80'CidrIp:0.0.0.0/0SecurityGroupEgress:- IpProtocol:tcpFromPort:'80'ToPort:'80'CidrIp:0.0.0.0/0AllSecurityGroups:Type:Custom::SplitProperties:ServiceToken:!GetAtt AppendItemToListFunction.ArnList:Ref:ExistingSecurityGroupsAppendedItem:Ref:SecurityGroupAppendItemToListFunction:Type:AWS::Lambda::FunctionProperties:Handler:index.handlerRole:!GetAtt LambdaExecutionRole.ArnCode:ZipFile:| var response = require('cfn-response');
exports.handler = function(event, context) {
var responseData = {Value: event.ResourceProperties.List};
responseData.Value.push(event.ResourceProperties.AppendedItem);
response.send(event, context, response.SUCCESS, responseData);
};Runtime:nodejs8.10MyEC2Instance:Type:AWS::EC2::InstanceProperties:ImageId:ami-0ff8a91507f77f867SecurityGroupIds:!GetAtt AllSecurityGroups.ValueInstanceType:Ref:InstanceTypeLambdaExecutionRole:Type:AWS::IAM::RoleProperties:AssumeRolePolicyDocument:Version:'2012-10-17'Statement:- Effect:AllowPrincipal:Service:- lambda.amazonaws.comAction:- sts:AssumeRolePath:"/"Policies:- PolicyName:rootPolicyDocument:Version:'2012-10-17'Statement:- Effect:AllowAction:- "*"Resource:arn:aws:logs:*:*:*
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
個別デモのリクエスト
Datadogを開始
Ask AI
AI-generated responses may be inaccurate. Verify important info.