Files
rclone/cmd/serve/proxy/proxy_code.go
T
Nick Craig-Wood f6ca72fabb serve sftp: fix auth proxy letting a public key be used as a password GHSA-66qv-66mg-9h74 CVE-PENDING
With --auth-proxy, the cache of backends made by the auth proxy
program was keyed on the user, the credential and the client IP but
not on whether the credential was a password or a public key. A public
key is not a secret, so once its owner had logged in with it anyone
who knew it could, from the same IP address and within the cache
lifetime, log in as that user by sending the base64 public key as
their password. The cached backend was returned without the proxy
program being asked, so a program which refuses all passwords was
bypassed. A password login arriving at the same time as the public key
login could also share its proxy call for the same reason.

The kind of credential is now part of the cache key and is checked on
a cache hit, so a public key sent as a password is passed to the proxy
program to decide, as it was on a cold cache.
2026-11-06 12:08:09 +00:00

76 lines
1.8 KiB
Go

//go:build ignore
// A simple auth proxy for testing purposes
package main
import (
"encoding/json"
"log"
"os"
)
func main() {
// Read the input
var in map[string]string
err := json.NewDecoder(os.Stdin).Decode(&in)
if err != nil {
log.Fatal(err)
}
// Note each run in a file if asked to
if runLog := os.Getenv("RCLONE_TEST_PROXY_RUN_LOG"); runLog != "" {
f, err := os.OpenFile(runLog, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
log.Fatal(err)
}
_, _ = f.WriteString(in["user"] + "\n")
_ = f.Close()
}
// Write the output
var out = map[string]string{}
for k, v := range in {
switch k {
case "user":
v += "-test"
case "error":
log.Fatal(v)
case "pass":
// Simulate a key-only policy which refuses every password
if os.Getenv("RCLONE_TEST_PROXY_KEY_ONLY") != "" {
log.Fatalf("password refused for %q", in["user"])
}
}
out[k] = v
}
if out["type"] == "" {
out["type"] = "local"
}
if out["_root"] == "" {
out["_root"] = ""
}
// S3 access key auth has neither pass nor public_key and needs
// the secret returned, unless the user asks for it to be omitted
// or empty. The secret's suffix can be changed to simulate a
// rotation and an access key ID can be revoked.
_, havePass := in["pass"]
_, havePublicKey := in["public_key"]
switch {
case havePass || havePublicKey || in["user"] == "nosecret":
case in["user"] == os.Getenv("RCLONE_TEST_PROXY_REVOKED"):
log.Fatalf("access key ID %q revoked", in["user"])
case in["user"] == "emptysecret":
out["_secret_access_key"] = ""
default:
suffix := os.Getenv("RCLONE_TEST_PROXY_SECRET_SUFFIX")
if suffix == "" {
suffix = "-secret"
}
out["_secret_access_key"] = in["user"] + suffix
}
json.NewEncoder(os.Stdout).Encode(&out)
if err != nil {
log.Fatal(err)
}
}