GithubHelp home page GithubHelp logo

A potential risk in cloudfront-authorization-at-edge which can be used to upload malicious code. about cloudfront-authorization-at-edge HOT 4 CLOSED

zolaer9527 avatar zolaer9527 commented on July 22, 2024
A potential risk in cloudfront-authorization-at-edge which can be used to upload malicious code.

from cloudfront-authorization-at-edge.

Comments (4)

zolaer9527 avatar zolaer9527 commented on July 22, 2024 1

OK, thank you!

from cloudfront-authorization-at-edge.

ottokruse avatar ottokruse commented on July 22, 2024

Hi @zolaer9527

Thanks for the report. Here's our findings:

You mention as first step executing this from CloudShell:

aws sts assume-role --role-arn "arn:aws:iam::747955086145:role/serverlessrepo-cloudfront-LambdaCodeUpdateHandlerR-MTRLVJ4XJCPJ" --role-session-name CLISession

But that is impossible, because that role can only be assumed by the AWS Lambda service (via the trust relationships of the role), so you must have already altered the trust relationship of the role to allow the role to be assumed by your AWS console user?

Here is the definition of the Lambda function:

LambdaCodeUpdateHandler:
Note that the associated role is created automatically by AWS SAM, and should only have a trust relationship to the AWS Lambda service (or there would be a bug in AWS SAM), and I checked a deployment in my own account where this is indeed the case.

You can indeed log the credentials from a Lambda function, and then use those credentials to do what the Lambda function is allowed to do. Normally you wouldn't do this, but as developer with admin privileges you could if you wanted to. There's no surprise there though? Note that this requires you to alter the Lambda function code, to add that logging. Threat actors would not be able to do that.

I believe your scenario is not a plausible threat, unless your AWS account is compromised (in which case you have more pressing concerns):

  • Threat actors do not have access to update the trust relationships of the role
  • Threat actors cannot assume the role from AWS CloudShell without already being in the AWS console, and having AWS credentials with which they can do very bad things (assuming roles that they weren't supposed to assume)
  • Threat actors cannot alter the Lambda function code without already having AWS credentials with which they can do very bad things (changing Lambda function code)

Back to the role itself: the permissions it has are necessary and required for deployment of the solution with CloudFormation. It needs "lambda:UpdateFunctionCode" the permission.

You are right that Lambda function code signing is an option to ensure with great confidence that only code you trust is deployed to Lambda––if you require that level of assurance. This however is beyond the scope of this sample solution. If you want to add it, you can take this sample solution and tweak it to suit your needs.

I will close this issue, let us know if the above didn't address your concern satisfactorily.

from cloudfront-authorization-at-edge.

zolaer9527 avatar zolaer9527 commented on July 22, 2024

Hello @ottokruse, in the trust relationships of the role, I find the principal is "Service": "lambda.amazonaws.com". Does this mean that the role can be assumed by all AWS Lambda functions? If not, how does the AWS implement one-on-one binding between a function and a role?

from cloudfront-authorization-at-edge.

ottokruse avatar ottokruse commented on July 22, 2024

Does this mean that the role can be assumed by all AWS Lambda functions

Yes, but only by Lambda functions within the account.

from cloudfront-authorization-at-edge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.