Skip to content

serve S3 using env variable RCLONE_AUTH_KEY broken since 1.70.0 #9044

Closed

Description

@static-moonlight

The associated forum post URL from https://forum.rclone.org

none

What is the problem you are having with rclone?

When using rclone to serve the content of a file system through S3, you can run it with a command like this:

rclone serve s3 --auth-key ACCESS_KEY_ID,SECRET_ACCESS_KEY remote:path

Usually it is possible to substitute CLI parameters with environment variables, in this case you could define RCLONE_AUTH_KEY=ACCESS_KEY_ID,SECRET_ACCESS_KEY instead of using the CLI parameter --auth-key. Keeping credentials out of the command line is better for security anyway.

Since v1.70.0 this no longer works. The last version where rclone considered the environment variable RCLONE_AUTH_KEY is v1.69.3.

The documentation states:

If --auth-key is not provided then serve s3 will allow anonymous access.

So since v1.70.0 rclone ignores RCLONE_AUTH_KEY and falls back to anonymous access.

What is your rclone version (output from rclone version)

rclone v1.72.1
- os/version: alpine 3.23.0 (64 bit)
- os/kernel: 5.14.0-570.58.1.el9_6.x86_64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.25.5
- go/linking: static
- go/tags: none

As I stated before. Every version since and including v1.70.0 is affected.

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Linux, x64, container image

Which cloud storage system are you using? (e.g. Google Drive)

none

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone serve s3 /data

with environment variables set:

RCLONE_ADDR=:8888
RCLONE_AUTH_KEY=[...],[...]

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

The debug logs from rclone serve s3 contain these lines:

2025/12/15 15:14:31 DEBUG : Setting  auth_key="{user},{pw}" from environment variable RCLONE_AUTH_KEY
2025/12/15 15:14:31 DEBUG : Setting --auth-key "{user}" from environment variable RCLONE_AUTH_KEY="{user},{pw}"
2025/12/15 15:14:31 DEBUG : Setting --auth-key "{pw}" from environment variable RCLONE_AUTH_KEY="{user},{pw}"

... implying, rclone still reads the environment variable, but doesn't apply it.

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. ncw commented on Dec 15, 2025

    @ncw
    Member

    Any chance you could git bisect this to pinpoint the problem?

  2. static-moonlight commented on Dec 16, 2025

    @static-moonlight
    ContributorAuthor

    Sorry, I'm not much of a code person ;-) I narrowed down the first affected release, best I can do for now.

  3. ncw commented on Dec 17, 2025

    @ncw
    Member

    I see what is going on here

    $ RCLONE_AUTH_KEY=user,pass rclone-v1.72.0 serve s3 -vv /tmp/src

    Notice rclone has split user and pass here

    2025/12/17 10:35:57 DEBUG : Setting  auth_key="user,pass" from environment variable RCLONE_AUTH_KEY
    2025/12/17 10:35:57 DEBUG : Setting --auth-key "user" from environment variable RCLONE_AUTH_KEY="user,pass"
    2025/12/17 10:35:57 DEBUG : Setting --auth-key "pass" from environment variable RCLONE_AUTH_KEY="user,pass"
    

    And they are being ignored here

    2025/12/17 10:35:57 INFO  : Ignored: invalid auth pair user
    2025/12/17 10:35:57 INFO  : Ignored: invalid auth pair pass
    

    So what is happening is that the new parsing code introduced in in one of these commits is treating user,pass as two pairs one user and one pass which are being discarded because they don't have a comma in.

    cf571ad
    21e5fa1
    b145683
    4d9a165
    b930c4b
    0b7be6f
    cebd588
    780f404

    There is a simple work-around. The arguments to RCLONE_AUTH_KEY are being treated like a line in a CSV file for escaping purposes, so putting in some quotes will fix it

    $ RCLONE_AUTH_KEY='"user,pass"' rclone-v1.72.0 serve s3 -vv /tmp/src
    2025/12/17 10:37:10 DEBUG : Setting  auth_key="\"user,pass\"" from environment variable RCLONE_AUTH_KEY
    2025/12/17 10:37:10 DEBUG : Setting --auth-key "user,pass" from environment variable RCLONE_AUTH_KEY="\"user,pass\""
    

    This also means we can have multiple user/pass pairs which didn't work before

    $ RCLONE_AUTH_KEY='"user1,pass1","user2,pass2"' rclone-v1.72.0 serve s3 -vv /tmp/src
    2025/12/17 10:42:17 DEBUG : Setting  auth_key="\"user1,pass1\",\"user2,pass2\"" from environment variable RCLONE_AUTH_KEY
    2025/12/17 10:42:17 DEBUG : Setting --auth-key "user1,pass1" from environment variable RCLONE_AUTH_KEY="\"user1,pass1\",\"user2,pass2\""
    2025/12/17 10:42:17 DEBUG : Setting --auth-key "user2,pass2" from environment variable RCLONE_AUTH_KEY="\"user1,pass1\",\"user2,pass2\""
    

    I think that parsing the keys is important so we shouldn't have just been ignoring an error in them. So I propose we change these warnings into fatal errors. That stops any security problems.

    2025/12/17 10:35:57 INFO  : Ignored: invalid auth pair user
    2025/12/17 10:35:57 INFO  : Ignored: invalid auth pair pass
    

    Then probably we need to document the setting of the environment variable better.

    What do you think?

  4. static-moonlight commented on Dec 17, 2025

    @static-moonlight
    ContributorAuthor

    Sounds good. I will also apply the workaround, so that I'm not stuck with an older version.

    And yes, the documentation should definitely reflect that.

    Thank you for investigating! :)

  5. ncw commented on Dec 17, 2025

    @ncw
    Member

    I've made the error be fatal so if you don't have the quotes it should stop rather than serving anonymously

    v1.73.0-beta.9364.1d200580d.fix-serve-s3-env-auth on branch fix-serve-s3-env-auth (uploaded in 15-30 mins)

    I also updated the docs - what do you think?


    Like all rclone flags --auth-key can be set via environment
    variables, in this case RCLONE_AUTH_KEY. Since this flag can be
    repeated, the input to RCLONE_AUTH_KEY is CSV encoded. Because the
    accessKey,secretKey has a comma in, this means it needs to be in
    quotes.

    export RCLONE_AUTH_KEY='"user,pass"'
    rclone serve s3 ...

    Or to supply multiple identities:

    export RCLONE_AUTH_KEY='"user1,pass1","user2,pass2"'
    rclone serve s3 ...

    Setting this variable without quotes will produce an error.


  6. static-moonlight commented on Dec 17, 2025

    @static-moonlight
    ContributorAuthor

    Nicely done. That should solve everything. Thank you for the quick response and fix!

  7. ncw commented on Dec 18, 2025

    @ncw
    Member

    Thanks for testing.

    I've merged this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.73 - I may put this in the next point release also.

  8. added a commit that references this issue on Dec 18, 2025
    f81cd7d
  9. added 2 commits that reference this issue on Jan 21, 2026
    8eace12
    85960cd
  10. added a commit that references this issue on Feb 14, 2026
    d9de6c5
  11. added a commit that references this issue on Jul 20, 2026
    a5ece8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions