Single Sign-On, Double Trouble: Credential Theft Using AWS Access Tokens

Summary:
AWS Single Sign-On (SSO) access tokens are critical credentials used for authenticating users to AWS resources. If these tokens are exposed or mishandled, they can be exploited by threat actors to assume the identity of legitimate users, bypassing standard authentication mechanisms. The Red Canary report highlights how the exposure of these tokens, often due to insecure practices in development environments or logging systems, presents a significant security risk to organizations relying on AWS SSO for identity management.

Security Officer Comments:
AWS SSO tokens are JSON Web Tokens (JWTs) containing claims and metadata that authenticate users within AWS. These tokens are typically stored locally when a user authenticates using the AWS Command Line Interface (CLI) or SDK. If exposed, an attacker can parse the token to retrieve sensitive claims, such as the user identity and expiration time, and potentially use it to invoke AWS API actions or assume roles within the victim's AWS environment.

Threat actors may exploit poorly configured development environments, where tokens are often stored in plaintext in temporary cache files, environment variables, or CI/CD pipelines. Tools like jq and base64 decoding make it trivial for attackers to analyze the JWT structure and extract critical information. Moreover, misconfigured logging systems that inadvertently capture token data can also serve as an entry point for exploitation.

To complicate detection, attackers may leverage the same legitimate user agent strings and IP addresses used by the compromised token's original owner, making anomalous activity detection more challenging. Security teams should focus on proactive controls like monitoring CloudTrail logs for high-privilege actions originating from unexpected locations, timeframes, or device fingerprints. Advanced detections can leverage AWS CloudTrail Insights or third-party SIEMs to detect deviations in baseline user behavior.

Suggested Corrections:

  • Secure Storage Practices: Ensure AWS SSO tokens are stored securely by using encrypted storage mechanisms and avoiding exposure in environment variables or configuration files. Tools like AWS Secrets Manager or HashiCorp Vault can securely manage sensitive credentials.
  • Environment Hygiene: Implement strict controls on developer workstations and CI/CD pipelines to prevent accidental exposure of tokens. This includes sanitizing logs and ensuring sensitive data is redacted.
  • Token Expiration and Rotation: Regularly rotate access tokens and enforce short expiration periods to limit the window of opportunity for misuse.
  • Enhanced Logging and Monitoring: Use AWS CloudTrail, GuardDuty, and third-party tools to monitor API calls and detect suspicious activity. Focus on anomalies such as unusual API calls, geographic locations, or times of access.
  • IAM Policies: Enforce least privilege access with restrictive IAM policies. Avoid assigning overly permissive roles or allowing wildcards in policy definitions.
  • Automated Threat Detection: Use detection-as-code frameworks to create and automate detections for token misuse scenarios, such as unauthorized attempts to access SSO endpoints or assume roles outside the expected scope.

Link(s):
https://redcanary.com/blog/threat-detection/aws-sso-access-tokens/