Cloud credential harvesting: how it happens, how to detect it, and how to break the chain before impact

Cloud credential harvesting (cloud credential collection) is the process by which an attacker obtains, at scale, usernames/passwords, session tokens, and API keys to turn an “identity” incident into real access to cloud environments. In enterprise, the problem is rarely a single leaked credential: it is usually a chain that mixes corporate endpoints, CI/CD integrations, broad IAM permissions, and lack of early detection.

The operational consequence is clear: if the attacker gets a token or a key with sufficient permissions, they can act like a legitimate user, with confusing traces and with the ability to automate actions (enumeration, secret discovery, escalation, and exfiltration). What follows is a guide oriented to operations and response, with an exclusive focus on harvesting cloud credentials.

Real attack surface: where credentials are harvested in the cloud

In modern corporate environments, harvesting is not limited to classic password phishing. What is most seen in incidents is the collection of reusable authentication material: session tokens, refresh tokens, API keys in repositories, environment variables in pipelines, configuration files on workstations, and credentials embedded in images or artifacts.

A frequent pattern: a developer configures a command-line tool on their laptop to operate in cloud, the machine is compromised (malware, infostealer, or remote access), and the attacker extracts the credentials directory or the sessions cache. They do not need to “break” IAM; it is enough to use valid credentials. The typical result in enterprise is access to buckets, queues, logs, or serverless functions from a “new” IP, but with a “known” identity.

Another corporate harvesting point is automation systems: CI/CD runners with poorly segregated secrets, logs that print sensitive variables, or jobs that assume roles that are too broad to “avoid friction”. When the attacker gets the pipeline secret, they bypass the human endpoint and go straight into the cloud account.

Abuse scenarios after harvesting: from a key to operational control

The difference between an “annoying” incident and a critical one is usually the permissions perimeter of the harvested credential. With an API key of a user with privileges, the attacker can create new identities, generate new keys, and establish persistence. With a session token of an operational role, they can enumerate resources, extract data, or modify configurations without needing to elevate privileges.

In enterprise, the impact usually lands on three fronts: service disruption due to configuration changes, data leakage due to access to storage/analytics, and costs due to resource abuse (mining, mass deployments, transfer). The dangerous part is that many actions “look” like normal operations, especially if there is no strong traceability of identity and context.

  • Persistence via new credentials

If the compromised principal has permissions to manage IAM, it is common to see creation of new users/roles, generation of access keys, or changes in policies. The company usually detects it late because the initial access can be brief: steal, enter, leave a door, and exit.

  • Silent exfiltration using legitimate services

With read permissions, the attacker does not need “weird” tools: listings, downloads, and exports via official APIs. In practice, teams are surprised to see that the incident did not trigger alerts because the traffic was “valid” and the identity was “correct”.

Early signals and telemetry: what does change when the attacker uses valid credentials

When access is done with real credentials, the challenge is detecting pattern changes, not “login failures”. There are indicators that, if well instrumented, usually appear early: first API calls from an unusual ASN/country, creation of access keys outside business hours, spikes of enumeration (List/Describe), and repeated authorization failures while the attacker maps permissions.

An especially useful signal is the sequence: GetCallerIdentity (or equivalent) followed by multiple “Describe/List” calls and then write or IAM actions. In real incidents, that reconnaissance phase happens in minutes. If the SOC or the cloud team does not have alerts on that transition, the attacker moves forward without friction.

  • Source and context anomalies

It is not just about geolocation. In corporate environments, it is more actionable to correlate with: known corporate egress IPs, VPN egress, runner ranges, and managed devices. Seeing a pipeline credential used from a residential network is almost always a bad sign.

  • High-risk IAM events

Key creation/rotation, policy changes, and permission attachments should be raised as critical events, even if an administrator does them. In harvesting, the attacker seeks to turn temporary access into persistence; if IAM is not monitored closely, the anomalous becomes normalized.

How to do it in practice: hardening and operational validation to reduce harvesting

Effective defense combines exposure reduction (fewer long-lived secrets, fewer surfaces where they can leak), blast radius limitation (least privilege, segmentation by roles/environments), and session controls (duration, conditions, devices, network). The key is that these measures can be verified, not just documented.

Concrete actions that often yield quick results in companies: enforce MFA on human identities, migrate automations to ephemeral credentials (roles with assumption and short sessions), and remove long-duration keys where feasible. In parallel, harden policies so that a harvested credential cannot by itself create new credentials or change IAM.

  • Configure IAM policies with source conditions

When the use case allows it, conditioning by source network (corporate ranges, VPC NAT, CI egress) reduces the value of a stolen credential. If the key appears outside those ranges, the call fails even if the secret is valid.

Example (AWS IAM policy) to limit actions to a corporate range:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowFromCorpEgressOnly",
"Effect": "Allow",
"Action": ["s3:ListBucket","s3:GetObject"],
"Resource": ["arn:aws:s3:::mi-bucket","arn:aws:s3:::mi-bucket/*"],
"Condition": {
"IpAddress": {"aws:SourceIp": ["203.0.113.0/24"]}
}
}
]
}

Validation: review in CloudTrail that calls denied by IP are recorded (eventName, errorCode) and that there are no “alternative” paths (for example, public endpoints used from outside) that allow access. Also, verify that the allowed ranges reflect reality (office/VPN/CI egress) so as not to force operational bypasses.

  • Block persistence: deny credential management except for controlled roles

A common corporate mistake is giving broad permissions “just in case” to technical users. If a credential is harvested, the attacker tries to create new access keys or attach policies. Reducing who can execute iam:CreateAccessKey, iam:AttachUserPolicy, or iam:PutUserPolicy cuts the most common escalation path.

Example (AWS IAM) of explicit denial of sensitive IAM actions:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyIamCredentialManagement",
"Effect": "Deny",
"Action": [
"iam:CreateAccessKey",
"iam:UpdateAccessKey",
"iam:DeleteAccessKey",
"iam:AttachUserPolicy",
"iam:PutUserPolicy",
"iam:CreateUser",
"iam:CreateLoginProfile"
],
"Resource": "*"
}
]
}

Validation: use IAM Access Analyzer and controlled tests (for example, with a lab role) to confirm that operations are blocked and that “break-glass” roles are segregated and audited. Also review CloudTrail events to detect repeated failed attempts: they are often the attacker’s reconnaissance phase after harvesting.

Recommendations for corporate environments

Cloud credential harvesting works because it turns reusable secrets (passwords, tokens, keys) into legitimate operations inside the cloud. In enterprise, the real impact appears when that credential has broad permissions or when it can be used from anywhere without context restrictions.

Operationally, what reduces risk the most is: shorten credential lifetime and scope (prioritize ephemeral sessions), close the door to persistence (limit IAM management and creation of new credentials), and improve pattern-based detection (source, API sequence, high-risk IAM events). If these measures are validated with telemetry (CloudTrail/IAM Access Analyzer and controlled testing), harvesting stops being a highway and becomes a noisy, low-yield attempt for the attacker.


Interested in Cloud Security?

Technical analysis, hands-on labs and real-world cloud security insights.

Privacy policy