PIVTR-D
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

LogSearch for
AuditCalls 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 daysCalls 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 policiesRules 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
FunctionsCode or logs that expose the OCI_RESOURCE_PRINCIPAL_RPST or OCI_RESOURCE_PRINCIPAL_PRIVATE_PEM files
VCN flow logsOutbound connections from the instance to hosts it does not normally reach

Contain

#Item
1Find the instance's boot volume: oci compute boot-volume-attachment list -c <compartment-ocid> --availability-domain <ad> --instance-id <instance-ocid>
2Back up the boot volume: oci bv boot-volume-backup create --boot-volume-id <ocid> --display-name <case-id>
3Save the dynamic group's current matching rule: oci iam dynamic-group get --dynamic-group-id <ocid>
4Exclude 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>'}"
5Cut the policy statements for that dynamic group to what the workload needs
6Capture memory, then stop the instance: oci compute instance action --instance-id <ocid> --action SOFTSTOP

Eradicate and recover

#Item
1Find how the attacker reached the instance, and clean or rebuild it from a known-good image
2Reverse everything the instance principal created in the window: users, keys, policies, pre-authenticated requests, instances
3Narrow dynamic group rules to named instances or tags, and scope their policies to one compartment
4Require version 2 of the instance metadata service (IMDS) on every instance: oci compute instance update --instance-id <ocid> --instance-options '{"areLegacyImdsEndpointsDisabled": true}'
5Restrict 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.

Adapts material from Dynamic Incident Response: A Framework for Security Teams by Joshua Wright, © 2026 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute, licensed under CC BY 4.0. Figures reproduced under that license. Changes were made. Not published by, endorsed by, or affiliated with the SANS Institute.