Skip to content
Access control Write-up Intermediate

The Danger of Falling to System Role in AWS SDK Client

A web application's 'Import Data From S3' feature set the AWS SDK credentials to nil on error, causing the SDK to fall back to the EC2 instance's IAM role. An attacker could supply internal S3 bucket names to read their contents through the import functionality.

Francesco Lacerenza Follow

Published on blog.doyensec.com

As application security engineers, we think that there are more interesting and context-related questions such as:

Francesco Lacerenza, Mohamed Ouad, on blog.doyensec.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the error handler set the credentials to nil, which caused the AWS SDK to fall back to the default credential provider chain and assume the instance's IAM role.

Impact

An attacker could read the contents of internal S3 buckets that the instance's IAM role can access, if they know the bucket names.

What the attacker needed

Access to the import feature; knowledge of internal bucket names

The fix

The application should avoid fall-back to system role patterns and ensure user-provided credentials are correctly set, using anonymous credentials for public resources.

How it was found

  1. Provide an S3 bucket name (and optionally credentials) to the import feature.
  2. The application attempts to list objects and encounters an error.
  3. The error handler sets the credentials to nil and retries the listing.
  4. The SDK falls back to the instance's IAM role and lists the bucket.
  5. The bucket contents are shown in the user interface.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When a program uses Amazon's cloud services, it needs a key to prove who it is. If the program forgets to provide a key, the Amazon toolkit automatically looks for one on the server itself, which often has broad access. Here, a mistake in error handling made the program forget the user's key and use the server's powerful key instead, letting a user read private storage.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.