- Newest
- Most votes
- Most comments
May considering this:
- AWS CloudTrail
- Use CloudWatch Logs to create metric filters on CloudTrail logs to detect specific events such as ConsoleLogin or Root API calls.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/MonitoringLogData.html
There's no straightforward way to log all the actions the root user may take. Various services either only emit logs in their own, service-specific ways, or don't log some actions at all.
As just one example, to log emails sent via Amazon SES, a "configuration set" must be created in the Amazon SES configuration in each enabled region that hosts SES, and then ensuring that emails are sent in the context of one of the identities associated with the configuration set. Enforcing that for the account root user can only be done with an SCP (service control policy) configured in AWS Organizations attached to the account or one of its parent OUs. SES is just one of many services that the root user can use that don't support a universal "log all actions in all regions to a central logging destination" type of configuration.
If the intent is to set up a reliable detection for the root user's credentials being compromised, then there is no universal, cross-service way of doing that. The recommended approach starts with either creating a new, dedicated account to serve as the management account of an AWS Organization or dedicating an existing account, such as the centralised billing account, only to that single use. An org is created in AWS Organizations in that dedicated management account, followed by all the member accounts being invited to join the organisation. Once all the workload accounts are members of the new organisation, root user credentials should be deleted from all the workload accounts. The management account of the AWS Organization can delete the root credentials with this feature: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-enable-root-access.html
If root credentials are broadly used and cannot be quickly deleted, then the next-best first step is to apply one or more SCPs (service control policy) to the workload accounts that use root credentials: https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html. SCPs apply to all actions taken in an account, including those taken by the root user, so they can be used to restrict the use of root credentials to those services and actions that are known to be used with root credentials. It would also be very valuable to restrict their use to legitimate IP addresses and VPC endpoints through which API calls are made by root. Once SCPs are configured to restrict actions to the relevant services, then you could determine which logging alternatives work best for those services.
The mid-term goal should be to use the logs to determine what root credentials are used for and to refactor each case to use IAM roles or IAM users instead (or federated logins, if any human user is logging on as root). Each IAM role/user should be configured with the proper permissions policies, and if possible, the identity-based policies attached to the roles/users should also include Deny statements to block access from outside expected IP addresses or VPC endpoints. There are good examples of network-based policy restrictions in this blog post: https://aws.amazon.com/blogs/security/establishing-a-data-perimeter-on-aws-allow-access-to-company-data-only-from-expected-networks/
Once all the identified uses for root credentials have been refactored to use IAM roles or IAM users (or federated sessions via IAM Identity Center for human users, if any human was logging on as root), you should set the SCP to block all actions by the root user, unless the request is being made with a special assumed root session from the management account. An example of how to configure an SCP to do this is in this documentation section: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-assumedroot. After the SCP is applied, anyone still logging on as root via the console will not be able to do anything. Once there are no legitimate uses left, the root credentials should be deleted from the workload accounts via the management account: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-enable-root-access.html
Despite the static, long-lived credentials of the root user having been deleted, the management account will still be able to perform the limited set of actions that are occasionally needed, by using the assumed root session feature. A typical situation where the root session is needed is if someone configured an S3 bucket policy that blocks access to everyone, including themselves; the root session can be used to delete the blocking bucket policy. A full list of the actions that the assumed root session can perform is here: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user-privileged-task.html
Relevant content
asked 3 years ago
- AWS OFFICIALUpdated 7 months ago
