Skip to content

Security: default permission allow any service to invoke a lambda function #3599

Closed
@ananich

Description

@ananich

Description:

When a lambda function has S3 event, this lambda function can be invoked by any service (not just S3).

Steps to reproduce:

  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Sub ${AWS::StackName}-hello
      CodeUri: hello/
      Handler: lambda_function.lambda_handler
      Runtime: python3.12
      Role: !GetAtt MyLambdaFunctionRole.Arn
      Events:
        S3FileAdded:
          Type: S3
          Properties:
            Bucket: !Ref MyBucket
            Events:
              - s3:ObjectCreated:*
            Filter:
              S3Key:
                Rules:
                  - Name: prefix
                    Value: inbox/
                  - Name: suffix
                    Value: .txt

Observed result:

When permission is created, it looks like that:

{
  "StringEquals": {
    "AWS:SourceAccount": "123123123123"
  }
}

Expected result:

I'd like Type: S3 to be same as Type: Schedule produce:

{
  "ArnLike": {
    "AWS:SourceArn": "arn:aws:events:us-east-1:123123123123:rule/hello-world"
  }
}

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: macOS-*******-x86_64-i386-64bit
  2. Python: 3.12.2
  3. sam --version: SAM CLI, version 1.116.0
  4. AWS region: us-east-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-customer-responseMaintainer response provided, waiting for customer feedback.stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions