Skip to content

Official deprecation of this gem with security, warning and disabling refresh #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# Aws::Google [![Build Status](https://travis-ci.com/code-dot-org/aws-google.svg?branch=master)](https://travis-ci.com/code-dot-org/aws-google)

## Security Advisory - DEPRECATION NOTICE

**What’s Actually Happening**
- The `aws-google` gem uses your Google Workspace SAML federation and refresh token (stored under `~/.config/gcloud`) to silently reauthenticate and fetch new SAML assertions indefinitely.
- Access tokens are short-lived, but the gem auto-refreshes them without user interaction, effectively granting perpetual AWS CLI access.

**Root Problem: IAM Trust + Refresh = Forever Access**
- Trust policy allows any valid Google SAML assertion to assume the role.
- A long-lived Google refresh token means AWS sessions can be recreated endlessly, bypassing STS session limits.

**Why This Feels Like a Hacker’s Backdoor**
- Chains refreshable identity tokens to bypass short-lived credentials.
- Skirts MFA: only checked on Google login, which could be months ago.
- Operates silently: no AWS logs for reauthentication calls.
- Becomes a persistent, long-lived IAM user, against AWS security best practices.

---

## Path Forward & Deprecation Plan

1. **Deprecate `aws-google`.**
- Introduce a warning on every invocation and in the README.
- Disable auto-refresh so sessions expire normally.
2. **Migrate to AWS IAM Identity Center (SSO).**
- Still federates from Google Workspace.
- Centralized user provisioning, role mapping, and enforced session duration (1–12 hr).
- CLI users run `aws sso login` instead of relying on a refresh token.
3. **Remove the Google SAML Provider in IAM.**
- Delete the `arn:aws:iam::<acct>:saml-provider/Google` trust and any `WebIdentity` entries for `accounts.google.com`.
- Forces immediate revocation for any existing refresh tokens.
4. **Audit Usage.**
- Use CloudTrail to query `AssumeRoleWithSAML` events.
- Identify any lingering federation patterns or anomalous long-lived access.

---

Use this gem at your own risk until you have completed the above migration steps.

# **DEPRECATION NOTICE:** The `aws-google` gem is deprecated and will no longer auto-refresh credentials. Please migrate to AWS IAM Identity Center or other solutions and expect this gem to stop functioning in future releases.

Use Google OAuth as an AWS Credential Provider.

## Installation
Expand Down
1 change: 1 addition & 0 deletions exe/aws-google
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
warn "\e[31m*** DEPRECATION NOTICE: The aws-google CLI is deprecated and will no longer auto-refresh credentials. Migrate to AWS IAM Identity Center. ***\e[0m"

# CLI to retrieve AWS credentials in credential_process format.
# Ref: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html
Expand Down
4 changes: 3 additions & 1 deletion lib/aws/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ class << self
# @option options [String] :client_id Google client ID
# @option options [String] :client_secret Google client secret
def initialize(options = {})
# Deprecation warning and disable auto-refresh
warn "\e[31m*** DEPRECATION NOTICE: The aws-google gem is deprecated and will no longer auto-refresh credentials. Please migrate to AWS IAM Identity Center. ***\e[0m"
options = options.merge(self.class.config)
@oauth_attempted = false
@online = options.fetch(:online, true)
@assume_role_params = options.slice(
*Aws::STS::Client.api.operation(:assume_role_with_web_identity).
input.shape.member_names
Expand All @@ -58,7 +61,6 @@ def initialize(options = {})
)
@client = options[:client] || Aws::STS::Client.new(credentials: nil)
@domain = options[:domain]
@online = options[:online]
@port = options[:port] || 1234
super
end
Expand Down
14 changes: 5 additions & 9 deletions lib/aws/google/cached_credentials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ def initialize(options = {})
@session_profile = @profile + '_session'
@expiration = Aws.shared_config.expiration(profile: @session_profile) rescue nil
@credentials = Aws.shared_config.credentials(profile: @session_profile) rescue nil
refresh_if_near_expiration
# Auto-refresh disabled due to deprecation
# refresh_if_near_expiration
end

def refresh_if_near_expiration
return unless near_expiration?(SYNC_EXPIRATION_LENGTH)

@mutex.synchronize do
if near_expiration?(SYNC_EXPIRATION_LENGTH)
refresh
write_credentials
end
end
# Deprecation: auto-refresh is disabled; sessions will expire normally.
warn "\e[31m*** DEPRECATION NOTICE: aws-google auto-refresh disabled. Sessions expire without refresh. ***\e[0m"
# no-op
end

# Write credentials and expiration to AWS credentials file.
Expand Down
Loading