131 points · by belter · 4y ago · 73 comments
1. Avoid long lived credentials (access key/secret key pairs) and IAM users whenever possible, and instead have everything assume roles for access to resources in the same as well as other accounts. Temporary credentials from STS are the way to go.
2. Turn on IMDSv2 by default for EC2 instances. v1 is susceptible to SSRF attacks so even if you’re attaching an instance profile to an instance and doing everything else right, you’ve got a problem if somebody finds a weakness in the app running on the instance.
Also heavily recommend checking out Scott Piper’s SCP Best Practices (https://summitroute.com/blog/2020/03/25/aws_scp_best_practic...) that still hold up even if being a few years old at this point.
It sounds like really basic security - my saved credential can't go delete servers. Absolutely everyone, from aws certified people to apparently renowned developers have gotten stuck into me over this, with complaints from "I'd quit anywhere that did that" to "bad setup, proper iam never requires mfa". I'm sure there's going to be some form of blow up where long term saved credentials eventually come out as problematic, and it will blow people's minds.
MFA seems like an essential defense-in-depth measure to ensure that a compromise of the locally held IAM key is not enough on its own to compromise your AWS account.
Say I want to load a huge amount of data, or do a ton of s3 uploads. My role assumption via MFA / TOTP lasts 4 hours.
Now say you are doing lots of different "big data" flows, how do you assume privileges when you need them?
I understand what MFA / TOTP brings to security, but security people pretend like my job is about logging into a box once-in-a-while for a couple minutes, and that is the ONLY USE CASE.
Least privilege is another thing that sounds great to a security guy but is a nightmare for development. So whenever you do anything off the beaten path (diagnose new systems deployed, try new database backends, do some data moves or loads, backup/restore), uhoh, you spend a ton of time diagnosing shortfalls and decoding error messages. The security guy DOES NOT CARE.
S3 is a perfect example. S3 should be simple. It is a nightmare of permissions on the user side, permissions on the bucket, and even worse across accounts. Tiresome. Magic numbers/dates for the "version" field policy, what is with THAT? ACLs/Policies stomping over each other.
The funny thing is, ask a security person to first enable cloudwatch and dig through the data to find issues and vulnerabilities, or ask security people to actually produce well-tuned IAM roles for what you need. Guess what? They don't want to do it. They want to sit around making checklists and sending memos.
It's a HTTP interface so that the most software can benefit from that, whether it's a shell script using curl or something written in Java, Scala, Python, Node.js, Rust, whatever ... pretty much everything can make HTTP requests. Of course over time that HTTP interface became a target itself and when applications have SSRF issues, badness could ensue.
IMDSv2 limits the reachability in four ways to protect against SSRF. 1. The IMDS can be entirely turned off if you prefer. 2. Access requires a PUT request, our analysis showed that SSRFs that grant the ability to PUT are very rare. Most SSRF issues only grant GET because they are a URL or header escaping issue that don't give up control of the method. 3. Requests with X-Forwarded-For are denied, so if it's a misconfigured open proxy or WAF that adds this header, you get protection. 4. The request has to come from the local box because we set the IP TTL to "1" which means it isn't routable off-box. This protects against misconfigured NATs and routers.
It’s dorky, but 9pfs over virtio would work for this purpose, at least with a Linux guest.
And it's hilarious that ssh is being treated as some massive vulnerability by the security folks, and they are pushing enterprisey crap like Teleport instead, which crashes / agents go dead / doesn't work in low memory.
I say that because taking this blog post as an article, it makes one major false assumption: Credential Leakage = Compromise.
In reality, anyone who knows AWS IAM knows that you can:
- Activate/Deactivate credentials
- Time-gate policies
- IP-restrict policies
- Use roles with STS temporary credentials
- Use roles in conjunction with the externalId attribute
- Many more things I've missed out....
Yes sure you probably should rotate your credentials yada yada (or perhaps use the "new" X.509 auth method instead).But that doesn't detract the fact that this blog is making a cheap-shot and not really taking into account the strengths of AWS IAM in terms of the security granularity that make it possible (with a correct, layered config) to comfortably say Credential Leakage DOES NOT equal Compromise. You just need to take a minute to RTFM and sit down and plan your IAM setup, instead of just doing it on a whim.
AWS IAM is actually one of the best bits of AWS. Its one of the areas where AWS leads in comparison to its competitors (IMHO).
Also if you push AWS keys into github (this does happen from time to time at the best organisation), github will nuke the rev. And even if you did it successfully there should be no damn keys which are usable because anything human issued should be via SSO and windowed or have MFA required set up. Everything else should be assume role based.
We did release some (hopefully) actionable guidance alongside the study[1].
Trusted Advisor is a fair point, but note that most of its security checks only come with the Business or above AWS support plan. IAM Access Analyzer is a great service but it currently supports only 6 resource types[2].
We'll look into adding both, appreciate the feedback!
[1]: https://securitylabs.datadoghq.com/articles/state-of-aws-clo...
[2]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access-anal...
Another fair point is Datadog also charges for its product.
No.
As per my post above, they "led to compromise" because lazy syadmins have been too inept to RTFM and make full use of IAM.
I mean, I could post my IAM credentials right here. I've even been lazy and haven't rotated them for 5 years (yes I've already slapped myself on the wrist !).
But they'll be naff all use to you because:
- My credentials are deactivated when I'm not using them.
- The STS policies they are linked to are IP-restricted
- The Role policies they are linked to are also IP-restricted
- The Role policies have minimal necessary privilege
- The Role policies can only be invoked be an assumed role
- The Roles have externalID attribute set using a UUID as value
Thus even if I copy/pasted my credentials right here, you wouldn't even get past step 1 let alone any further.And that's just a simple example. You can go much more layered and granular than that.
Its not rocket science, its not difficult, its just a case of the old PPPPPP (Prior Planning Prevents P* Poor Performance).
Companies generally totter along until about 50 engineers / 100 employees before hiring a single security-focused engineer. When those first few security engineers come on board, you can bet they'll have a backlog of at least several months' if not a couple years' worth of research and remediation before they get anywhere near taming the company's IAM setup. The vast majority of companies are small and probably aren't where they need to be in terms of IAM practices.
AWS adoption has become a lot more mainstream among companies. 10 years ago it was almost a secret weapon for forward-thinking (and VC-money-burning) companies that let them out-scale competitors. Unfortunately their defaults, documentation, guard rails, etc are still set up for those bleeding-edge, hyper-competent, top-0.01% companies.
Not saying they're impossible, but they are definitely difficult to figure out!
This sounds rather interesting, mind elaborating how its done? How would they activate when you use them, but not if anyone else does?
> No.
> As per my post above, they "led to compromise" because lazy syadmins have been too inept to RTFM and make full use of IAM.
You're contradicting yourself: "No, it hasn't led to compromises" but "they led to compromise because ..."
It's possible that (as you argue) AWS IAM provides strong security controls and, simultaneously, a lot of people use it in a way where credential leak _does_ represent compromise. My going-in expectation is that both of these are true. But this post isn't about whether AWS IAM is any good. Nor does the post talk about solutions -- I don't see a call to action to buy Datadog (aside from the banner in the footer that doesn't look connected to the post). So your criticism of "this is a non-problem -- everybody's just using it wrong" sounds pretty lame.
Do you mean using roles (which aren’t credentials) or temporary credentials (which can’t be revoked)?
Or do you use other credentials to disable them (and how do you disable those)?
I’m not an AWS expert by any stretch, so genuinely interested as I wasn’t aware of any other mechanism you could be using.
A public/leaked set of IAM credentials, using reasonable AWS access policies, should be considered more secure than a private set of credentials that just has unrestricted access to everything.
The number one cause of AWS security issues is human error or not understanding what you are doing. AWS provides a hell of a lot of tooling, documentation and guidance to manage those risks out of the box. What doesn't help is buying a vendor product first and assuming it's going to do magic unicorn farts and make everything ok. What it will do is cost you a ton of money and time to tick a box somewhere that seemed like a good idea.
Someone selling a solution to those is selling you snake oil.
All of the issues identified will be picked up by Trusted Advisor or complain loudly on the IAM dashboard. If you don't notice that or don't use it, then your funeral.
> 40 percent of organizations have at least one IAM user that has AWS Console access and does not have multi-factor authentication
Yeah, I hope your last resort, non-root account is locked in a safe place and has no multi-factor on it. Statistics are cool, but some context behind the findings is also useful.
Similar story with the active root accounts. If they exist only on paper in a safe, that's fine.
(Root user ARN is arn:aws:iam::555555555555:root versus IAM users which have ARNs like arn:aws:iam::555555555555:user/USERNAME)
Wow didn't expect that. Separating accounts is probably one of the most important things to do in AWS, for security and performance/development.
This piece is clearly "content marketing", or even "technical content marketing". The purpose is to spread awareness about Datadog and possibly lure potential clients into looking at their product offerings.
There's nothing bad with it per se; but I would take the bait if you provide some really insightful information. This piece doesn't seem to add much value.
An example of something more useful, IMHO, is this report about cloud native threats [0]. (I think it's quite stupid to ask for name, company, etc, in order to be able to download the report. Anyway...) If I'm actively into security, it provides useful information.
As an example, the report cites that "It costs $430,000 in cloud bills and resources for an attacker to generate $8,100 in cryptocurrency revenue.". This information tells me that these attackers can generate a lot of damage, and it suggests I should do something to control the spending in my cloud infra, in case one of these attacks is successful.
[0]: https://sysdig.com/resources/reports/2022-cloud-native-threa...
Would love to hear your thoughts on how we can make it "deeper" and "more accurate" in the future!
[1]: https://securitylabs.datadoghq.com/articles/state-of-aws-clo...
Audit logs are in many cases disabled by default (RDS, S3, OpenSearch, ELB).
S3 does not require TLS requests by default. ECR does not have image scanning enabled by default.
Also new accounts almost all regions enabled and a default VPC in each (and subnets, route tables, security groups, internet gateway, dhcp option set). Unused VPCs are not recommended to keep around but I suppose it makes onboarding easier.
Audit logging costs money, so I'm on the fence about that.
A default VPC is easy to disable in enterprise deployments, but for the rest of us it is necessary to do quick tests with EC2-adjacent services - I'd be in favour of it not existing until you try to launch something though.
I completely agreed though - I look at CloudConformity and so many of the warnings are for encrypted resources.
I am curious where the OP got this information. Cannot imagine AWS sharing this. Datadog or GitGuardian study mentioned in the article cannot track data for such a large fraction of AWS users either. Just curious ...