home.social

#cloudtrail — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #cloudtrail, aggregated by home.social.

  1. 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 enough

    I 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 them

    At 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 to

    What 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 pipes

    I wrote about my frustrations in this article: [advancedweb.hu/cloudtrails-hor.

    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.

    #aws #cloudtrail #eventbridge

    Originally published [on my blog](advancedweb.hu/shorts/how-hard)

  2. 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 enough

    I 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 them

    At 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 to

    What 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 pipes

    I wrote about my frustrations in this article: [advancedweb.hu/cloudtrails-hor.

    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.

    #aws #cloudtrail #eventbridge

    Originally published [on my blog](advancedweb.hu/shorts/how-hard)

  3. 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 enough

    I 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 them

    At 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 to

    What 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 pipes

    I wrote about my frustrations in this article: [advancedweb.hu/cloudtrails-hor.

    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.

    #aws #cloudtrail #eventbridge

    Originally published [on my blog](advancedweb.hu/shorts/how-hard)

  4. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  5. 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!

  6. 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!

  7. 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!

  8. 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!

  9. 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!

  10. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  11. Updated AWS::CloudTrail::EventDataStore

    Use the FederationEnabled property to specify whether you want to federate the event data store.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  12. 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

    medium.com/cloud-security/usin

  13. 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

    medium.com/cloud-security/usin

  14. 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

    medium.com/cloud-security/usin

  15. 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

    medium.com/cloud-security/usin

  16. 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

    medium.com/cloud-security/usin

  17. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  18. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  19. 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 👇

    awsbites.com/94-get-the-most-o

  20. Updated AWS::CloudTrail::EventDataStore

    Use the IngestionEnabled property to specify whether you want the event data store to ingest events.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  21. 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 #cloudformation

    medium.com/cloud-security/crea

  22. 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 #policy

    medium.com/cloud-security/gran

  23. 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. medium.com/cloud-security

  24. 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 medium.com/cloud-security/gran

  25. 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 #cloudtrail

    medium.com/cloud-security/step

  26. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  27. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  28. 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.
    docs.aws.amazon.com/AWSCloudFo #cloudtrail #cloudformation

  29. 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 #governance

    medium.com/cloud-security/anal

  30. #aws folks: check out this now-fixed vulnerability that someone found by observing AWS account traffic and parsing it. #iam #iamadmin #cloudtrail securitylabs.datadoghq.com/art

  31. @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 doing sudo su - root etc!) into #S3

    Use #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).

    #aws