gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 08:51:06 27 4
gpt4 key购买 nike

我担心安全问题。 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com