Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community

AWS CloudTrail - "whois" Organization Whitelist

Copper Contributor

Hi all,

 

I'm trying to creat a custom alert trigger in Sentinel, to filter source ip addresses from my cloudtrail logs, as I've whitelisted ips (vpn) well defined.

 

However some services like autoscaling, they use some internal Aws IPs which I do not have control over.

My question is: Is there a way to whitelist, and exclude these ips from my query, using some sort of whois organization response attribute?

 

If any has some guidance, it would be very helpful. Coding and integrations are also welcom.

 

Best regards,

Siedlarczyk

6 Replies
Additional protection against web attacks using conditions that you specify. You can define conditions
by using characteristics of web requests such as the following:
• IP addresses that requests originate from.
• Country that requests originate from.
• Values in request headers.
• Strings that appear in requests, either specific strings or string that match regular expression (regex)
patterns.
• Length of requests.
• Presence of SQL code that is likely to be malicious (known as SQL injection).
• Presence of a script that is likely to be malicious (known as cross-site scripting).
• Rules that can allow, block, or count web requests that meet the specified conditions. Alternatively,
rules can block or count web requests that not only meet the specified conditions, but also exceed a
specified number of requests in any 5-minute period.
• Rules that you can reuse for multiple web applications.
• Managed rule groups from AWS and AWS Marketplace sellers.
• Real-time metrics and sampled web requests.
• Automated administration using the AWS WAF API.
Hi Lewis, thanks for the response.

I believe my challenge is a little bit different. I want to exclude Amazon ASNs IPs from the query, just to monitor outside Amazon ones.
I would like to do something like a whois, get the org name Amazon, and if it matches, do not trigger.
I just couldn't find a way to use this sort of intel or command in the log query.

Best regards,
Lucas

@Siedlarczyk95 Sounds like you would need to create a logic app that makes the queries to whois to get the information you need and update a custom log with that information.

 

I do not have the exact code you would need but you can look at the Azure Sentinel on getting Teams information to give you an idea of how to start.

@Gary Bushey 

 

Hi Gary, thanks for the response.

 

I thought about that, but not sure how to stream the data to get it queried from whois.

As logic apps connectors for Sentinel are basically based on alerts, the nois would be huge if I used this approach.

 

Do you have a suggestion on that?

 

Best regards.

Lucas

@Siedlarczyk95 This would a straight Logic App, not a Playbook so you could set up to use the Recurrence trigger and use the HTTP action to call whois (assuming you can make a REST call to get the data you need)

 

@Siedlarczyk95 This may be along the lines of what you are looking for. I wanted to create tickets in an ITSM for alerts in Sentinel and instead of having to constantly lookup the location and owner of the IP addresses, I used a rest api call via Logic Apps to get the IP owner https://ipapi.co/8.8.8.8/org so this could be added to the ticket on creation.

 

This won't necessarily let you alert for non-Amazon IPs since the alert would've already occurred.

 

I also wanted to get information on where connections to our Cisco ASA were coming from geographically so I used another logic app to lookup IPs for their location, owner etc.

 

For this you would need a csv file in blob storage with the defined headers you are looking for e.g. IP, Location, Owner

 

I used a recurringly triggered logic app to run a log analytics query to get a list of IPs and then conditionally check the csv for the IP to make sure it wasn't already there (to avoid going over the api rate limit looking up IPs twice). 

 

If the IP isn't in the file, you would then call the api and add the information as a new line to the csv file.

 

You could then use externaldata to lookup this information in log analytics and create alerts based on a query that excludes Amazon owned IPs.

 

I used the code below to generate a map showing the places connections were being made from to our ASA. The URL for the blob was generated by clicking on generate SAS under the storage account > containers > file.

 

externaldata(ip:string, country_code:string)
[h"https://my.blob.core.windows.net/mycontainer/iplookup.csv?sp=sharedaccesssignature"]
| join kind= inner (
CommonSecurityLog
| where TimeGenerated {TimeRange}
| extend day=dayofmonth(TimeGenerated)
| where Message contains "%ASA:  Group <GroupPolicy_VPN> User"
| parse Message with *"> User <" User ">"*
| parse Message with *"> IP <" ConnectingIP ">"*
) on $left.ip == $right.ConnectingIP
| distinct User, country_code
| summarize count(User) by country_code