GHSA-gx4c-2hqx-cw2r: rclone S3 Backend Does Not Strip Vulnerability

LOW
CVSS 3.1
CWE-319 CWE-522
Published
Advisory Summary

GHSA-gx4c-2hqx-cw2r is a LOW (CVSS 3.1) s3 backend does not strip vulnerability (CWE-319: Cleartext Transmission of Sensitive Information) affecting rclone libraries in the Go ecosystem. The issue involves s3 backend does not strip x-amz-security-token on a same-host https->http redirect. Remediation is available by upgrading affected packages to version 1.74.4.

GHSA-gx4c-2hqx-cw2r at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-gx4c-2hqx-cw2r
Severity LOW
CVSS v3.1 Base Score 3.1
CWE Classification CWE-319: Cleartext Transmission of Sensitive Information
Affected Product rclone
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 3.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N).

Attack Vector Adjacent (AV:A)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-gx4c-2hqx-cw2r

To remediate this vulnerability, upgrade all affected rclone dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/rclone/rclone fixed: 1.74.4
Upgrade github.com/rclone/rclone to 1.74.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/rclone/rclone

How to Check if You Are Affected

To determine whether your application is affected by GHSA-gx4c-2hqx-cw2r, inspect your project dependencies for rclone:

inspect dependencies for github.com/rclone/rclone

Analyze the terminal output to locate any version of rclone in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.74.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-319: Cleartext Transmission of Sensitive Information, where the product transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors. In rclone, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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. ```go 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 1. The user configures an `s3` remote (or `--s3-endpoint` pointing at a self-hosted/third-party S3-compatible service) using temporary credentials that include an STS `session_token` (common for assumed-role / CI / Kubernetes IRSA setups). 2. The configured endpoint responds to a request with a 3xx redirect to the *same* host:port but with `http://` instead of `https://` (TLS-front misconfiguration, maintenance redirect, or a malicious/compromised storage provider trying to harvest the token). 3. rclone's S3 HTTP client follows the redirect and re-sends the request, including `X-Amz-Security-Token`, over the now-unencrypted connection to that same host. 4. Any passive observer on that now-plaintext network path can read the STS session token from the request headers. ### 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". ### Vulnerable Code ```go 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 } ``` ### Recommended Fix Also compare `URL.Scheme`, so a scheme downgrade on the same host is treated the same as a host change: ```go 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 } ``` ### Verification Added a unit test (`backend/s3/redirect_scheme_test.go`) that calls the real, unmodified `s3RedirectCrossesHost` / `s3CheckRedirect` with an `https://bucket.example.com` -> `http://bucket.example.com` redirect chain. On unpatched code (commit 16091ce365, current master / v1.74.3): - `s3RedirectCrossesHost` returns `false` - `s3CheckRedirect` leaves `X-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.

GHSA-gx4c-2hqx-cw2r Affected rclone Versions

1 component(s)
Fixed Versions:
1.74.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/rclone/rclone
Go
< 1.74.4
1.74.4

References

Frequently Asked Questions

What is GHSA-gx4c-2hqx-cw2r?
GHSA-gx4c-2hqx-cw2r is a security vulnerability in rclone involving S3 backend does not strip X-Amz-Security-Token on a same-host HTTPS->HTTP redirect under CWE-319: Cleartext Transmission of Sensitive Information.
Which rclone versions are affected?
Affected versions include releases prior to 1.74.4 across affected packages: github.com/rclone/rclone.
What version fixes GHSA-gx4c-2hqx-cw2r?
Upgrading to 1.74.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/rclone/rclone affected?
Yes, github.com/rclone/rclone is affected in releases prior to 1.74.4. Upgrade your dependency to 1.74.4 or later.
What is the CVSS score of GHSA-gx4c-2hqx-cw2r?
GHSA-gx4c-2hqx-cw2r has a CVSS v3.1 base score of 3.1 (LOW) with vector string CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with GHSA-gx4c-2hqx-cw2r?
GHSA-gx4c-2hqx-cw2r is classified under CWE-319: Cleartext Transmission of Sensitive Information (The product transmits sensitive or security-critical data in cleartext in a communication channel that can be sniffed by unauthorized actors.).
How can I check Go dependencies for GHSA-gx4c-2hqx-cw2r?
Run the dependency tree command: 'inspect dependencies for github.com/rclone/rclone'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gx4c-2hqx-cw2r",
  "modified" : "2026-08-05T20:43:11Z",
  "published" : "2026-08-05T20:43:11Z",
  "aliases" : [ ],
  "summary" : "rclone: S3 backend does not strip X-Amz-Security-Token on a same-host HTTPS->HTTP redirect",
  "details" : "## Vulnerability Details\n\n**File**: `backend/s3/s3.go`\n**Lines**: 1359-1380 (functions `s3CheckRedirect` / `s3RedirectCrossesHost`)\n\n### Root Cause\nCommit `e7b1eb774` (released in v1.74.3) added a `CheckRedirect` policy for\nthe S3 HTTP client whose purpose is to strip the `X-Amz-Security-Token`\nheader (the AWS STS session token) whenever a redirect chain \"crosses a\nhost\", so the token isn't forwarded to an unintended origin.\n\n`s3RedirectCrossesHost` decides this purely by comparing `url.URL.Host`\n(hostname[:port]); it never looks at `url.URL.Scheme`. A redirect that keeps\nthe exact same host:port but changes the scheme from `https://` to `http://`\ntherefore compares as \"same host\" and `X-Amz-Security-Token` is *not*\nstripped — it is sent again, this time over plaintext HTTP.\n\n```go\nfunc s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {\n\tif len(via) == 0 {\n\t\treturn false\n\t}\n\thost := via[0].URL.Host\n\tfor _, redirect := range via[1:] {\n\t\tif redirect.URL.Host != host {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn host != req.URL.Host\n}\n```\n\n### Attack Scenario\n1. The user configures an `s3` remote (or `--s3-endpoint` pointing at a\n   self-hosted/third-party S3-compatible service) using temporary\n   credentials that include an STS `session_token` (common for assumed-role\n   / CI / Kubernetes IRSA setups).\n2. The configured endpoint responds to a request with a 3xx redirect to the\n   *same* host:port but with `http://` instead of `https://` (TLS-front\n   misconfiguration, maintenance redirect, or a malicious/compromised\n   storage provider trying to harvest the token).\n3. rclone's S3 HTTP client follows the redirect and re-sends the request,\n   including `X-Amz-Security-Token`, over the now-unencrypted connection to\n   that same host.\n4. Any passive observer on that now-plaintext network path can read the STS\n   session token from the request headers.\n\n### Impact\nDisclosure of the AWS STS session token (`X-Amz-Security-Token`) in\ncleartext for the remainder of its validity window. This is the exact class\nof leak that `e7b1eb774` was written to close — it just doesn't cover the\nscheme-downgrade axis of \"crossing a host\".\n\n### Vulnerable Code\n```go\nfunc s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {\n\tif len(via) == 0 {\n\t\treturn false\n\t}\n\thost := via[0].URL.Host\n\tfor _, redirect := range via[1:] {\n\t\tif redirect.URL.Host != host {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn host != req.URL.Host\n}\n```\n\n### Recommended Fix\nAlso compare `URL.Scheme`, so a scheme downgrade on the same host is treated\nthe same as a host change:\n\n```go\nfunc s3RedirectCrossesHost(req *http.Request, via []*http.Request) bool {\n\tif len(via) == 0 {\n\t\treturn false\n\t}\n\tscheme, host := via[0].URL.Scheme, via[0].URL.Host\n\tfor _, redirect := range via[1:] {\n\t\tif redirect.URL.Host != host || redirect.URL.Scheme != scheme {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn host != req.URL.Host || scheme != req.URL.Scheme\n}\n```\n\n### Verification\nAdded a unit test (`backend/s3/redirect_scheme_test.go`) that calls the real,\nunmodified `s3RedirectCrossesHost` / `s3CheckRedirect` with an\n`https://bucket.example.com` -> `http://bucket.example.com` redirect chain.\n\nOn unpatched code (commit 16091ce365, current master / v1.74.3):\n- `s3RedirectCrossesHost` returns `false`\n- `s3CheckRedirect` leaves `X-Amz-Security-Token: SECRET-SESSION-TOKEN`\n  intact on the outgoing (plaintext) request.\n\n```\n=== RUN   TestSchemeDowngradeNotDetectedAsCrossHost\n    redirect_scheme_test.go:23: initial=https://bucket.example.com final=http://bucket.example.com s3RedirectCrossesHost=false\n--- PASS: TestSchemeDowngradeNotDetectedAsCrossHost (0.00s)\n```\n\nAfter applying the one-line fix above (also adding scheme comparison), the\ntoken is correctly stripped and all existing redirect tests\n(`TestClientRemovesSecurityTokenOnCrossHostRedirect`,\n`TestClientDoesNotRestoreSecurityTokenAfterCrossHostRedirect`,\n`TestClientKeepsSecurityTokenOnSameHostRedirect`,\n`TestClientStopsAfterTenRedirects`) continue to pass.\n\nA minimal fix commit is ready and can be pushed to a private fork once this\nreport is acknowledged.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/rclone/rclone"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.74.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.74.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rclone/rclone/security/advisories/GHSA-gx4c-2hqx-cw2r"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rclone/rclone/commit/1a28451ea6fc8ac1806b0e9923dcb5b3f543f7fa"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rclone/rclone"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rclone/rclone/releases/tag/v1.74.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-319", "CWE-522" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-05T20:43:11Z",
    "nvd_published_at" : null
  }
}