Skip to main content

More Info:

Compute instances should disable legacy Instance Metadata Service (IMDSv1) endpoints. IMDSv1 is vulnerable to SSRF attacks that can expose instance credentials to attackers

Risk Level

Medium

Address

Compliance, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Below are step‑by‑step console instructions to disable Instance Metadata Service v1 (IMDSv1) on an OCI Compute instance (e.g., an instance used for monitoring), leaving only IMDSv2 enabled.Note: This is done per instance by updating the “Instance Metadata Service Version” setting.

1. Identify the compute instance

  1. Sign in to the OCI Console.
  2. In the left menu, go to: ComputeInstances.
  3. In the Compartment selector, choose the compartment where your monitoring instance resides.
  4. Click the Name of the target instance (the one used for monitoring).

2. Open the Instance Details and Edit Settings

  1. You are now on the Instance details page.
  2. Click the More actions button (three dots) in the top right (or use the Edit button, depending on the current UI).
  3. Select Edit (or Edit instance details).

3. Change the Metadata Service Version

In the Edit panel/page:
  1. Scroll down to the Instance metadata service section.
  2. Locate the setting typically labeled:
    • “Instance metadata service version”, or similar.
  3. Set it to:
    • V2 only (or Use only version 2, depending on UI wording).
  4. Ensure that “Allow metadata service v1” (or equivalent toggle) is disabled / unchecked.
This setting enforces IMDSv2 and implicitly disables IMDSv1.

4. Save the Changes

  1. Review the changes.
  2. Click Save changes or Update.
No reboot is typically required for the IMDS version setting to take effect, but:
  • If you have any custom agents or scripts on the monitoring instance that query IMDSv1 endpoint (http://169.254.169.254/opc/v1/...), update them to use IMDSv2 semantics (including the session token flow) before making this change.

5. (Optional) Confirm IMDSv1 Is Disabled

From within the instance (SSH):
  1. Try to call an IMDSv1 endpoint:
    It should fail (e.g., 401/403 or similar denial).
  2. Use the IMDSv2 token flow to confirm IMDSv2 still works:
This completes the remediation: IMDSv1 disabled, IMDSv2 enforced for your OCI compute monitoring instance.
To disable OCI Instance Metadata Service v1 (legacy endpoint) for your Compute instances (including those used for monitoring) via OCI CLI, you need to update the instance’s metadata service configuration.

1. Prerequisites

  • OCI CLI installed and configured (oci setup config)
  • Permissions: ability to inspect and update instances in the target compartment/tenancy.

2. Find the instance OCID(s)

List instances in a compartment:
Note the id (instance OCID) for each instance you want to fix.

3. Check current IMDS configuration (optional)

You’ll see something like:

4. Disable IMDSv1 (legacy endpoint) on an existing instance

Run:
You can keep other fields if you want (e.g., maxAttempts / sessionDurationInSeconds):
This switches the instance to IMDSv2-only. No reboot is typically required.

5. Apply to all monitoring instances (batch)

Example bash loop for all running instances in a compartment:
Use a narrower filter (tags, display-name) if you only want monitoring-related instances.

6. Ensure future instances are compliant

If you use instance configurations (e.g., for autoscaling / instance pools used for monitoring), update the configuration as well:
New instances launched from that configuration will have IMDSv1 disabled.
To disable OCI Instance Metadata Service v1 (legacy endpoints) using Python, you need to set the are_legacy_imds_endpoints_disabled flag on the instance options via the OCI Python SDK.Below is step‑by‑step remediation for existing and new instances.

1. Prerequisites

  1. Install the OCI Python SDK:
  1. Configure your OCI credentials (e.g. ~/.oci/config):

2. Disable IMDSv1 on an existing instance

This:
  • Keeps IMDSv2 enabled
  • Disables legacy metadata endpoints (IMDSv1 paths such as /opc/v1/...).
No reboot is usually required, but verify any applications relying on IMDSv1 first.

3. Ensure all new instances have IMDSv1 disabled

When launching instances (e.g. for monitoring agents), set the same flag in LaunchInstanceDetails:

4. Verifying from the instance (optional)

From the instance, IMDSv1 endpoints (e.g. curl http://169.254.169.254/opc/v1/instance/) should return an error or no data, while IMDSv2 endpoints (e.g. /opc/v2/instance/) remain available according to OCI docs for your region/shape.This is sufficient to satisfy the requirement: “OCI Compute Instance Metadata Service V1 Should Be Disabled” for your monitoring instances using Python automation.
This updates the instance’s metadata service to disable legacy IMDSv1; it should not force replacement, but may require a reboot depending on OCI behavior and current state.To verify, terraform plan should show an in-place update setting instance_options.are_legacy_imds_endpoints_disabled from false (or unset) to true on the affected oci_core_instance resource.