amazon-web-services - IAM 角色限制 sts :AssumeRole to one AWS Lambda function

标签 amazon-web-services aws-lambda amazon-iam

我担心安全问题。 IAM 角色的创建是一种高安全风险,并且您只能指定为可以担任角色的 AWS Lambda 这一事实在 IMO 上还不够好。如果不小心处理,可能会出现特权升级。

如何创建特定于某些 Lambda 函数的 IAM 角色?

我没有发现任何类似的东西,但我相信它可能是可能的。

此角色还将附加一些策略:

{
  "Action": "sts:AssumeRole",
  "Principal": {
    "Service": "lambda.amazonaws.com"
  },
  "Effect": "Allow",
  "Sid": ""
}

通常,在其他角色中,您会使用 Principal 子句来决定哪些帐户可以承担该角色。
{
 "Effect": "Allow",
 "Principal": {
   "AWS": "arn:aws:iam::123456789:root"
 },
 "Action": "sts:AssumeRole"
}

根据@Michael 在评论中的说法,我不得不说哪些用户可以对哪些角色使用传递角色,因此问题是,我如何确定哪些用户可以传递这个角色?

如果是这样,这个问题的答案将分两步解决。使此角色只能由 Lambda 服务承担(因为它已经存在),然后为每个用户制定一个包含 PassRole 限制的策略。

最佳答案

我就此询问了 AWS 支持。他们说他们目前*不支持假设角色/信任策略中的条件,以通过匹配函数名称模式来限制哪些函数可以承担角色。
相反,他们建议在执行策略中添加条件(而不是假设/信任策略):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "WhitelistSpecificLambdaFunction",
            "Effect": "Deny",
            "Action": "*",
            "Resource": "*",
            "Condition": {
                "StringNotLike": {
                    "aws:userid": "AROAUISMSUAFHSJDJURKJ:TestLambda"
                }
            }
        }
    ]
}

-- This policy denies access to all Lambda functions except the specific Lambda function whose name is mentioned in "aws:userid" condition key. Other Lambda functions will be able to assume the role, but they will be denied from performing any action but if they are just printing or returning any variables/data the function would work.


--> NOTE: The condition key "aws:userid" specifies the unique ID for the current role and the corresponding value of this key has the following format: "role-id:role-session-name".


-- IAM role ID is "AROAUISMSUAFHSJDJURKJ" for the sample role I used.


-- In case of Lambda function the role-session-name is same as Lambda function name. In this example case it is "TestLambda", so aws:userid becomes "aws:userid": "AROAUISMSUAFHSJDJURKJ:TestLambda"


* 他们将我的名字添加到现有请求中以添加此功能

关于amazon-web-services - IAM 角色限制 sts :AssumeRole to one AWS Lambda function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42717431/

相关文章:

java - 为什么上传到 S3 的文件的内容类型为 application/octet-stream,除非我将文件命名为 .html?

django - 在 AWS 弹性 beantalk 上部署 django 项目

amazon-web-services - AWS Lambda 和不准确的内存分配

aws-lambda - 是否可以为 API Gateway -> Lambda 映射指定多个方法?

amazon-web-services - S3 IAM 策略在模拟器中有效,但在现实生活中无效

amazon-web-services - 调用 AssumeRole 操作时发生错误 (AccessDenied)

amazon-web-services - 可以在单个请求中从 Amazon S3 获取多个对象吗?

python - 无法使用 Tensorflow 在 Chalice 上部署

javascript - 如何向用户隐藏 javascript( native react )应用程序中的 S3 key ?

amazon-web-services - 安全组与角色的使用