Kuboid
Open Luck·Kuboid.in
Security BSides2023
Open in YouTube ↗

From Red to Blue: Security Strategies in Azure

BSidesSLC40 views27:08over 2 years ago

This talk explores common misconfigurations and attack vectors in Microsoft Azure environments, specifically focusing on identity and access management. It details techniques for abusing Azure AD Connect, service principals, and OAuth consent grants to achieve persistence and privilege escalation. The speaker provides actionable defense strategies for security professionals to audit and harden their cloud infrastructure. The presentation includes references to tools like AADInternals, Stormspotter, and AzureGoat for testing and research.

Why Your Azure AD Connect Server Is the Keys to the Kingdom

TLDR: Azure AD Connect servers are frequently overlooked targets that provide a direct path to domain dominance through credential theft. By abusing synchronization mechanisms like Password Hash Synchronization or Pass Through Authentication, attackers can extract credentials or forge authentication tokens. Security teams must treat these servers with the same level of protection as a Tier 0 domain controller to prevent complete environment compromise.

Cloud identity is the new perimeter, but the bridge between on-premises Active Directory and Microsoft Entra ID remains a massive, often neglected, attack surface. Many organizations treat their Azure AD Connect server as a simple utility, failing to realize that it holds the credentials necessary to bridge two worlds. If you are performing a red team engagement or a penetration test against an organization using a hybrid identity model, this server is your primary target.

The Mechanics of the Bridge

Azure AD Connect facilitates the synchronization of identities from on-premises Active Directory to the cloud. To do this, it requires significant privileges within the local domain. When an organization enables features like Password Hash Synchronization (PHS) or Pass Through Authentication (PTA), they are essentially granting the synchronization service account the ability to read and process sensitive credential data.

In a PHS configuration, the server periodically pulls password hashes from the local domain and pushes them to Entra ID. While these are technically hashes of hashes, they are sufficient for an attacker who has gained local administrative access to the server to perform offline cracking or, in some cases, pass-the-hash style attacks.

PTA is even more dangerous from an offensive perspective. It relies on an on-premises agent to validate authentication requests proxied from the cloud. If you compromise the host running this agent, you are sitting in the middle of the authentication flow. You can intercept credentials as they are validated against the domain controller, effectively turning the server into a credential harvesting machine.

Exploiting the Synchronization Service

Tools like AADInternals have fundamentally changed how we approach these environments. During an engagement, your first step should be to identify the synchronization method in use. You can query the Microsoft login endpoint to determine if a domain is managed or federated. If you find a managed domain, you are looking for the synchronization server.

Once you have local admin access on the sync server, you are not just a user; you are the gatekeeper. You can use o365creeper to validate account names against the tenant, allowing you to build a targeted list of users for password spraying or brute-forcing. Because these requests originate from legitimate Microsoft endpoints, they often bypass basic rate-limiting or anomaly detection that would trigger on direct login attempts.

The most critical risk, however, is the potential for Golden Ticket attacks. Because the sync server is constantly communicating with domain controllers to facilitate identity management, it often possesses the necessary permissions to request service tickets. If you can dump the memory of the process handling these requests, you can often extract the KRBTGT hash or other sensitive material, allowing you to forge tickets and maintain persistence long after your initial access is discovered.

The Danger of OAuth Consent Grants

Beyond the sync server, the OAuth 2.0 consent framework is a goldmine for persistence. When a user clicks "Accept" on an application permission request, they are granting that application access to their data, such as mail, calendars, or even administrative functions.

Attackers use phishing campaigns to trick users into granting these permissions to malicious applications. Once the consent is granted, the application retains access even if the user changes their password or enables multi-factor authentication. This is a classic Broken Access Control scenario. The application doesn't need the user's credentials; it has a persistent token.

During your assessment, use Stormspotter to map out the relationships between users, applications, and permissions. You will often find that users have granted "Read" or "Write" access to applications that have no business being in the environment. If you find a service principal with excessive permissions, you can use it to pivot through the cloud environment, exfiltrating data or creating new administrative accounts to ensure your access remains permanent.

Hardening the Environment

Defending against these techniques requires a shift in mindset. You cannot simply monitor for suspicious logins. You must audit the applications that have been granted consent. Use the Entra ID portal to review Publisher Verified Apps and restrict the ability of users to grant permissions to unverified third-party applications.

For the sync server, the defense is straightforward but difficult to implement: treat it like a domain controller. It should be hardened, monitored for any unauthorized process execution, and restricted from accessing the internet directly. If you are using PTA, ensure the server is isolated and that you are monitoring for any unusual service account activity.

If you want to practice these techniques in a controlled environment, deploy AzureGoat. It provides a realistic, vulnerable Azure environment that allows you to test your ability to steal tokens, abuse service principals, and escalate privileges without risking production data. The path from a simple phish to full tenant compromise is shorter than most administrators believe. Your job is to find that path before the real adversaries do.

Talk Type
talk
Difficulty
intermediate
Has Demo Has Code Tool Released


BSides SLC, RedRocks 2023

9 talks · 2023
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in