Lesson 5 of 5 Azure Key Vault

Detecting Exposed Secrets and Vault Threats

This lesson explains agentless secrets scanning and the Defender for Key Vault plan.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how agentless secrets scanning works.
  • Identify the plans that provide it.
  • Describe how to respond to an exposed secret.
  • Explain what Defender for Key Vault detects.

Why secrets end up on disks

Credentials appear in places that nobody intended: an SSH private key left in a home directory, a storage key in a script, a database password in a configuration file, or a token in a shell history file. If an attacker reaches a machine, these items offer a way to move to other resources, which is known as lateral movement. A machine with a modest role can therefore lead to a critical one.

Agentless secrets scanning in Defender for Cloud finds these credentials. Microsoft states that scanning machines for supported secrets is available when either Defender CSPM or Defender for Servers Plan 2 is enabled. It works on Azure VMs, and on AWS and GCP instances that are connected to Defender for Cloud.

How the scan works

The process runs outside the machine. Defender for Cloud takes a snapshot of the disks, analyses it in a secure environment, and deletes it. No agent is needed, nothing runs in the guest, and the machine's performance is not affected. Secrets scanning shares this mechanism with agentless vulnerability scanning, which the lesson on agentless scanning describes in full.

Findings appear as recommendations: Machines should have secrets findings resolved for Azure, EC2 instances should have secrets findings resolved for AWS, and VM instances should have secrets findings resolved for GCP. The value of the finding comes from context. With Defender CSPM, attack path analysis can show that a key found on an internet-exposed VM grants access to a sensitive storage account, which is far more urgent than a similar key that reaches nothing. Cloud security explorer can query for such machines directly.

True or false

Agentless secrets scanning

Exam skills 1.2.6

Check how agentless secrets scanning works.

Log in to try this activity Interactive activities are free with an account.

Responding to a finding

Finding a secret does not fix anything, and removing it from the disk is not sufficient. Treat an exposed credential as compromised, because you cannot tell who has read it.

  1. Assess

    Determine what the secret reaches, using attack paths or the owning team's knowledge.

  2. Rotate

    Replace the credential at its source, so that the exposed value stops working.

  3. Remove

    Delete it from the disk and from any backups or images in which it persists.

  4. Redesign

    Move the workload to a managed identity, or to a Key Vault reference, so that the problem does not return.

Scanning machine disks is only one of several routes. Defender for Cloud DevOps security and GitHub secret scanning find secrets in code repositories. Choose based on where the secret lives: a repository needs code scanning, and a disk needs machine scanning.

Scenario questions

Where secrets live

Exam skills 1.2.6

Choose the scanning approach for where the secret lives.

Log in to try this activity Interactive activities are free with an account.

Defender for Key Vault

Defender for Key Vault is a workload protection plan that detects unusual and potentially harmful attempts to access or exploit vaults. It does not change access control. It is threat detection that analyses how the vault is used, and it needs no agent and no change to the vault.

Enable it in Defender for Cloud under Environment settings, on the Defender plans page, normally at subscription level so that new vaults are covered automatically. Alerts appear on the vault's Security page, on the Workload protections page, and on the security alerts page, and they can be emailed to designated contacts.

Alerts describe situations such as access from a suspicious IP address, access from an unusual application or user, and an unusually large number of secret retrievals. When an alert fires, identify the caller from the alert and the vault's logs, decide whether the activity was authorized, and if not, disable the principal, rotate everything that it could reach, and tighten network and access settings. Diagnostic logging makes this far easier, as AuditEvent entries show which objects were read.

Select all that apply

Defender for Key Vault

Exam skills 1.2.7

Identify what Defender for Key Vault does.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing the right control

A company wants to know whether any VM contains a plain-text storage account key, and whether anyone is retrieving secrets from a vault in an unusual pattern. It has Defender for Cloud with Foundational CSPM only. Which plans should it enable, and which should it not rely on?

The first requirement needs agentless secrets scanning, which needs Defender CSPM or Defender for Servers Plan 2. Foundational CSPM does not include it. The second requirement needs Defender for Key Vault, which analyses access patterns.

Azure Policy could require that secrets have expiry dates, but it would find neither a key on a disk nor unusual retrieval. Key Vault diagnostic logs record access, but on their own they raise no alerts.

Check yourself

A storage key is found on a VM's disk. Why is deleting the file not enough?

Show answer

Someone may already have read it, so treat it as compromised, and rotate the key at its source.

Exam Tips

Remember for the exam

  • Secrets scanning needs Defender CSPM or Defender for Servers Plan 2.
  • Treat an exposed secret as compromised, and rotate it before removing it.
  • Defender for Key Vault detects threats; it does not control access.
  • Attack paths show which exposed secrets matter most.