Summary
rclone: S3 backend does not strip X-Amz-Security-Token on a same-host HTTPS->HTTP redirect
Vulnerability Details
File: backend/s3/s3.go
Lines: 1359-1380 (functions s3CheckRedirect / s3RedirectCrossesHost)
Root Cause
Commit e7b1eb774 (released in v1.74.3) added a CheckRedirect policy for
the S3 HTTP client whose purpose is to strip the X-Amz-Security-Token
header (the AWS STS session token) whenever a redirect chain "crosses a
host", so the token isn't forwarded to an unintended origin.
s3RedirectCrossesHost decides this purely by comparing url.URL.Host
(hostname[:port]); it never looks at url.URL.Scheme. A redirect that keeps
the exact same host:port but changes the scheme from https:// to http://
therefore compares as "same host" and X-Amz-Security-Token is not
stripped, it is sent again, this time over plaintext HTTP.
func s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {
if len(via) == 0 {
return false
}
host := via[0].URL.Host
for _, redirect := range via[1:] {
if redirect.URL.Host != host {
return true
}
}
return host != req.URL.Host
}
Attack Scenario
- The user configures an
s3remote (or--s3-endpointpointing at a
self-hosted/third-party S3-compatible service) using temporary
credentials that include an STSsession_token(common for assumed-role
/ CI / Kubernetes IRSA setups). - The configured endpoint responds to a request with a 3xx redirect to the
same host:port but withhttp://instead ofhttps://(TLS-front
misconfiguration, maintenance redirect, or a malicious/compromised
storage provider trying to harvest the token). - rclone's S3 HTTP client follows the redirect and re-sends the request,
includingX-Amz-Security-Token, over the now-unencrypted connection to
that same host. - Any passive observer on that now-plaintext network path can read the STS
session token from the request headers.
Vulnerable Code
func s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {
if len(via) == 0 {
return false
}
host := via[0].URL.Host
for _, redirect := range via[1:] {
if redirect.URL.Host != host {
return true
}
}
return host != req.URL.Host
}
Verification
Added a unit test (backend/s3/redirect_scheme_test.go) that calls the real,
unmodified s3RedirectCrossesHost / s3CheckRedirect with anhttps://bucket.example.com -> http://bucket.example.com redirect chain.
On unpatched code (commit 16091ce365, current master / v1.74.3):
s3RedirectCrossesHostreturnsfalses3CheckRedirectleavesX-Amz-Security-Token: SECRET-SESSION-TOKEN
intact on the outgoing (plaintext) request.
=== RUN TestSchemeDowngradeNotDetectedAsCrossHost
redirect_scheme_test.go:23: initial=https://bucket.example.com final=http://bucket.example.com s3RedirectCrossesHost=false
--- PASS: TestSchemeDowngradeNotDetectedAsCrossHost (0.00s)
After applying the one-line fix above (also adding scheme comparison), the
token is correctly stripped and all existing redirect tests
(TestClientRemovesSecurityTokenOnCrossHostRedirect,TestClientDoesNotRestoreSecurityTokenAfterCrossHostRedirect,TestClientKeepsSecurityTokenOnSameHostRedirect,TestClientStopsAfterTenRedirects) continue to pass.
A minimal fix commit is ready and can be pushed to a private fork once this
report is acknowledged.
Impact
Disclosure of the AWS STS session token (X-Amz-Security-Token) in
cleartext for the remainder of its validity window. This is the exact class
of leak that e7b1eb774 was written to close, it just doesn't cover the
scheme-downgrade axis of "crossing a host".
GHSA-GX4C-2HQX-CW2R has a CVSS score of 3.1 (Low). The vector is reachable from an adjacent network, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.74.4); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Also compare URL.Scheme, so a scheme downgrade on the same host is treated
the same as a host change:
func s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {
if len(via) == 0 {
return false
}
scheme, host := via[0].URL.Scheme, via[0].URL.Host
for _, redirect := range via[1:] {
if redirect.URL.Host != host || redirect.URL.Scheme != scheme {
return true
}
}
return host != req.URL.Host || scheme != req.URL.Scheme
}
Frequently Asked Questions
- What is GHSA-GX4C-2HQX-CW2R? GHSA-GX4C-2HQX-CW2R is a low-severity security vulnerability in github.com/rclone/rclone (go), affecting versions <= 1.74.3. It is fixed in 1.74.4.
- How severe is GHSA-GX4C-2HQX-CW2R? GHSA-GX4C-2HQX-CW2R has a CVSS score of 3.1 (Low). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of github.com/rclone/rclone are affected by GHSA-GX4C-2HQX-CW2R? github.com/rclone/rclone (go) versions <= 1.74.3 is affected.
- Is there a fix for GHSA-GX4C-2HQX-CW2R? Yes. GHSA-GX4C-2HQX-CW2R is fixed in 1.74.4. Upgrade to this version or later.
- Is GHSA-GX4C-2HQX-CW2R exploitable, and should I be worried? Whether GHSA-GX4C-2HQX-CW2R is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-GX4C-2HQX-CW2R is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-GX4C-2HQX-CW2R? Upgrade
github.com/rclone/rcloneto 1.74.4 or later.