More Info:
Compute instances should disable legacy Instance Metadata Service (IMDSv1) endpoints. IMDSv1 is vulnerable to SSRF attacks that can expose instance credentials to attackersRisk Level
MediumAddress
Compliance, SecurityCompliance 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
Remediation
Using Console
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
- Sign in to the OCI Console.
- In the left menu, go to: Compute → Instances.
- In the Compartment selector, choose the compartment where your monitoring instance resides.
- Click the Name of the target instance (the one used for monitoring).
2. Open the Instance Details and Edit Settings
- You are now on the Instance details page.
- Click the More actions button (three dots) in the top right (or use the Edit button, depending on the current UI).
- Select Edit (or Edit instance details).
3. Change the Metadata Service Version
In the Edit panel/page:- Scroll down to the Instance metadata service section.
- Locate the setting typically labeled:
- “Instance metadata service version”, or similar.
- Set it to:
- V2 only (or Use only version 2, depending on UI wording).
- Ensure that “Allow metadata service v1” (or equivalent toggle) is disabled / unchecked.
4. Save the Changes
- Review the changes.
- Click Save changes or Update.
- 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):- Try to call an IMDSv1 endpoint:
It should fail (e.g., 401/403 or similar denial).
- Use the IMDSv2 token flow to confirm IMDSv2 still works:
Using CLI
Using CLI
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.
Note the
You’ll see something like:
You can keep other fields if you want (e.g., maxAttempts / sessionDurationInSeconds):This switches the instance to IMDSv2-only. No reboot is typically required.
Use a narrower filter (tags, display-name) if you only want monitoring-related instances.
New instances launched from that configuration will have IMDSv1 disabled.
1. Prerequisites
- OCI CLI installed and configured (
oci setup config) - Permissions: ability to
inspectandupdateinstances in the target compartment/tenancy.
2. Find the instance OCID(s)
List instances in a compartment:id (instance OCID) for each instance you want to fix.3. Check current IMDS configuration (optional)
4. Disable IMDSv1 (legacy endpoint) on an existing instance
Run:5. Apply to all monitoring instances (batch)
Example bash loop for all running instances in a compartment: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:Using Python
Using Python
To disable OCI Instance Metadata Service v1 (legacy endpoints) using Python, you need to set the
This:
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
- Install the OCI Python SDK:
- Configure your OCI credentials (e.g.
~/.oci/config):
2. Disable IMDSv1 on an existing instance
- Keeps IMDSv2 enabled
- Disables legacy metadata endpoints (IMDSv1 paths such as
/opc/v1/...).
3. Ensure all new instances have IMDSv1 disabled
When launching instances (e.g. for monitoring agents), set the same flag inLaunchInstanceDetails: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.Using Terraform
Using Terraform
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.
