# hkb-alert-assume-root

Fires on: sts:AssumeRoot (centralized root sessions into member accounts).

Run the [common pre-checks](/wiki/runbooks/#common-pre-checks) first.

## Symptoms
An email from `hkb master alert`: `sts:AssumeRoot`, with the caller's role ARN and IP. A task-scoped root session into a member account has started.

## Pre-checks
1. Only HKB-RootUnlock may call `sts:AssumeRoot`, and only for three task policies: the root audit, the S3 bucket policy unlock and the SQS queue policy unlock. The caller ARN should contain `AWSReservedSSO_HKB-RootUnlock_`.
2. Find the target account and the task: `aws cloudtrail lookup-events --profile ro-hkb-master --region us-east-1 --lookup-attributes AttributeKey=EventName,AttributeValue=AssumeRoot --max-results 5`, then read `requestParameters.targetPrincipal` and `requestParameters.taskPolicyArn`.

## Resolution
- **Planned:** confirm the task finished and the session expired (sessions last at most 15 minutes). Record the account, the task and the reason.
- **Not planned, or a caller other than HKB-RootUnlock:** remove the HKB-RootUnlock assignment in Identity Center (an Identity Center alert follows, as expected), then read the target account's CloudTrail for events with `userIdentity.type` `Root` since the session started.

## Post-checks
No `AssumeRoot` events after the planned one. An unlocked bucket or queue has its intended resource policy back.

## Rollback
Reassign HKB-RootUnlock to `hkb-admins` through `hkb-bootstrap-identity` once the cause is understood.

## Alert details

| Property | Value |
| --- | --- |
| Runs in | the management account, us-east-1 |
| Email | From `hkb master alert`: `sts:AssumeRoot at <time> by <who> from <ip>.` |
| Source | `security/hkb-security-master-alerts.yaml`, resource `AssumeRootRule` |

The event pattern, as deployed:

```yaml
EventPattern:
  source: [aws.sts]
  detail-type: [AWS API Call via CloudTrail]
  detail:
    eventSource: [sts.amazonaws.com]
    eventName: [AssumeRoot]
```
