Course contentsShow
← Security
Lesson 1939 of 3,05239. Cloud Security - Compute and ServerlessFree lesson

IMDS Security Best Practices and Monitoring

Enforce IMDSv2-only mode, monitor unusual IMDS queries, and implement defense-in-depth for metadata service access.

IMDS Security Best Practices and Monitoring

What You'll Learn

You'll learn how to enforce the most secure IMDS configuration, detect suspicious access patterns, and build layered defenses around metadata service access.

Pulling Together Defense-in-Depth for IMDS

Now that you understand individual IMDS protections, it's time to implement a comprehensive defense strategy. Think of this like securing a vault: you need the right lock (IMDSv2), guards watching for unusual activity (monitoring), and multiple barriers (defense-in-depth).

Enforce IMDSv2-Only Mode

Your first line of defense is making IMDSv2 mandatory across all instances. This prevents SSRF attacks that rely on simple GET requests. Configure instance metadata options to require session tokens:

HttpTokens: required
HttpPutResponseHopLimit: 1

Use infrastructure-as-code policies to prevent anyone from launching instances with IMDSv1 enabled. This is like changing all building locks to require biometric access—no more simple keys.

Monitor Unusual IMDS Queries

Enable CloudTrail data events or VPC Flow Logs to track IMDS access patterns. Watch for:

  • High-frequency metadata requests (possible credential harvesting)
  • Access from unexpected processes or users
  • Queries to sensitive paths like IAM role credentials outside normal application patterns

Set up alerts when access volumes spike or when dormant instances suddenly query IMDS—these often indicate compromise.

Implement Defense-in-Depth

Layer multiple controls:

  • Network layer: Use hop limit restrictions and security groups
  • Application layer: Block IMDS in application proxies and web frameworks
  • IAM layer: Use minimal instance role permissions
  • Detection layer: Monitor CloudTrail and application logs for metadata access

This multi-layered approach ensures that even if one control fails, others catch the threat.

Key Takeaway:
Enforce IMDSv2-only mode organization-wide, actively monitor metadata access patterns for anomalies, and implement multiple overlapping security controls to protect this critical attack surface.