OAuth scopes define exactly what your tokens can do. Mismanaged scopes open the door to unauthorized access. In cloud environments, the margin for error is zero. Tight scope management means controlling API permissions down to the smallest action. It means logging every grant, revocation, and change. AWS CloudTrail captures these events, but raw logs are not enough—you need precise queries and repeatable runbooks.
Start with analysis. For every OAuth scope change, run a CloudTrail lookup using the LookupEvents API or Athena against CloudTrail logs in S3. Filter by eventName equal to CreateToken, UpdateToken, or AttachPolicy. Add filters for userIdentity.sessionContext.attributes.mfaAuthenticated to check MFA use. Pinpoint the request source, the IAM principal, and the scope granted.
Then move to automation. Build runbooks that respond the same way every time. A solid runbook for OAuth scopes management should: