Skip to content

fix: do not fall back to anonymous access when --iam is set - #52

Merged
efirs merged 1 commit into
mainfrom
fix/no-anon-fallback-with-iam
Sep 28, 2026
Merged

efirs merged 1 commit into
mainfrom
fix/no-anon-fallback-with-iam

Conversation

@efirs

@efirs efirs commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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_ID in the environment, as evidence the caller wanted anonymous access, and swapped the client onto anonymous credentials:

if len(s.config.Profile) == 0 && os.Getenv("AWS_ACCESS_KEY_ID") == "" {
    s.awsConfig.Credentials = credentials.AnonymousCredentials
    s3Log.Info().Msg("anonymous bucket detected")
}

With --iam neither 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 --iam together with a bucket that serves an anonymous HEAD, and --no-detect avoids 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-detect turns 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_ID env 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.UseIAM to that guard so IAM mounts keep using the IAM signer path.

The --no-detect help 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.

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)
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Critical risk] Changes AWS credential fallback logic when IAM is enabled.

The PR appears safe to merge, with a non-blocking regression-test gap in the IAM detection path.

Fix All in Claude CodeFindings

  1. P2 IAM guard lacks regression coverage ▶

Summary

The PR prevents a successful unsigned bucket HEAD from switching an IAM-configured S3 mount to anonymous credentials and clarifies the --no-detect help text.

  • The credential guard addresses the stated identity-loss path.
  • The changed branch lacks a focused regression test.

Reviews (1) · Last reviewed commit: "fix: do not fall back to anonymous acces..."

Comment thread core/backend_s3.go
@efirs
efirs merged commit 5bf1be7 into main Sep 28, 2026
9 checks passed
@efirs
efirs deleted the fix/no-anon-fallback-with-iam branch September 28, 2026 20:28
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants