ROracle Cloud playbook · Compute and containers
Stolen instance principal credentials
The attacker gains a shell on an instance and reads the instance principal certificate from the instance metadata service at 169.254.169.254. From elsewhere, the attacker calls OCI APIs with the permissions of every dynamic group that matches the instance, and functions that use resource principals expose the same risk through their token files. Exclude the instance from its dynamic groups first, then capture memory and stop it.
Look here
| Log | Search for |
|---|---|
| Audit | Calls by the instance principal from addresses that are not the instance's own. data.identity.principalId is the instance OCID. Compare data.identity.ipAddress with the instance's own addresses |
| Logging Search, last 14 days | Calls by the instance principal in each compartment the dynamic group's policies reach. Add each of those compartments to the search: search "<compartment-ocid>/_Audit", "<compartment2-ocid>/_Audit" | where data.identity.principalId = '<instance-ocid>' | sort by datetime desc |
| Dynamic groups and policies | Rules that match the instance by instance.id or instance.compartment.id, and then the policies that name those groups: oci iam dynamic-group list -c <tenancy-ocid> --all |
| Functions | Code or logs that expose the OCI_RESOURCE_PRINCIPAL_RPST or OCI_RESOURCE_PRINCIPAL_PRIVATE_PEM files |
| VCN flow logs | Outbound connections from the instance to hosts it does not normally reach |
Contain
| # | Item |
|---|---|
| 1 | Find the instance's boot volume: oci compute boot-volume-attachment list -c <compartment-ocid> --availability-domain <ad> --instance-id <instance-ocid> |
| 2 | Back up the boot volume: oci bv boot-volume-backup create --boot-volume-id <ocid> --display-name <case-id> |
| 3 | Save the dynamic group's current matching rule: oci iam dynamic-group get --dynamic-group-id <ocid> |
| 4 | Exclude the instance by adding instance.id != '<instance-ocid>' to the saved rule. The update replaces the whole rule, for example: oci iam dynamic-group update --dynamic-group-id <ocid> --matching-rule "All {instance.compartment.id = '<compartment-ocid>', instance.id != '<instance-ocid>'}" |
| 5 | Cut the policy statements for that dynamic group to what the workload needs |
| 6 | Capture memory, then stop the instance: oci compute instance action --instance-id <ocid> --action SOFTSTOP |
Eradicate and recover
| # | Item |
|---|---|
| 1 | Find how the attacker reached the instance, and clean or rebuild it from a known-good image |
| 2 | Reverse everything the instance principal created in the window: users, keys, policies, pre-authenticated requests, instances |
| 3 | Narrow dynamic group rules to named instances or tags, and scope their policies to one compartment |
| 4 | Require version 2 of the instance metadata service (IMDS) on every instance: oci compute instance update --instance-id <ocid> --instance-options '{"areLegacyImdsEndpointsDisabled": true}' |
| 5 | Restrict SSH to the instance to the people the dynamic group's permissions are meant for |
Watch out
- Anyone who can SSH to the instance inherits its privileges. Treat every account on the host as having the dynamic group's permissions.
- Functions cache the resource principal token for 15 minutes, so a policy or dynamic group change reaches them late. IAM changes can take several minutes to reach every region, so confirm the change took effect before relying on it.
OCI CLI 3.94.2 help for compute boot-volume-attachment list, bv boot-volume-backup create, iam dynamic-group, compute instance action and compute instance update. Checked October 2026.