mirror of
https://github.com/floci-io/floci.git
synced 2026-12-03 18:18:02 -05:00
fix(iam): check each layer a Lambda function adds as lambda:GetLayerVersion (#9769)
The Service Reference lists lambda:GetLayerVersion among the actions CreateFunction and UpdateFunctionConfiguration are authorized by, and the Lambda Developer Guide says what it is checked on: "Make sure that you have permission to call the GetLayerVersion API on the layer version". Floci checked neither operation as it, so a caller allowed to create or update functions added any layer version of its account, whatever its policies said about reading it. tools/aws/fetch_lambda_layer_permissions.py vendors that sentence from the adding-layers page, with the action and the resource it names, and refuses a page asking for permission to call an API in any other wording. The request-resources generator reads it (api_permission_resources): an operation the Service Reference lists as authorized by that action is also checked as it on each value of the request's member holding botocore's ARN shape for the type the words name (`<Type>Arn`, as minted_types reads it; `Layers`, a list of `LayerVersionArn`, for a `layerVersion`). CreateFunction and UpdateFunctionConfiguration now check lambda:GetLayerVersion on each layer version their Layers give, and a request giving none is not checked as it; no other operation changes. --verify reports an operation checked so whose action the Service Reference stops listing (verify_api_actions). CreateFunction is the first operation checked by parts that also tags what it creates, so IamEnforcementFilter now checks an operation's own action, where it is one of the parts, as it would be alone: with the request's tags (aws:RequestTag, aws:TagKeys) and carried values, not the bare part context. The checks made after it, the tagging action a create also needs, a companion and a forwarded action, are made on the resources that action was checked on, not on *, so lambda:TagResource is again checked on the function a tagged create makes. Another account's layer version is checked on its ARN alone: LambdaStoredResourceArns answers reachedInItsAccount for it, as Lambda reads such a layer in its owner's account through the owner's policy and never as the caller's layer of that name, where IAM also checked the caller's same-named layer before (GetLayerVersionByArn too). The table is regenerated against today's Service Reference too, which the online gate this change runs requires: AWS added SageMaker's leaderboard and model-monitor-config types (their ARN formats and tag keys, and the types of AddTags, DeleteTags and ListTags) and lists a backup-external namespace the table does not read. The docs and two comments in LambdaService and LambdaLayerService no longer say Floci implements no layer permissions.
This commit is contained in:
1 parent
f1b47125de
commit
6563e6a315
16 files changed
+638
-46
No files matched your search
+11
-3
@@ -610,9 +610,9 @@ An ARN naming another account or another partition is answered on the live servi
|
||||
resource policy: an AWS-managed public layer resolves, and everything else is
|
||||
`AccessDeniedException`. Measured on `CreateFunction` in ap-southeast-1, a foreign-account ARN and
|
||||
a cross-partition ARN return the same `AccessDeniedException`, so Floci returns that for both.
|
||||
Floci implements no layer permissions and cannot fetch real AWS content, so it cannot tell a
|
||||
public layer from a private one; refusing is the faithful default, being the answer AWS gives to
|
||||
every foreign ARN except a public one.
|
||||
Floci cannot fetch real AWS content, so it cannot tell a public layer from a private one, and it does
|
||||
not yet resolve another account's layer its owner granted (see Layer permissions below); refusing is
|
||||
the faithful default, being the answer AWS gives to every foreign ARN except a public or granted one.
|
||||
|
||||
Set `floci.services.lambda.accept-external-layer-arns: true`
|
||||
(`FLOCI_SERVICES_LAMBDA_ACCEPT_EXTERNAL_LAYER_ARNS`) to record a same-partition foreign ARN on the
|
||||
@@ -644,6 +644,14 @@ AWS's "the owner of that account must grant your account permission in a resourc
|
||||
Reading another account's layer version once granted is not served yet: `GetLayerVersionByArn` still
|
||||
resolves a layer only in the caller's own account.
|
||||
|
||||
**Layers under IAM enforcement:** `CreateFunction` and `UpdateFunctionConfiguration` are also
|
||||
checked as `lambda:GetLayerVersion` on each layer version their `Layers` give, as the developer
|
||||
guide's "Make sure that you have permission to call the GetLayerVersion API on the layer version"
|
||||
says, so a caller allowed to create or update functions but not to read a layer version is refused
|
||||
that layer. A request giving no `Layers` is not checked as it. Another account's layer version is
|
||||
checked on its own ARN alone, against its owner's policy, never as a same-named layer of the
|
||||
caller's, as Lambda never substitutes one.
|
||||
|
||||
## Provisioned concurrency
|
||||
|
||||
Published versions with `SnapStart.ApplyOn=PublishedVersions` reject provisioned concurrency
|
||||
|
||||
Reference in new issue
Block a user