Repository navigation
fix: do not fall back to anonymous access when --iam is set - #52
Merged
Merged
Conversation
Startup autodetection sends an unsigned HEAD at the bucket. A 200 means the bucket answers unauthenticated requests, and the code took that, plus the absence of a profile and of AWS_ACCESS_KEY_ID in the environment, as proof the caller wanted anonymous access, and swapped the client onto anonymous credentials. With --iam neither of those is set, because credentials come from the metadata service instead. A mount configured for IAM against a publicly readable bucket therefore dropped to unauthenticated requests without saying so: every subsequent call carried no identity, so writes fail and reads are attributed to nobody. Require that IAM is not in use before inferring anonymous access, and say in the --no-detect help text that anonymous detection is one of the things it turns off, which the old wording omitted. Cherry-picked from geesefs a47ba58. Our fork predates it. (cherry picked from commit a47ba5804b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e)
|
himank
approved these changes
Sep 28, 2026
|
🎉 This PR is included in version 1.2.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One-line guard, backported from geesefs
a47ba58. From the backlog triage in #51.Problem
Startup autodetection sends an unsigned HEAD at the bucket. A 200 back means the bucket answers unauthenticated requests. The code treated that, plus no configured profile and no
AWS_ACCESS_KEY_IDin the environment, as evidence the caller wanted anonymous access, and swapped the client onto anonymous credentials:With
--iamneither of those two signals is set, because credentials come from the metadata service instead. So a mount explicitly configured for IAM, pointed at a publicly readable bucket, silently dropped to unauthenticated requests for the rest of its life. Writes then fail, and reads carry no identity, so access control and audit attribution are both wrong. The only trace is an info-level "anonymous bucket detected" line.Narrow to reach, since it needs
--iamtogether with a bucket that serves an anonymous HEAD, and--no-detectavoids it entirely. But the failure is silent and the fix is one condition.Change
Require that IAM is not in use before inferring anonymous access.
Also takes the help-text half of the same upstream commit:
--no-detectturns off anonymous detection as well as location and signature detection, which the old wording did not mention. That omission is part of why the behaviour is surprising.Verification
Build, vet and the unit suites pass. No test added: the path needs a live endpoint answering an unsigned HEAD with 200 during backend construction, which the suite has no fixture for. The change is a single conjunct on an existing condition and upstream shipped it the same way.
Note
Medium Risk
Touches S3 startup credential selection and IAM vs anonymous behavior; change is a narrow guard but affects authentication for IAM mounts.
Overview
Startup bucket probing can see HTTP 200 on an unsigned HEAD and treat the bucket as anonymously readable, switching the S3 client to anonymous credentials when there is no AWS profile and no
AWS_ACCESS_KEY_IDenv var.With
--iam, credentials come from instance metadata instead, so those checks are empty even though IAM is intended. Mounts against publicly readable buckets could then stay on anonymous access (failed writes, no identity on reads). This PR adds!s.config.UseIAMto that guard so IAM mounts keep using the IAM signer path.The
--no-detecthelp text now states that it disables anonymous-access autodetection as well as region and signature detection.Reviewed by Cursor Bugbot for commit 57a7040. Bugbot is set up for automated code reviews on this repo. Configure here.