applied security research
Rik van Duijn - 15 okt 2020

Honeytokens using Azure Keyvaults

In 2017 Wesley and I gave a presentation at SHA2017 about honey/pot/tokens. We actually planned on building a fully fledged platform. But never came further then the POC phase of that project. This week we got a product demo from the guys at Thinkst, i’ve always loved this way of thinking: let the attacker come to you. During the demo I saw a cool honeytoken for o365. This gave me an idea to see if we could build tokens that could be used in Azure.

This week I had to deploy some new Azure Key Vault, vaults. We wanted to limit access to one service principal, limit the IP’s that were allowed to access the vault and log all access to Azure Sentinel. Our backend uses the service principal credentials to authenticate to the Key Vault and query the secrets.

While building this I worried about an attacker gaining access to the service principal credentials and stealing the information from the keyvault. The IP filter rule makes this more difficult for an attacker. But at the same time why not make extra keyvaults as a honeytoken? Leave them in repo’s, emails and documentation. The moment someone queries the vault we know someone stole our stuff! This type of token could be a nice indicator for when an attacker has already gained access to our environment. But is trying to escalate those privileges. We might want to give it an interesting name to make sure the attackers try and use it.

Building it

So how do we make this? Preferably in an automated manner so we can re-use it. There are some prerequisites, we assume you are already using Azure Sentinel to log stuff to. If you are using o365 but not logging to Sentinel you are missing out. (free SIEM essentially)

So I built a script that does the following:

  1. Creates a resource group to put everything in (easy cleanup)
  2. Creates a key vault
  3. Creates a service principal
  4. Gives the service principal read access to the newly created key vault
  5. Configure audit logging and send it to Sentinel.
  6. Output the tokens so we can spread them
  7. Generate KQL queries so we can detect the use of our tokens

After running the script it will look like this:

Detecting it

Now all audit log messages related to our newly created keyvault will be logged to our Sentinel. We can essentially alert on anything related to audit log. But to be sure no internal Azure processes trigger an alert we can filter on certain operations. We filter on the following operations:

  1. Authentication
  2. SecretGet
  3. SecretList

AzureDiagnostics
| where ResourceType == "VAULTS"
| where Resource == "HONEYTOKENSKV"
| where OperationName in ("SecretGet","Authentication", "SecretList")
| order by TimeGenerated desc

We can add this to a sentinel rule in order to check for someone accessing our keyvault. If you want to have this sent to a webhook or email you can build a playbook to automatically forward them.

bonus

We already have a service principal that we leak. What if the attacker doesnt know its supposed to be used for Azure Key Vault? We can monitor the log to see if someone logs into our AzureAD. I read a blog recently that describes the options to enable logging for the service principal logons. Essentially its: AzureAD->Monitoring->Diagnostic Settings . Here you can modify the entries being logged to your Sentinel environment.

We can use this log to query for logons from our service principal. So lets say we found the creds to a service principal and logged on:

we can then query for this in our Sentinel environment:
AADServicePrincipalSignInLogs
| where ServicePrincipalName == "honeytokensSP"

Conclusion

Honey pots and honey tokens can be a way of finding shenanigans with high reliability. The tokens, once used indicate an active attacker. Having these inside Azure can be of great benefit in detecting said shenanigans. This blog focuses on the key vault and service principal avenue. But way more can be thought of. Maybe a fake backup administrator with fake creds inside the description or Azure Functions app with an interesting name. The thing with honeypots and honeytokens is that many people still don’t place them. It’s a shame they can be quickly deployed and greatly improve the chances of detecting an attacker.

Blogs

Zolder.App LIVE Presentations

Erik Remmelzwaal - 11 jan 2021
During #CES2021 we will host a daily LIVE event in Microsoft Teams – OPEN FOR ALL, so also available for non-CES-visitors and non-Teams-users. Monday – Tuesday – Wednesday from 17:00 – 17:30 CET / 11:00 – 11:30 AM EST. The events will be hosted by Erik Remmelzwaal in English. The sessions will be opened for […] Lees verder

#CES2021 - We Are Ready!

Erik Remmelzwaal - 06 jan 2021
We are very excited to be part of the #CES2021NL mission! Meet us at CES (Januari 11-14) in our online booth 10609 and see how we solve global challenges with NLTech. Erik Remmelzwaal, Co-Founder & CEO Yes I indeed think we are ready for CES. At this virtual event we will showcase Zolder.App. I am […] Lees verder

Azure App Consent Policies

Rik van Duijn - 11 nov 2020
OAuth consent phishing has been on the rise for a while now. Unsurprisingly, Microsoft has gradually introduced measures to protect from this type of attack. Latest: Risk-Based Step-Up Consent. Lees verder

Honeytokens using Azure Keyvaults

Rik van Duijn - 15 okt 2020
In 2017 Wesley and I gave a presentation at SHA2017 about honey/pot/tokens. We actually planned on building a fully fledged platform. But never came further then the POC phase of that project. This week we got a product demo from the guys at Thinkst, i’ve always loved this way of thinking: let the attacker come […] Lees verder

Risk of exposed home automation services

Wesley Neelen - 24 sep 2020
At home, I am automating many things for fun. Currently I am using Home Assistant, an incredibly powerful piece of software for automating your home. Regularly I am combining the home automation experiences with security. Home automation is often related to physical things such as changing lights, moving curtains, opening door locks or turning the […] Lees verder

Hacking the traffic light of the future

Wesley Neelen - 06 aug 2020
Nowadays we are connecting everything we can think of to the internet. Usually to make our lives easier or more comfortable. Some of the new upcoming innovations are related to making our traffic smart with the goal to improve safety, comfort and the traffic flow. We dived into this technology to analyze the inner workings and identify potential security risks. Lees verder

Detect lateral movement with Azure Sentinel

Wesley Neelen - 01 jul 2020
Lately we have been setting up a the production network for our Zolder.App service. The network consists of multiple segments separated by a firewall. As an addition we wanted to add monitoring features into the network. If an attacker is in our network, we would like to get a notification. Lees verder

Detecting BEC fraud using Azure Sentinel

Rik van Duijn - 17 jun 2020
Business Email Compromise (BEC) Fraud inflicts the most damage of all types of cybercrime, according to the FBI. How to detect such attacks using Azure Sentinel? Rik shares some actual possibilities. Lees verder

Phishing aftercare

Rik van Duijn - 26 mei 2020
This blog is part of our Office 365 attack & defense series. We also maintain a Github page where we share our Office 365 tools and queries. We often get sent phishing emails by family and friends. Not to phish us but because we ask family and friends to forward them to us. Sometimes they […] Lees verder

Inside a phishing panel

Wesley Neelen - 20 mei 2020
Dutch and Belgium citizens are receiving phishing attacks every day. But how does that exactly work? Lees verder

Office 365 - Exchange rules

Rik van Duijn - 13 mei 2020
This blog is part of our Office 365 attack & defense series. We also maintain a Github page where we share our Office 365 tools and queries. Exchange rules can be useful in managing the emails we receive on a daily basis. For example, it allows users to automatically respond or move specific emails to […] Lees verder

Office 365 - malicious applications

Wesley Neelen - 05 mei 2020
Wesley dives into the App Registrations feature of Microsoft Azure Active Directory. Finds ways to abuse it through delegate & application permissions and shares ideas howto protect from such abuse. Lees verder

Windows terminal profile fun

Rik van Duijn - 24 apr 2020
Rik plays around with the preview version of Windows Terminal to find manipulation options. Lees verder

Building a Zolder logo

Wesley Neelen - 22 apr 2020
Wesley writes about his most recent IoT project: building a Zolder logo with WS2812B ledstrips behind it, to give it some cool effects. Lees verder