What is an OCI Instance Principal?

OCI Instance Principal is a key feature in Oracle Cloud Infrastructure's Identity and Access Management (IAM) that lets a compute instance prove its identity and make authorized API calls to other OCI services. It provides a secure, credential-free way for workloads like virtual machines to access resources such as Object Storage, Databases, or Secrets Vaults in your tenancy - removing the need to store or manage long-lived credentials on the instance.

oracle

Understanding OCI Instance Principals

An OCI Instance Principal is an IAM feature in Oracle Cloud Infrastructure that gives a compute instance a unique identity. This lets the instance authenticate with other OCI services and make authorized API calls without using traditional user credentials or API keys. OCI automatically creates and manages this identity, allowing applications on the instance to access services securely without handling credentials.

A Plain-Language Explanation

You can think of an OCI Instance Principal as a digital passport and work badge for your cloud server.

When you launch a virtual machine (VM) or container in OCI, it needs to access other services to do its job. For example, a web server might need to save log files to Object Storage, or an application might need to retrieve a database password from the Secrets Vault.

Instead of creating a user account, generating an API key, and storing that key on the server - a significant security risk - OCI assigns an identity directly to the instance. This identity is called the Instance Principal.

OCI creates and manages this identity using cryptography. When the instance requests another service, the OCI SDK retrieves a temporary certificate from the instance metadata service, which the application then uses to cryptographically sign the request. OCI IAM then verifies the signature and checks:

  • "Do I recognize this server's identity?"
  • "What permissions does this server have?"

The instance is treated like a full member in IAM - just like a human user or a service account.

How Authentication Typically Works in Cloud Environments

Before Instance Principals and similar features in other clouds, securing communication between services was often difficult. Here's how cloud service authentication has evolved:

  1. Hardcoded Credentials - The earliest and least secure method. Developers would put usernames, passwords, or API keys directly into application code or config files on the instance. This often caused leaked keys, made rotation hard, and created accountability problems.
  2. API Keys for Service Accounts - A better approach where a special IAM user (service account) is created for the application. The API key is stored on the instance. Although safer than using human credentials, this key is still long-lived and must be manually rotated and protected on the file system.
  3. IAM Roles / Instance Profiles (The Cloud-Native Way) - This is where Instance Principals come in. In modern cloud architecture, the fundamental goal is credential-free access. The cloud provider manages temporary, rotating credentials for the compute instance, and the instance receives its authorization purely through IAM policies tied to its unique identity. This is the gold standard for Oracle Cloud Infrastructure authentication.

How OCI Instance Principals Allow Instances to Access Other OCI Services Securely Without Storing Credentials

This eliminates the need to generate, distribute, rotate, or store long-lived API keys - removing an entire class of credential management risk that is one of the most common causes of cloud breaches.

The Credential-Free Flow

  1. Identity Binding - When you launch an instance, OCI associates the instance's OCID with the metadata service endpoint. When the instance makes a request to the metadata service, it proves its identity as that OCID, and the metadata service returns temporary credentials based on that binding.
  2. Request Signing - When an application on the instance needs to access an OCI service (like listing buckets in Object Storage), it doesn't use a key from a config file. Instead, the OCI SDK or CLI automatically contacts the instance metadata service.
  3. Token Exchange - The metadata service provides a temporary, short-lived X.509 certificate and associated private key based on the instance's identity. The SDK uses this certificate and key to cryptographically sign the API request.
  4. Authorization Check - When the request reaches the OCI service, OCI IAM intercepts it, verifies the cryptographic signature using the instance's identity, and checks IAM policies to confirm if the Instance Principal is permitted to perform the action.
  5. Access Granted - If the policy grants permission, the request proceeds. If not, access is denied.
Key point: The application never deals with long-lived passwords or API keys. Credentials are temporary and automatically refreshed by the cloud, greatly reducing the risk of compromise.

The Role of IAM Policies and Dynamic Groups in Enabling Instance Principals

Instance Principals become truly powerful only when integrated with two core OCI IAM components: Dynamic Groups and IAM Policies.

Dynamic Groups: Defining the Identity

Since an Instance Principal's identity is an OCID, we can't create an IAM policy for every single instance. Dynamic Groups solve this by allowing you to group compute instances based on defined rules - much like a Smart Folder.

Example Dynamic Group Rule

This rule creates a group containing all instances in the AppServer-Compartment that have the tag Project set to CyberGlossary:

 

All {instance.compartment.id = 'ocid1.compartment.oc1..aaaaaxxxxexample',
 instance.tag.Project.value = 'CyberGlossary'}

 

Every instance matching this rule automatically becomes a "member" of this Dynamic Group.

IAM Policies: Granting Permissions

Once the Dynamic Group is defined, you write an IAM Policy that grants specific permissions to that group - granting permissions to every Instance Principal within it.

Example Policy Statement

 

Allow dynamic-group CyberGlossary-AppServers to manage objects
 in compartment AppData-Compartment
 where all {target.bucket.name = 'App-Logs-Bucket'}

 

This policy allows any instance in the CyberGlossary-AppServers dynamic group to upload, read, and delete objects in that specific Object Storage bucket. No API keys are needed.

Real-World Example Scenarios

Scenario 1: Instance Accessing Object Storage

A batch processing VM needs to read source data from an Object Storage bucket and write processed results back to a different bucket.

Setup Steps:

  1. Dynamic Group: Create a Dynamic Group called Batch-Processor-Group with a rule matching all batch VMs in the Processing compartment.
  2. IAM Policy:

     

    Allow dynamic-group Batch-Processor-Group to read objects
     in compartment RawData-Compartment
     where target.bucket.name = 'Input-Data'
    
    Allow dynamic-group Batch-Processor-Group to write objects
     in compartment Results-Compartment where target.bucket.name = 'Output-Data'

     

  3. Application Code: The application uses the OCI SDK. When it attempts to read the input bucket, the SDK automatically retrieves and uses the Instance Principal identity for authentication. Access is seamlessly granted according to the policy.

Scenario 2: Instance Retrieving Secrets

A Kubernetes worker node needs to retrieve a PostgreSQL database connection string securely stored in OCI Vault.

Setup Steps:

  1. Dynamic Group: Create a Dynamic Group called K8S-Worker-Group with a rule matching the worker nodes based on their resource tags or compartment.
  2. IAM Policy:

     

    Allow dynamic-group K8S-Worker-Group to read secret-bundle
     in compartment Prod-Secrets-Compartment
     where target.secret.name = 'Postgres-Connection-String'

     

  3. Application Execution: The application or startup script calls the OCI Secrets service through the SDK. The request is signed by the Instance Principal and verified by OCI IAM, so the application retrieves the secret securely. The sensitive credential never gets stored unencrypted on the instance, and no API key is used.

Security Benefits of Using Instance Principals Instead of API Keys

Using OCI Instance Principals over traditional API keys is a significant step toward a stronger security posture.

Security Aspect Instance Principal API Key
Credential Lifetime Extremely short-lived (automatically refreshed) Long-lived until manually rotated
Credential Storage No credentials stored on the instance file system Must be stored on the file system, making it a target for compromise
Rotation Automatic and managed by OCI Manual, often neglected, and complex to coordinate
Scope of Access Defined by granular, auditable Dynamic Group policies Defined by the IAM User's total permissions; keys often have over-privileged access
Compromise Risk Lower - compromising the instance does not immediately reveal a long-lived secret Higher - a compromised instance gives an attacker a static, reusable key
Auditability Access logs clearly show the Instance OCID as the source Logs show the IAM User ID, but tracking which instance used the key is harder

Common Misconfigurations and Risks

While Instance Principals are secure by design, they can be misconfigured, creating unintended security gaps.

The Risk of Over-Privileged Policies

The most common mistake is granting the Dynamic Group overly broad permissions.

Bad Example:

 

Allow dynamic-group Batch-Processor-Group to manage all resources in tenancy

 

If one VM in that group is compromised, an attacker could control every resource in your OCI tenancy. Following the principle of Least Privilege is essential.

Incorrect Dynamic Group Rules

If a Dynamic Group rule is too broad (e.g., including instances across many environments), a development instance could accidentally gain access to production resources simply by matching the rule criteria. Dynamic Group rules should always be specific, using instance OCIDs, compartment OCIDs, or unique tags to ensure proper isolation.

Relying on Instance Metadata for Sensitive Information

While the Instance Metadata Service is essential for the Instance Principal flow, it should never be used to store or retrieve highly sensitive, long-lived data. Applications should not unnecessarily expose this service locally.

Misunderstanding inspect vs read Permission Verbs

OCI defines a hierarchy of permission verbs: inspect, read, use, and manage. A common misconfiguration occurs when administrators confuse the scope of inspect and read. According to OCI documentation, inspect is designed for third-party auditors and provides visibility into resource existence and metadata only. The read verb grants actual data access, intended for internal auditors who need to view resource contents.

When both verbs are assigned to the same principal, either through overlapping group memberships or overly broad policies, an unintended attack path emerges. The inspect capability allows the principal to discover the existence and names of sensitive resources (such as Object Storage buckets), while the read capability then allows downloading their contents. For Dynamic Groups tied to Instance Principals, this means a compromised instance could enumerate and exfiltrate data across compartments if its policies are not tightly scoped to specific resources.

Why Instance Principals Matter: An Offensive Perspective

The security benefits of Instance Principals become clear when examining how attackers target OCI environments that rely on static credentials instead.

Static Credentials Are a Primary Target

When applications store OCI API keys in configuration files (such as ~/.oci/config and associated .pem files), any vulnerability that grants filesystem access puts those credentials at risk. In real-world attacks, techniques like Local File Inclusion (LFI) chained with Remote Code Execution (RCE) have been used to extract OCI credentials directly from compromised instances. Once an attacker obtains a valid API key and private key, they can authenticate as that identity from any location and begin enumerating the environment.

Post-Compromise Enumeration and Lateral Movement

With stolen OCI credentials, attackers follow a predictable pattern. They identify the tenancy and compartment hierarchy, enumerate group memberships to understand the principal's permissions, and then use tools like oci-enum and oci-hunter to systematically discover accessible resources across compartments. If the compromised identity has read permissions on Object Storage or read access to OCI Vault secrets, sensitive data can be exfiltrated without triggering the access controls that were intended to prevent it.

Instance Principals eliminate this attack vector entirely. Because there are no static credentials stored on the filesystem, an LFI or filesystem traversal attack finds nothing to steal. Even if an attacker gains code execution on the instance, the temporary tokens used by Instance Principals are short-lived and scoped to the instance's metadata service, making them far harder to extract and reuse externally.

Real-World Context

In 2025, security advisories from CloudSEK, FINRA, and CISA raised concerns about a claimed breach involving Oracle Cloud Infrastructure's authentication systems. According to these reports, attackers may have gained access to credential materials, giving them the ability to impersonate legitimate OCI users. Organizations that had migrated to Instance Principals and eliminated static API keys from their environments were better positioned to contain the blast radius of such credential-based attacks.

Best Practices for Securely Implementing Instance Principals

  1. Adhere to Least Privilege - Every IAM policy associated with a Dynamic Group must be as restrictive as possible. Use the where clause extensively to limit access to specific resources (e.g., specific buckets, vaults, or compartments).
  2. Isolate with Dynamic Groups - Create separate Dynamic Groups for distinct roles and environments. Instead of one "all web servers" group, create groups like Prod-Frontend-Web, Dev-Backend-API, and Staging-Batch-Processors.
  3. Use Tags for Granularity - Use OCI's tagging system heavily. Dynamic Groups can key off tags like Environment: Production, Application: Payroll, or DataClassification: High. This makes policy management scalable and auditable.
  4. Regular Policy Review - Periodically review the IAM policies attached to Dynamic Groups. Ensure that retired applications or instances that have changed roles do not retain unnecessary permissions.
  5. Use OCI SDK / CLI - Always use the official OCI SDKs or CLI on the instance. They are purpose-built to automatically handle the Instance Principal authentication flow, ensuring temporary tokens are managed securely and cryptographically signed.

By implementing Instance Principals and following these best practices, cloud engineers and security professionals can build secure, resilient, and compliant cloud architectures that effectively eliminate the biggest vulnerability: stored, long-lived credentials.

Related Labs

Put this knowledge into practice with hands-on labs that demonstrate OCI security concepts covered in this article:

  • Compromise, Recon and Exfiltration in OCI - Explore how misconfigured IAM permission verbs (inspect vs read) allow an external auditor identity to enumerate compartments, discover storage buckets, and exfiltrate confidential data using the OCI CLI and oci-enum.
  • Leverage LFI for RCE and OCI Access - See how static OCI credentials stored on a web server are extracted through an LFI-to-RCE chain, then used to enumerate resources, access OCI Vault secrets, and demonstrate chained privilege escalation with oci-hunter.

Frequently Asked Questions

What is the main difference between an OCI Instance Principal and an OCI IAM User?

A: An OCI IAM User represents a human or dedicated service account and uses static credentials like a password or API key. An OCI Instance Principal is the identity of a compute resource (the VM itself) and uses temporary, automatically rotated cryptographic tokens for secure, credential-free Oracle Cloud Infrastructure authentication.

How do I enable the Instance Principal feature on a compute instance?

A: Instance Principals are automatically enabled when an instance is launched. You don't "enable" the feature on the instance itself; instead, you enable its authorization by placing it into a dynamic group and then attaching the necessary permissions to that dynamic group via an IAM policy.

Can an Instance Principal access services in a different OCI region?

A: Yes, assuming the appropriate IAM policies are configured. Instance Principal identities are not regional - they are scoped to the tenancy. An instance in one region can access resources in any region, provided the IAM policies grant the necessary permissions to resources like Object Storage buckets or databases, provided the necessary networking and policy rules are in place.

Why are OCI Instance Principals better than storing API keys for cloud service authentication?

A: Instance Principals eliminate the need to store long-lived, high-value secrets (API keys) on the file system. They use temporary, short-lived tokens that are automatically managed by the OCI control plane, drastically reducing the attack surface and mitigating risks from compromised instances.

What role do dynamic groups play in OCI IAM for instance access?

A: Dynamic groups are essential for managing OCI Instance Principal permissions at scale. They allow administrators to create a logical grouping of compute instances based on rules (like compartment or tags). This grouping is then used as the 'principal' in an IAM policy to grant permissions, making authorization management much simpler and more flexible than assigning permissions to individual instance IDs.

Learn this hands-on in a bootcamp

 


Train, certify, prove it


Our bootcamps combine expert-led instruction with real cloud environments. Complete the training, pass the exam, and earn an industry-recognized certification.



MCRTE_-1

What practitioners say.

Caleb Havens

Red Team Operator & Social Engineer, NetSPI


"I’ve attended two training sessions delivered by Pwned Labs: one focused on Microsoft cloud environments and the other on AWS. Both sessions delivered highly relevant content in a clear, approachable manner and were paired with an excellent hands-on lab environment that reinforced key concepts and skills for attacking and defending cloud infrastructures. The training was immediately applicable to real-world work, including Red Team Operations, Social Engineering engagements, Purple Team exercises, and Cloud Penetration Tests. The techniques and insights gained continue to be referenced regularly and have proven invaluable in live operations, helping our customers identify vulnerabilities and strengthen their cloud defenses."

Sebas Guerrero

Senior Security Consultant, Bishop Fox


"The AWS, Azure, and GCP bootcamps helped me get up to speed quickly on how real cloud environments are built and where they tend to break from a security standpoint. They were perfectly structured, with real-world examples that gave me rapid insight into how things can go wrong and how to prevent those issues from happening in practice. I’m now able to run cloud pentests more confidently and quickly spot meaningful vulnerabilities in customers’ cloud infrastructure.

Dani Schoeffmann

Security Consultant, Pen Test Partners


"I found the Pwned Labs bootcamps well structured and strongly focused on practical application, with clear background on how and why cloud services behave the way they do and how common attack paths become possible. The team demonstrates both sides by walking through attacks and the corresponding defenses, backed by hands-on labs that build confidence using built-in and third-party tools to identify and block threats. The red-team labs are hands-on and challenge-driven, with clear walkthroughs that explain each step and the underlying logic. I’ve seen several of these techniques in real engagements, and the bootcamp helped me develop a repeatable methodology for cloud breach assessments and deliver more tailored mitigation recommendations."

Matt Pardo

Senior Application Security Engineer, Fortune 500 company


"I’ve worked in security for more than 15 years, and every step up came from taking courses and putting the lessons into practice. I’ve attended many trainings over the years, and Pwned Labs’ bootcamps and labs are among the best I’ve experienced. When you factor in how affordable they are, they easily sit at the top of my list. As a highly technical person, I get the most value from structured, hands-on education where theory is immediately reinforced through labs. Having lifetime access to recordings, materials, and training environments means you can repeat the practice as often as needed, which is invaluable. If you’re interested in getting into cloud security, sign up for Pwned Labs.

Steven Mai

Senior Penetration Tester, Centene


Although my background was mainly web and network penetration testing, the ACRTP and MCRTP bootcamps gave me a solid foundation in AWS and Azure offensive security. I’m now able to take part in cloud penetration testing engagements and have more informed security discussions with my team.

 

Got any Questions? Get in touch