# hkb-forward-iam-high-risk

Fires on: IAM users, access keys and login profiles, and removing or editing an hkb boundary (the calls the boundaries deny).

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

## Symptoms
An email from `hkb security alert`: `SECURITY EVENT aws.iam <call> in account <member>`. One of: an IAM user, access key or login profile was created or changed, a permissions boundary was removed from a role, or an `hkb-*-boundary` policy was edited or deleted.

## Pre-checks
1. Did the call succeed? The rule matches attempts too. Read the event's `errorCode`: `AccessDenied` means a boundary or an SCP stopped it, and the alert shows the guardrail working.
2. Who made it: `userIdentity.arn`. SCP-04 denies creating users, access keys and login profiles to everything but the Control Tower and StackSets execution roles, and the hkb boundaries deny removing or editing a boundary. A successful call points at one of those exempt roles.

## Resolution
- **Denied:** find out why the caller tried. A pipeline role trying is a template bug; fix the template in a PR.
- **Succeeded:** delete the user, key or login profile, or put the boundary back. HKB has no IAM users anywhere, so any user is unwanted. In a member account the fix goes through the pipeline (a template change) or, for a role the pipeline doesn't own, a task-scoped root session.

## Post-checks
`aws iam get-account-summary --profile ro-<account>` shows `Users` 0, and the control tests' boundary checks pass for that account.

## Rollback
Nothing to roll back: the fix removes something that shouldn't exist.

## Alert details

| Property | Value |
| --- | --- |
| Runs in | every member account, both Regions, forwarded to the `hkb-security-events` bus in Security |
| Email | From `hkb security alert`: `SECURITY EVENT <src> <what> in account <account>, <region>, at <time> by <who>.` |
| Source | `baseline/hkb-baseline-events.yaml`, resource `IamRule` |

The event pattern, as deployed:

```yaml
EventPattern:
  source: [aws.iam]
  detail-type: [AWS API Call via CloudTrail]
  detail:
    eventSource: [iam.amazonaws.com]
    "$or":
      - eventName: [CreateUser, CreateAccessKey, CreateLoginProfile, UpdateLoginProfile, DeleteRolePermissionsBoundary]
      - eventName: [CreatePolicyVersion, DeletePolicy, DeletePolicyVersion, SetDefaultPolicyVersion]
        requestParameters:
          policyArn:
            - wildcard: "*:policy/hkb-*-boundary"
```
