#cloudtrail — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #cloudtrail, aggregated by home.social.
-
I wanted to automatically disable an IAM user when it does something suspicious. Since this IAM user is used by a script I know that when it deviates that is a good indicator that it was compromised and I need to investigate.
How hard could it be?
Well, it turned out to be a frustrating experience. CloudTrail records events done by users, so this should be easy to setup. But then I started to encounter problems:
* Only the first CloudTrail event is free, so I did not want to create more than one trail
* CloudTrail sends events to EventBridge but only for the current region, which is not enoughI have an organizational trail in the management account. Let's see how easy it is to send these events into a member account!
* CloudTrail can send events to a CloudWatch log then I could set up a subscription filter. This worked for a PoC but ultimately there is a limit of 2 for subscription filters for a log group. So this was a no-go
* Otherwise it writes to S3, so I had to have a Lambda reading the objects as CloudTrail writes themAt this point I had a Lambda that got all CloudTrail events and filters out the interesting ones: ones with AccessDenied error, GetCallerIdentity, and ConsoleLogin. That should be a good start.
EventBus Rules can send events based on a filter, so forwarding these events into an EventBus seems like a good idea. So so far the chain is: CloudTrail => S3 => Lambda => EventBus.
But how can I send these events to the member account? Well, an EventBus Rule, of course. So I created an EventBus in the member account.
Next issue: a CloudFormation stack can't create an EventBus Rule in a different region. Interestingly, it is possible to create *cross-account* but not cross-region. So I needed an EventBus in the target region as well and set up a Rule to forward events there.
Then the very last step is to set up a Rule to filter events for the IAM user(s) and set up a CloudWatch alarm that calls a Lambda that attaches the DenyAll policy to the user.
Since I wanted everything managed by CloudFormation I ended up with an enormous amount of stacks:
* (mgmt acc us-east-1) CloudTrail + Lambda + EventBus
* (mgmt acc us-east-1) EventBus Rule to forward events to the member account
* (member acc us-east-1) EventBus to receive events from the mgmt account
* (member acc us-east-1) EventBus Rule to forward events to the regional EventBus
* (member acc eu-west-1) The target stack with the IAM users and an EventBus to receive events toWhat makes it a particularly annoying experience is that there are so many small limitations that make a simpler solution impossible:
* CloudTrail should support filtering by events so that the whole management account => member account part could be saved
* Or: the default EventBus should receive *all* CloudTrail events not just ones for the current region
* EventBus Rule should be allowed to be cross-region. That would have saved me one EventBus
* EventBridge Pipes don't support SNS as a source and also it's not clear if that supports cross-region and cross-account pipesI wrote about my frustrations in this article: [https://advancedweb.hu/cloudtrails-horrible-developer-experience/](https://advancedweb.hu/cloudtrails-horrible-developer-experience/).
Overall, I'm fairly happy with this solution, but I feel that it would be so much easier if AWS supported some basic features around CloudTrail.
Originally published [on my blog](https://advancedweb.hu/shorts/how-hard-it-is-to-disable-an-iam-user-when-it-does-something-suspicious/)
-
I wanted to automatically disable an IAM user when it does something suspicious. Since this IAM user is used by a script I know that when it deviates that is a good indicator that it was compromised and I need to investigate.
How hard could it be?
Well, it turned out to be a frustrating experience. CloudTrail records events done by users, so this should be easy to setup. But then I started to encounter problems:
* Only the first CloudTrail event is free, so I did not want to create more than one trail
* CloudTrail sends events to EventBridge but only for the current region, which is not enoughI have an organizational trail in the management account. Let's see how easy it is to send these events into a member account!
* CloudTrail can send events to a CloudWatch log then I could set up a subscription filter. This worked for a PoC but ultimately there is a limit of 2 for subscription filters for a log group. So this was a no-go
* Otherwise it writes to S3, so I had to have a Lambda reading the objects as CloudTrail writes themAt this point I had a Lambda that got all CloudTrail events and filters out the interesting ones: ones with AccessDenied error, GetCallerIdentity, and ConsoleLogin. That should be a good start.
EventBus Rules can send events based on a filter, so forwarding these events into an EventBus seems like a good idea. So so far the chain is: CloudTrail => S3 => Lambda => EventBus.
But how can I send these events to the member account? Well, an EventBus Rule, of course. So I created an EventBus in the member account.
Next issue: a CloudFormation stack can't create an EventBus Rule in a different region. Interestingly, it is possible to create *cross-account* but not cross-region. So I needed an EventBus in the target region as well and set up a Rule to forward events there.
Then the very last step is to set up a Rule to filter events for the IAM user(s) and set up a CloudWatch alarm that calls a Lambda that attaches the DenyAll policy to the user.
Since I wanted everything managed by CloudFormation I ended up with an enormous amount of stacks:
* (mgmt acc us-east-1) CloudTrail + Lambda + EventBus
* (mgmt acc us-east-1) EventBus Rule to forward events to the member account
* (member acc us-east-1) EventBus to receive events from the mgmt account
* (member acc us-east-1) EventBus Rule to forward events to the regional EventBus
* (member acc eu-west-1) The target stack with the IAM users and an EventBus to receive events toWhat makes it a particularly annoying experience is that there are so many small limitations that make a simpler solution impossible:
* CloudTrail should support filtering by events so that the whole management account => member account part could be saved
* Or: the default EventBus should receive *all* CloudTrail events not just ones for the current region
* EventBus Rule should be allowed to be cross-region. That would have saved me one EventBus
* EventBridge Pipes don't support SNS as a source and also it's not clear if that supports cross-region and cross-account pipesI wrote about my frustrations in this article: [https://advancedweb.hu/cloudtrails-horrible-developer-experience/](https://advancedweb.hu/cloudtrails-horrible-developer-experience/).
Overall, I'm fairly happy with this solution, but I feel that it would be so much easier if AWS supported some basic features around CloudTrail.
Originally published [on my blog](https://advancedweb.hu/shorts/how-hard-it-is-to-disable-an-iam-user-when-it-does-something-suspicious/)
-
I wanted to automatically disable an IAM user when it does something suspicious. Since this IAM user is used by a script I know that when it deviates that is a good indicator that it was compromised and I need to investigate.
How hard could it be?
Well, it turned out to be a frustrating experience. CloudTrail records events done by users, so this should be easy to setup. But then I started to encounter problems:
* Only the first CloudTrail event is free, so I did not want to create more than one trail
* CloudTrail sends events to EventBridge but only for the current region, which is not enoughI have an organizational trail in the management account. Let's see how easy it is to send these events into a member account!
* CloudTrail can send events to a CloudWatch log then I could set up a subscription filter. This worked for a PoC but ultimately there is a limit of 2 for subscription filters for a log group. So this was a no-go
* Otherwise it writes to S3, so I had to have a Lambda reading the objects as CloudTrail writes themAt this point I had a Lambda that got all CloudTrail events and filters out the interesting ones: ones with AccessDenied error, GetCallerIdentity, and ConsoleLogin. That should be a good start.
EventBus Rules can send events based on a filter, so forwarding these events into an EventBus seems like a good idea. So so far the chain is: CloudTrail => S3 => Lambda => EventBus.
But how can I send these events to the member account? Well, an EventBus Rule, of course. So I created an EventBus in the member account.
Next issue: a CloudFormation stack can't create an EventBus Rule in a different region. Interestingly, it is possible to create *cross-account* but not cross-region. So I needed an EventBus in the target region as well and set up a Rule to forward events there.
Then the very last step is to set up a Rule to filter events for the IAM user(s) and set up a CloudWatch alarm that calls a Lambda that attaches the DenyAll policy to the user.
Since I wanted everything managed by CloudFormation I ended up with an enormous amount of stacks:
* (mgmt acc us-east-1) CloudTrail + Lambda + EventBus
* (mgmt acc us-east-1) EventBus Rule to forward events to the member account
* (member acc us-east-1) EventBus to receive events from the mgmt account
* (member acc us-east-1) EventBus Rule to forward events to the regional EventBus
* (member acc eu-west-1) The target stack with the IAM users and an EventBus to receive events toWhat makes it a particularly annoying experience is that there are so many small limitations that make a simpler solution impossible:
* CloudTrail should support filtering by events so that the whole management account => member account part could be saved
* Or: the default EventBus should receive *all* CloudTrail events not just ones for the current region
* EventBus Rule should be allowed to be cross-region. That would have saved me one EventBus
* EventBridge Pipes don't support SNS as a source and also it's not clear if that supports cross-region and cross-account pipesI wrote about my frustrations in this article: [https://advancedweb.hu/cloudtrails-horrible-developer-experience/](https://advancedweb.hu/cloudtrails-horrible-developer-experience/).
Overall, I'm fairly happy with this solution, but I feel that it would be so much easier if AWS supported some basic features around CloudTrail.
Originally published [on my blog](https://advancedweb.hu/shorts/how-hard-it-is-to-disable-an-iam-user-when-it-does-something-suspicious/)
-
New AWS::CloudTrail::Dashboard
Use the Dashboard resource to specify a CloudTrail Lake custom dashboard. A custom dashboard can have up to 10 widgets. For more information, see CloudTrail Lake dashboards in the AWS CloudTrail User Guide.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-dashboard.html #cloudtrail #cloudformation -
Dotenv doesn’t work in #lamda, but because it is during init, only white page. And because it is during init, no (symfony) lig in #CloudTrail 🥳🥳 #bref #symfony #CloudWatch
Cc @beberlei @BrocksiNet thanks!
-
Dotenv doesn’t work in #lamda, but because it is during init, only white page. And because it is during init, no (symfony) lig in #CloudTrail 🥳🥳 #bref #symfony #CloudWatch
Cc @beberlei @BrocksiNet thanks!
-
Dotenv doesn’t work in #lamda, but because it is during init, only white page. And because it is during init, no (symfony) lig in #CloudTrail 🥳🥳 #bref #symfony #CloudWatch
Cc @beberlei @BrocksiNet thanks!
-
Dotenv doesn’t work in #lamda, but because it is during init, only white page. And because it is during init, no (symfony) lig in #CloudTrail 🥳🥳 #bref #symfony #CloudWatch
Cc @beberlei @BrocksiNet thanks!
-
Dotenv doesn’t work in #lamda, but because it is during init, only white page. And because it is during init, no (symfony) lig in #CloudTrail 🥳🥳 #bref #symfony #CloudWatch
Cc @beberlei @BrocksiNet thanks!
-
Updated AWS::CloudTrail::EventDataStore
If the FederationEnabled property is set to true, use the FederationRoleArn property to specify the ARN for the federation role. The federation role must exist in your account and provide the required minimum permissions.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-eventdatastore.html #cloudtrail #cloudformation -
Updated AWS::CloudTrail::EventDataStore
Use the FederationEnabled property to specify whether you want to federate the event data store.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-eventdatastore.html #cloudtrail #cloudformation -
Using Session Names to Log Who Deployed What in CloudTrail
~~
ACM.388 Refactoring my test script that will ultimately be used in EC2 Instances to run deployment jobs
~~
#Cloudtrail #logs #aws #namingconvention #user #process -
Using Session Names to Log Who Deployed What in CloudTrail
~~
ACM.388 Refactoring my test script that will ultimately be used in EC2 Instances to run deployment jobs
~~
#Cloudtrail #logs #aws #namingconvention #user #process -
Using Session Names to Log Who Deployed What in CloudTrail
~~
ACM.388 Refactoring my test script that will ultimately be used in EC2 Instances to run deployment jobs
~~
#Cloudtrail #logs #aws #namingconvention #user #process -
Using Session Names to Log Who Deployed What in CloudTrail
~~
ACM.388 Refactoring my test script that will ultimately be used in EC2 Instances to run deployment jobs
~~
#Cloudtrail #logs #aws #namingconvention #user #process -
Using Session Names to Log Who Deployed What in CloudTrail
~~
ACM.388 Refactoring my test script that will ultimately be used in EC2 Instances to run deployment jobs
~~
#Cloudtrail #logs #aws #namingconvention #user #process -
Updated AWS::CloudTrail::EventDataStore
Use the BillingMode property to specify the billing mode to use for the event data store.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-eventdatastore.html #cloudtrail #cloudformation -
Updated AWS::CloudTrail::EventDataStore InsightSelector
Use the AWS::CloudTrail::EventDataStore InsightSelector property to specify the types of Insights events you want to collect in your destination event data store. ApiCallRateInsight and ApiErrorRateInsight are valid Insights types.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudtrail-eventdatastore-insightselector.html #cloudtrail #cloudformation -
Updated AWS::CloudTrail::EventDataStore
Use the InsightsDestination property to specify the ARN (or ID suffix of the ARN) of the destination event data store that logs Insights events.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-eventdatastore.html #cloudtrail #cloudformation -
Have you ever thought about querying your #CloudTrail logs using #SQL with #Athena? 🏛️
This can actually be a great idea, especially if you are managing multiple AWS accounts!
If you want to find out more, check out our latest episode of #AWS Bites 👇
https://awsbites.com/94-get-the-most-out-of-cloudtrail-with-athena/
-
Updated AWS::CloudTrail::EventDataStore
Use the IngestionEnabled property to specify whether you want the event data store to ingest events.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-eventdatastore.html #cloudtrail #cloudformation -
Create an Organization CloudTrail with CloudFormation
~~
ACM. 202 Automating deployment of a trail to monitor events across all AWS accounts [key policy issues]
~~
by Teri Radichel | Apr 28, 2023
#cloudtrail #kms #s3 #policy #cloudformationhttps://medium.com/cloud-security/create-an-organization-cloudtrail-with-cloudformation-c27e7efe7044
-
Granting AWS Services Access to use a KMS Key
~~
ACM.201 Modifying our generic KMS key policy to allow services to use a key
~~
by Teri Radichel | Apr 25, 2023
#cloud #security #aws #kms #cloudtrail #policyhttps://medium.com/cloud-security/granting-services-access-to-use-a-kms-key-23d221a6fe01
-
Had a crazy busy day today. More #cloudsecurity blog posts tomorrow! Almost done with my last post on deploying an #AWS organization #CloudTrail after finalizing the #KMS key and #S3 bucket templates. https://medium.com/cloud-security
-
S3 Bucket for CloudTrail
~~~
ACM.195 Creating a bucket with a server access logging bucket
~~~
by Teri Radichel | Apr 19, 2023
#cloud #security #aws #cloudtrail #s3 #serveraccess #logging #cybersecurityhttps://medium.com/cloud-security/s3-bucket-for-cloudtrail-e603271a1bb5
-
Granting AWS CloudTrail and Users Permission to use a KMS Key
~~~
ACM.190 Complexities and Caveats when using a customer managed encryption key with CloudTrail logs
~~~
by Teri Radichel | Apr 14, 2023
#aws #cloudtrail #encryption #cloud #cyber #security https://medium.com/cloud-security/granting-aws-cloudtrail-and-users-permission-to-use-a-kms-key-85affe6c5504 -
AWS Organizations: Enable All Features
~~
ACM.188 Step one to set up AWS Organizations CloudTrail
~~
by Teri Radichel | Apr 13, 2023#cloudsecurity #aws #organizations #cloudtrail
https://medium.com/cloud-security/aws-organizations-enable-all-features-57b89b42bb06 -
Steps to Enable CloudTrail for an AWS Organization
~~~
ACM.187 View all your CloudTrail logs for an organization in one place
~~~
by Teri Radichel | April 12, 2023
#cloudsecurity #aws #cloudtrailhttps://medium.com/cloud-security/steps-to-enable-cloudtrail-for-an-aws-organization-bbf360b6315e
-
New AWS::CloudTrail::ResourcePolicy.ResourcePolicy
Use the ResourcePolicy property to specify the JSON-formatted string that contains the resource-based policy to attach to the CloudTrail channel.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudtrail-resourcepolicy-resourcepolicy.html #cloudtrail #cloudformation -
New AWS::CloudTrail::ResourcePolicy.ResourceArn
Use the ResourceArn property to specify the Amazon Resource Name (ARN) of the CloudTrail channel attached to the resource-based policy. The following is the format of a resource ARN: arn:aws:cloudtrail:us-east-2:123456789012:channel/MyChannel.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudtrail-resourcepolicy-resourcearn.html #cloudtrail #cloudformation -
New AWS::CloudTrail::ResourcePolicy
Use the ResourcePolicy resource to attach a resource-based permission policy to a CloudTrail channel that is used for an integration with an event source outside of AWS. For more information about resource-based policies, see CloudTrail resource-based policy examples in the CloudTrail User Guide.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudtrail-resourcepolicy.html #cloudtrail #cloudformation -
Analyzing CloudTrail Requests Related to SCPs: ACM.140 Trying to figure out conditions and ARNs to create a delegated administrator for SCPs
~~~~
by Teri Radichel | Jan 25, 2023
#cloudtrail #scp #iam #delegatedadministrator #cloudsecurity #governancehttps://medium.com/cloud-security/analyzing-cloudformation-requests-related-to-scps-7cd8647d1a07
-
"AWS CloudTrail vulnerability: Undocumented API allows CloudTrail bypass"
https://securitylabs.datadoghq.com/articles/iamadmin-cloudtrail-bypass/
-
#aws folks: check out this now-fixed vulnerability that someone found by observing AWS account traffic and parsing it. #iam #iamadmin #cloudtrail https://securitylabs.datadoghq.com/articles/iamadmin-cloudtrail-bypass/
-
@dob That's a big scope.
Some things we do to make our lives easier and doesn't cost $$$.
Enable #guardduty and pipe all the alerts into a slack channel (+email as well).
Enable #cloudtrail log everything to an #S3 bucket in another account. #cloudwatch alerts on auth failures (to slack + email (some go to pagerduty #infosec contact).
We also have some alerts on updates when a cidr is added to a #SecurityGroup.Don't use #ssh or #bastion/#JumpHosts use #ssm to run automations on the hosts (package install, service restarts etc) also to get a shell on a box (if needed at all). (you can use #TransitiveTags with #RoleAssumption to give granular access).
Using #ssm for console access also logs the entire session (including someone doingsudo su - rootetc!) into #S3Use #MicroSegmentation within our #vpc. Instances behind an #alb will only accept traffic from the #alb #SecurityGroup etc.. #rds, #elasticache willl only accept traffic from instances in the appropriate #SecurityGroup. (Basically we don't use cidr ingress rules, we use security group ids) (this works across accounts in the same region with peering, but not across regions however).
-
HIRING: Director, Security and Trust - Remote / United States - https://infosec-jobs.com/job/6579-director-security-and-trust-remote/ #InfoSec #infosecjobs #CyberSecurity #CyberCareer #cyberjobs #cybertalents #security #HITRUST #SIEM #CloudTrail #AWS #Azure #CEH #CISM #CISSP #Cloud #DevOps #PCI #Golang #qualys