/secskills-defense:investigating-aws-incidentsfrom secskills-defense
Investigates security incidents in AWS by reconstructing attacker activity from CloudTrail, VPC Flow Logs, and GuardDuty. Use for suspected AWS compromise, exposed keys, or anomalous API activity.
Ships in secskills-defense. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
In AWS an incident is reconstructed from logs the attacker usually could not delete -- CloudTrail, VPC Flow Logs, and the control plane's own record of every API call. The investigation is therefore a log-correlation exercise anchored on the compromised principal: the access key or assumed role, and the sequence of API calls it made. Find the principal, pull every event it generated, and the rest of the intrusion falls out of the timeline.
investigating-m365-entrainvestigating-azure-incidentsinvestigating-gcp-incidentsresponding-to-incidentsexploiting-cloud-platformsattacking-eks-gke-akshunting-threatsThree actions, in order: identify the principal, pull its recent activity, preserve before you contain.
Scope the compromised principal. Whether the report is a leaked key, a GuardDuty finding, or a billing spike, resolve it to a single principal ARN -- an IAM user, a role, or the root account. That ARN is the anchor for everything that follows.
# What is this key/session, and does it still work?
aws sts get-caller-identity # if you hold the suspect creds
# Resolve an access key ID to its owner
aws iam get-access-key-last-used --access-key-id AKIA...
# Enumerate the principal's current footprint
aws iam list-access-keys --user-name <user>
aws iam list-attached-user-policies --user-name <user>
aws iam list-user-policies --user-name <user>
Pull recent activity from the principal. Event history (below) is the fastest first look; the S3 log bucket is the source of truth.
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=Username,AttributeValue=<user> \
--start-time 2026-07-01T00:00:00Z --max-results 200
# By access key -- catches role sessions that lookup-by-username misses
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIA...
Isolate without tipping off -- snapshot then contain. An attacker who sees their key deactivated mid-operation will burn persistence you have not found yet. For anything but active, ongoing damage: preserve evidence first (snapshot volumes, export logs), map persistence, then contain everything at once. If there is live damage -- active mining, active exfil -- stop the damage and accept the trade.
Event history vs. the S3 log bucket. The console Event history is searchable but covers only 90 days of management events and drops data events. The CloudTrail S3 log bucket (or CloudTrail Lake) is the authoritative record and the only place with S3/Lambda data events -- query it, not the console, once you are past the first look. Confirm what is actually logged:
aws cloudtrail describe-trails
aws cloudtrail get-trail-status --name <trail> # IsLogging: true?
aws cloudtrail get-event-selectors --trail-name <trail> # data events on?
userIdentity types tell you what you are looking at:
type | Meaning | Investigative note |
|---|---|---|
IAMUser | Long-lived user credentials | accessKeyId is the pivot. Human or service account? |
AssumedRole | Temporary STS creds | Read sessionContext.sessionIssuer for the source role. |
AWSService | An AWS service acting | Usually benign, but check for spoofed-looking service calls. |
Root | Root account | Almost never legitimate for API calls. Treat as critical. |
FederatedUser / WebIdentityUser | GetFederationToken broker / OIDC web identity | Trace to the broker's IAM user, or the IdP session. |
For AssumedRole, sessionContext.sessionIssuer.arn names the role and
sessionContext.attributes.mfaAuthenticated tells you whether MFA was used.
Anomaly fields to grep:
sourceIPAddress -- external IPs on role credentials that should only run
inside the VPC (the IMDS theft signature, below). Correlate against VPC Flow
Logs.userAgent -- aws-cli/2.x, Boto3, python-requests, or anything with
kali on a principal that normally shows console or SDK-from-Lambda agents.awsRegion -- calls in regions you do not operate in (attackers spin up
mining in ap-* / sa-* to dodge attention). Enumeration touches many
regions fast.errorCode -- a storm of AccessDenied / UnauthorizedOperation is
enumeration: the attacker is mapping what the stolen principal can do.-- Athena over the CloudTrail S3 bucket: AccessDenied enumeration storm
SELECT eventname, count(*) AS n
FROM cloudtrail_logs
WHERE useridentity.accesskeyid = 'AKIA...'
AND errorcode = 'AccessDenied'
AND eventtime > '2026-07-01T00:00:00Z'
GROUP BY eventname ORDER BY n DESC;
Grep the timeline for this sequence. It is the shape of nearly every stolen-key intrusion:
GetCallerIdentity -- often the very first call. The attacker is
confirming what the key is and who owns the account.List* / Get* / Describe* across IAM, S3, EC2, RDS,
Secrets Manager, often with an AccessDenied storm.CreateUser, CreateAccessKey,
AttachUserPolicy (watch for AdministratorAccess), PutUserPolicy (inline
policy so it does not show in attached-policy lists), CreateLoginProfile (a
console password on an API-only account), UpdateLoginProfile.iam:PassRole abuse -- passing a high-privilege role to a new EC2
instance, Lambda, or Glue job to inherit its permissions. Look for PassRole
paired with RunInstances / CreateFunction.UpdateAssumeRolePolicy or CreateRole with a
trust policy naming an external account (a cross-account backdoor).AssumeRole into a more privileged role, then another,
building a chain that launders the original stolen key.# Pull the IAM mutating calls for the window
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=CreateAccessKey
# Repeat for: CreateUser, AttachUserPolicy, PutUserPolicy, CreateLoginProfile,
# UpdateAssumeRolePolicy, CreateRole, AssumeRole
# (iam:PassRole is a permission, not an event -- find it in requestParameters of
# RunInstances / CreateFunction, not via lookup-by-EventName)
Enumerate every mechanism explicitly during eradication -- rotating the one leaked key does nothing about a second one the attacker created.
CreateAccessKey on the
victim or another account; a user may have up to two keys.CreateLoginProfile on a
principal that never used the console is high-signal.UpdateAssumeRolePolicy adding an
external principal or sts:AssumeRole from another account.iam:CreateServiceLinkedRole and other quietly-privileged roles.# Users and keys created recently
aws iam list-users --query 'Users[?CreateDate>=`2026-07-01`].[UserName,CreateDate]'
for u in $(aws iam list-users --query 'Users[].UserName' --output text); do
aws iam list-access-keys --user-name "$u" \
--query 'AccessKeyMetadata[].[UserName,AccessKeyId,CreateDate]' --output text
done
# Roles whose trust policy names an external account
aws iam list-roles --query 'Roles[].[RoleName,AssumeRolePolicyDocument]'
# Recently modified Lambda and the EventBridge rules that fire them
aws lambda list-functions --query 'Functions[].[FunctionName,LastModified]'
aws events list-rules --query 'Rules[].[Name,ScheduleExpression,State]'
The classic AWS escalation: an SSRF or foothold on an EC2 instance reads the
Instance Metadata Service (http://169.254.169.254/latest/meta-data/iam/...),
lifts the instance role's temporary credentials, and uses them elsewhere.
The signature is unmistakable in CloudTrail: the instance role's session
credentials appear from a sourceIPAddress that is not the instance. The role
is minted for the instance, so any call from an external or unrelated IP means
the credentials left the box.
-- Role session creds used from outside the VPC
SELECT eventtime, eventname, sourceipaddress, useragent
FROM cloudtrail_logs
WHERE useridentity.arn LIKE '%assumed-role/<instance-role>%'
AND sourceipaddress NOT LIKE '10.%'
AND sourceipaddress NOT LIKE '172.%'
ORDER BY eventtime;
IMDSv1 (a simple GET, no session token) makes this trivial and is itself a
finding -- confirm whether the instance enforces IMDSv2
(HttpTokens: required) via aws ec2 describe-instances. Correlate the theft
window with VPC Flow Logs for the outbound SSRF and the reuse source.
GuardDuty is a starting pistol, not the investigation. Each finding type maps to a hypothesis you confirm in CloudTrail:
| Finding type | Implication |
|---|---|
UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.* | Instance role creds used off the instance -- the IMDS theft above. |
UnauthorizedAccess:IAMUser/MaliciousIPCaller | A principal called from a known-bad IP. |
UnauthorizedAccess:IAMUser/TorIPCaller | API calls via Tor -- almost never a legitimate admin. |
CryptoCurrency:EC2/BitcoinTool.B!DNS | An instance talking to a mining pool -- confirmed crypto-mining. |
Recon:IAMUser/* | Enumeration -- the AccessDenied storm. |
Persistence:IAMUser/*, PrivilegeEscalation:IAMUser/* | IAM mutation matching the escalation patterns above. |
Policy:S3/BucketAnonymousAccessGranted | A bucket was made public -- possible exfil staging. |
aws guardduty list-findings --detector-id <id> \
--finding-criteria '{"Criterion":{"severity":{"Gte":4}}}'
aws guardduty get-findings --detector-id <id> --finding-ids <id>
Findings older than the CloudTrail window still carry the principal and IPs -- pivot on those even when the raw events have aged out of Event history.
GetObject volume/bytes on sensitive
buckets, visible only if S3 data events are logged. Check request counts by
principal.PutBucketPolicy / PutBucketAcl granting
AllUsers or AuthenticatedUsers, or PutPublicAccessBlock disabling the
block.ModifySnapshotAttribute or ModifyImageAttribute
adding an external account or all to the volume/AMI (steal data by sharing
the snapshot out).ModifyDBSnapshotAttribute sharing a DB snapshot, or
StartExportTask dumping a snapshot to an attacker-controlled S3 bucket.SELECT eventname, useridentity.arn, sourceipaddress,
json_extract_scalar(requestparameters, '$.attributeType') AS attr
FROM cloudtrail_logs
WHERE eventname IN ('ModifySnapshotAttribute','ModifyImageAttribute',
'ModifyDBSnapshotAttribute','PutBucketPolicy','PutBucketAcl')
AND eventtime > '2026-07-01T00:00:00Z';
A capable attacker tries to blind you. Watch for and, crucially, work around:
StopLogging / DeleteTrail -- turning off CloudTrail.PutEventSelectors -- narrowing what the trail records (dropping data
events or a whole region) without deleting the trail.DeleteFlowLogs -- removing VPC Flow Logs to hide the network side.DeleteDetector / UpdateDetector (disable) / suspend -- killing
GuardDuty.The defeat for all of these is a member-account-independent
Organizations-level trail that logs to a central, locked S3 bucket (MFA
delete, Object Lock, separate log-archive account) the compromised principal
cannot reach. The very act of StopLogging is itself logged there before it
takes effect. If you have an org trail, the attacker's cleanup calls are
evidence, not gaps. If you do not, note the blind window as a scoping
limitation.
# Was logging tampered with? These calls are the finding.
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=StopLogging
# Repeat: DeleteTrail, PutEventSelectors, DeleteFlowLogs, DeleteDetector
EBS snapshots of every involved instance's volumes, before you touch the instance. Tag with the case ID and apply a resource policy / legal hold so they cannot be deleted.
aws ec2 create-snapshot --volume-id vol-xxx \
--description "IR-2026-042 preserve" \
--tag-specifications 'ResourceType=snapshot,Tags=[{Key=case,Value=IR-2026-042},{Key=legal-hold,Value=true}]'
Memory capture on a live instance before termination -- for a resident
implant or in-memory creds, this is the only source. Acquire and then analyze
per analyzing-memory-images.
Export the relevant CloudTrail window to a preserved location, and copy VPC Flow Logs and any GuardDuty findings before retention expires.
Tagging and legal hold on all evidence artifacts, and involve legal before collection if the incident may become a regulatory or litigation matter.
Do it all at once, after scoping. Partial containment alerts the attacker.
Deactivate, do not delete, keys -- deletion destroys the artifact; a deactivated key still shows in the timeline.
aws iam update-access-key --user-name <user> \
--access-key-id AKIA... --status Inactive
Revoke active sessions -- deactivating a key does not kill in-flight
temporary sessions minted from it. Attach an inline deny policy that invalidates
any session/token issued before now (the AWSRevokeOlderSessions pattern):
aws iam put-user-policy --user-name <user> \
--policy-name AWSRevokeOlderSessions \
--policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Deny",
"Action":"*","Resource":"*","Condition":{"DateLessThan":
{"aws:TokenIssueTime":"2026-07-20T00:00:00Z"}}}]}'
For a role, put an equivalent deny in the role's inline policy or a boundary.
Rotate every credential the principal could reach: other keys, secrets in Secrets Manager / SSM the principal read, and any hardcoded creds on compromised instances.
Quarantine security group -- move a mining or exfil instance to an SG with no egress rather than terminating it, so memory and disk survive for analysis.
Remove attacker persistence -- delete the created users/keys/roles, revert tampered trust policies, remove backdoor Lambda and EventBridge rules -- only after they are documented.
PutUserPolicy), a second access key on an existing user, and modified role
trust policies all grant persistence without ever creating a user.RunInstances was compromised -- the same access could exfiltrate data or
escalate. Mining is the visible symptom, not the scope.iam:PassRole and AssumeRole chains routinely turn a modest instance role
into account-wide access. Trace what the role can reach, don't assume.investigating-m365-entra -- the sibling cloud-IR skill for M365 / Entra ID incidentsresponding-to-incidents -- the general IR process, evidence handling, and host-level responseexploiting-cloud-platforms -- the offensive side; how these AWS TTPs are executedattacking-eks-gke-aks -- when the pivot is specifically into Kubernetes on EKSanalyzing-memory-images -- working an instance memory capture with Volatilityhunting-threats -- proactive hunting when there is no confirmed incidentreporting-security-findings -- structuring the incident narrative and deliverablecloudtrail-partitioner -- partition the CloudTrail S3 bucket for fast Athena queriesstratus-red-team -- emulate AWS attack TTPs to learn what each leaves in CloudTrailWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub trilwu/secskills --plugin secskills-defense2 plugins ship this exact skill · first indexed Jul 31, 2026
22 skills in this plugin
/analyzing-disk-imagesPerform dead-disk forensics on an acquired disk image using The Sleuth Kit, Plaso, and bulk_extractor — verify integrity and mount read-only, map partitions, recover deleted files, build a file-system and super-timeline, carve unallocated space, mine registry hives and OS artifacts, and detect anti-forensics. Use when handed a .E01/.dd/.raw/.vmdk/.vhdx disk image or forensic acquisition to examine, recovering deleted files, building a file-system timeline, or carving artifacts from unallocated space./analyzing-linux-persistenceSystematically identify and analyze persistence mechanisms on Linux systems during DFIR investigations -- sweep systemd units, cron jobs, shell initialization, SSH config, kernel modules, LD_PRELOAD, package manager hooks, udev rules, container entrypoints, and XDG autostart entries. Use when investigating a compromised Linux host, performing forensic analysis of a Linux disk image, looking for backdoors or unauthorized access mechanisms, or determining how an attacker maintained access./analyzing-malwareAnalyze suspected malware safely — containment, static triage, sandboxed detonation, unpacking, capability and C2 extraction, IOC production, and YARA rule authoring. Use when handed a suspicious file, hash, or sample, when triaging an alert artifact, or when producing detection content from a specimen.Other plugins' skills for the same job