You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the docs you mention that the scope of IAM admin user permissions is not locked down due to the rapid dev pace of the framework. However using a super admin in production is just the kind of thing this framework was intended to solve by enforcing AWS best practices from the start.
Has there been any recent work done to nail down the scope of permissions needed to use serverless in a prod environment? Using a super user is a non starter at most shops, and a huge security vulnerable everywhere else.
Reacted by Michael Stramel, GA7, Jordan Arsenault, Adam Booth, Frangeris Peguero, Tobias Nawa, Giovanni Frigo, Matt Weinberg, Phil Glanville, Stanley Zheng and 15 more
Serverless is now at a Beta status, so we haven't really made a thorough investigation on that front.
@doapp-ryanp@Nopik and @erikerikson I think you guys are working in an Enterprise environment. If you guys have time could you please share some thoughts on how you handle production permissions so we can add it to the docs? 😊
Also very interested in this. At the very least I would be interested to get a quick explanation how to change user permissions. From the documentation:
This should be done from the AWS CloudFormation UI, behind a user that has 2FA enabled and a secure password. All the Serverless tooling has a -c, --noExeCf option that will simply update your CloudFormation file, which can then be executed in the UI.
This is a lack of knowledge from my end, but I'm not sure how I would achieve this. Would I upload the created template from _meta/resources/. in the CloudFormation UI and change the policy in this UI? Specifically in this part:
Taken for granted that the PowerUser policy would be sufficient, I've added the according policy. However, this will result in an error: Action not allowed by stack policy.
Could someone give me quick pointer?
The role of s-resources-cf.json?
I have specific rules in my s-resources-cf.json eg:
@swennemans the requirement for Administration rights is the broad IAM permissions granted via the CFT. Once those roles are create then PowerUser is sufficient for deployment.
@eahefnawy We handle permissions in a much finer grained and targeted manner than the default CFT. We have roles for each lambda and have very narrow lambda responsibilities (i.e. each distinct resource/method is a separate lambda).
That said, we have IAM rights broadly (nearly iam:*) that are overridden by custom privilege elevation detection and rejection code that triggers on IAM activity. The detection depends upon naming conventions that identify the creator/owner of the resource. This forces specificity of permissions to those resources we create and control but we go beyond that minimum bar to meet best practices by specifying in detail only the rights that a lambda needs to execute each of usage scenarios.
To enable this to be a not terrible PITA, we specify each role in a region/environment agnostic manner using Fn:Join in the same manner as the default CFT does so that we specify unique privileges only once. Actually, the CFT is crafted by code so that we cut duplication down even further. In the specification we use naming standards so that we can templatize the customName and customRole attributes in our s-function files for our lambdas.
I'd expect that it would be easy to generalize the specificity pattern but it wouldn't be a trivial development effort to do so and provide a management interface over top of it. Regardless, it would be desirable and useful.
@erikerikson thanks a lot for the clarification. Do you think this setup is tied to some rules set up by your company in particular? Because it seems that there's lots of ways to handle production permissions and it all depends on the company policies. In that case I'm not sure what to recommend in our docs, and users will have to create their own policy for managing permission by having some balance between simplicity and security.
@eahefnawy I'd say "yes and no", or "it depends", or something else non committal. I know that the IAM rights set up we have is not off the shelf and as such, its probably not terribly common. That said, I think the least privilege approaches to lambda rights is something we did as an important best practice as opposed to being a reaction to company policy. It could be important for Serverless to consider enabling smarter more fine grained permissions management options if only to reduce the liability for the tool of being viewed as insecure by design. If you end up deciding that it is, I'd say this isn't your highest priority. That said, given the per stage rights "bubble" that is created (and punting on external resource access management to users) I can see a reasonable argument for not enabling fine grained control from a "is it necessary/wasted resources" standpoint.
Stepping back a little, this all assumes that we're talking about the IAM roles as provided in the CFT and applied to our systems. The other IAM roles (or at least policy given rights) involved here are the deployment permission rights. I believe that the narrowing of the declaration of the necessary rights for each of the various aspects of a Serverless project's deployment to the cloud would be wonderful and fundamentally pragmatic. Again though, I'm not sure this is the highest priority concern.
To take that perspective on your original question:
I deploy under the rights I have been assigned by our central cloud management group. Those rights more expansive than some teams but realistically you can expect a lot of variance across companies. That said, if the developers using the tools are not empowered to make the IAM rights changes, then you have to allow them to hand off the smallest portion of highest privilege CFT to the team that has those rights. We had more of a subtle situation in that the ApiGateway rights are harder to control in our scheme and so we have to get another team to create our API that are thereafter allowed to modify (and thereby deploy against). Since we could add the ApiGateway ID in manually, we were okay. As a second example, the pattern might generalize and imply the flexibility that you need to enable: manual and separated processes for doing any of the things that Serverless does to accomplish a full deployment. That is, at least in theory. If a team doesn't have the rights to alter Lambdas and ApiGateways, then... maybe this isn't the tool for them.
@eahefnawy for all my assertions of lower priority on these items, part of that is that I've been in a state of facing blocking issues and because these are not blocking in the "impossible" sense for my organization, I have deprioritized them. I can imagine a world wherein organizational constraints impinge in order to make some of these issues "blockers" by organizational decision. I imagine you know what I mean: security and privacy organizations and the like with gate passing or design review approval powers.
Reacted by Stanley Zheng, Yutaka Nishimura, John Twomey, Nick Boultbee, Nathan Wallace, Kenneth Chan, SimplySeth, James Beswick, Pepijn Verburg, Parker Rule and 5 more
Reacted by Tim Savage
Reacted by Stanley Zheng, Nathan Wallace, Kenneth Chan, Mario Kahlhofer, Jordan Arsenault and Marshall An
I'm using the ${project} variable so it has to be in a CF template read by serverless.
I cannot figure out where do I need to define this. Is it something that passed as arguments to sls CLI or defined in some section within serverless.yml?
@jenyayel my comment is a bit old so mainly relevant to version 0.5.5. I think it didn't even have serverless.yml back then from what I remember. The framework setup and configuration changed significantly around 0.6. Having said that the basis of that part of my comment was mostly that serverless would automatically complete the ${project} var for you as long as one placed that inside one of the template files it was preprocessing. In the latest serverless I think that's done for any CloudFormation definition, e.g. see the ${self:service} style under resources: on these docs.
I would like to discuss one more part regarding this topic as I am interested to limit the S3 permissions. In particular, I would like only allow deleting the buckets containing the specific string -serverlessdeploymentbucket-, none else. I think for deployment with the serverless framework, this is the only permission needed for S3. I tried with the following policy, but it seems to not work. Any ideas?
Activity
dherault commentedon Mar 3, 2016
👍 #726
eahefnawy commentedon Mar 4, 2016
Serverless is now at a Beta status, so we haven't really made a thorough investigation on that front.
@doapp-ryanp @Nopik and @erikerikson I think you guys are working in an Enterprise environment. If you guys have time could you please share some thoughts on how you handle production permissions so we can add it to the docs? 😊
swennemans commentedon Mar 4, 2016
Also very interested in this. At the very least I would be interested to get a quick explanation how to change user permissions. From the documentation:
This is a lack of knowledge from my end, but I'm not sure how I would achieve this. Would I upload the created template from
_meta/resources/.in the CloudFormation UI and change the policy in this UI? Specifically in this part:Taken for granted that the
PowerUserpolicy would be sufficient, I've added the according policy. However, this will result in an error:Action not allowed by stack policy.Could someone give me quick pointer?
The role of s-resources-cf.json?
I have specific rules in my
s-resources-cf.jsoneg:But from what i understand, this in combination with Administrator keys isn't a safe solution. Is this correct?
erikerikson commentedon Mar 4, 2016
@swennemans the requirement for Administration rights is the broad IAM permissions granted via the CFT. Once those roles are create then PowerUser is sufficient for deployment.
erikerikson commentedon Mar 4, 2016
@eahefnawy We handle permissions in a much finer grained and targeted manner than the default CFT. We have roles for each lambda and have very narrow lambda responsibilities (i.e. each distinct resource/method is a separate lambda).
That said, we have IAM rights broadly (nearly iam:*) that are overridden by custom privilege elevation detection and rejection code that triggers on IAM activity. The detection depends upon naming conventions that identify the creator/owner of the resource. This forces specificity of permissions to those resources we create and control but we go beyond that minimum bar to meet best practices by specifying in detail only the rights that a lambda needs to execute each of usage scenarios.
To enable this to be a not terrible PITA, we specify each role in a region/environment agnostic manner using Fn:Join in the same manner as the default CFT does so that we specify unique privileges only once. Actually, the CFT is crafted by code so that we cut duplication down even further. In the specification we use naming standards so that we can templatize the customName and customRole attributes in our s-function files for our lambdas.
I'd expect that it would be easy to generalize the specificity pattern but it wouldn't be a trivial development effort to do so and provide a management interface over top of it. Regardless, it would be desirable and useful.
erikerikson commentedon Mar 4, 2016
Feel free to ask for clarification if I have created more questions than answers.
eahefnawy commentedon Mar 5, 2016
@erikerikson thanks a lot for the clarification. Do you think this setup is tied to some rules set up by your company in particular? Because it seems that there's lots of ways to handle production permissions and it all depends on the company policies. In that case I'm not sure what to recommend in our docs, and users will have to create their own policy for managing permission by having some balance between simplicity and security.
erikerikson commentedon Mar 5, 2016
@eahefnawy I'd say "yes and no", or "it depends", or something else non committal. I know that the IAM rights set up we have is not off the shelf and as such, its probably not terribly common. That said, I think the least privilege approaches to lambda rights is something we did as an important best practice as opposed to being a reaction to company policy. It could be important for Serverless to consider enabling smarter more fine grained permissions management options if only to reduce the liability for the tool of being viewed as insecure by design. If you end up deciding that it is, I'd say this isn't your highest priority. That said, given the per stage rights "bubble" that is created (and punting on external resource access management to users) I can see a reasonable argument for not enabling fine grained control from a "is it necessary/wasted resources" standpoint.
Stepping back a little, this all assumes that we're talking about the IAM roles as provided in the CFT and applied to our systems. The other IAM roles (or at least policy given rights) involved here are the deployment permission rights. I believe that the narrowing of the declaration of the necessary rights for each of the various aspects of a Serverless project's deployment to the cloud would be wonderful and fundamentally pragmatic. Again though, I'm not sure this is the highest priority concern.
To take that perspective on your original question:
I deploy under the rights I have been assigned by our central cloud management group. Those rights more expansive than some teams but realistically you can expect a lot of variance across companies. That said, if the developers using the tools are not empowered to make the IAM rights changes, then you have to allow them to hand off the smallest portion of highest privilege CFT to the team that has those rights. We had more of a subtle situation in that the ApiGateway rights are harder to control in our scheme and so we have to get another team to create our API that are thereafter allowed to modify (and thereby deploy against). Since we could add the ApiGateway ID in manually, we were okay. As a second example, the pattern might generalize and imply the flexibility that you need to enable: manual and separated processes for doing any of the things that Serverless does to accomplish a full deployment. That is, at least in theory. If a team doesn't have the rights to alter Lambdas and ApiGateways, then... maybe this isn't the tool for them.
erikerikson commentedon Mar 5, 2016
@eahefnawy for all my assertions of lower priority on these items, part of that is that I've been in a state of facing blocking issues and because these are not blocking in the "impossible" sense for my organization, I have deprioritized them. I can imagine a world wherein organizational constraints impinge in order to make some of these issues "blockers" by organizational decision. I imagine you know what I mean: security and privacy organizations and the like with gate passing or design review approval powers.
11 remaining items
DanielRuskin1 commentedon May 31, 2016
Cool, makes sense. I ended up just removing the CF permission completely for my deployment, I'll probably just make those updates manually.
flomotlik commentedon Aug 19, 2016
Duplicate of #1439 so I'm closing here but we'll keep the discussion going there.
berry2012 commentedon Jan 26, 2018
create a serverless.json policy with the code below and attach to user or role that runs serverless project in your environment.
tommedema commentedon Aug 10, 2018
@berry2012 this gives me:
erikerikson commentedon Aug 10, 2018
@tommedema - most users in a more restrictive environment pre-create their bucket and specify it using the deploymentBucket parameter
jenyayel commentedon Feb 12, 2019
@c-knowles you mentioned:
I cannot figure out where do I need to define this. Is it something that passed as arguments to
slsCLI or defined in some section within serverless.yml?cknowles commentedon Feb 14, 2019
@jenyayel my comment is a bit old so mainly relevant to version 0.5.5. I think it didn't even have serverless.yml back then from what I remember. The framework setup and configuration changed significantly around 0.6. Having said that the basis of that part of my comment was mostly that serverless would automatically complete the
${project}var for you as long as one placed that inside one of the template files it was preprocessing. In the latest serverless I think that's done for any CloudFormation definition, e.g. see the${self:service}style underresources:on these docs.jenyayel commentedon Feb 16, 2019
Thanks @c-knowles for getting back! I'll try to define it there, although I think I already did and it did't pick it up.
ptrhck commentedon Feb 21, 2019
I would like to discuss one more part regarding this topic as I am interested to limit the S3 permissions. In particular, I would like only allow deleting the buckets containing the specific string -serverlessdeploymentbucket-, none else. I think for deployment with the serverless framework, this is the only permission needed for S3. I tried with the following policy, but it seems to not work. Any ideas?
joshuaquek commentedon Feb 4, 2021
So far I am using this tool to help me generate policies for my serverless projects:
https://open-sl.github.io/serverless-permission-generator/