Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential security weakness: .htpasswd is global readable on docker image #318

Open
lfse-slafleur opened this issue Dec 23, 2024 · 1 comment

Comments

@lfse-slafleur
Copy link

lfse-slafleur commented Dec 23, 2024

Output of rest-server --version

rest-server version rest-server 0.13.0 compiled with go1.22.5 on linux/amd64

How did you run rest-server exactly?

Using docker & docker-compose

services:
  restic-rest-server_prod:
    image: restic/rest-server
    ports:
      - "127.0.0.1:8000:8000"
    volumes:
      - "/backup-prod:/data"
    environment:
      data_directory: /data/

What backend/server/service did you use to store the repository?

VPS

Expected behavior

.htpasswd should have the following permissions which prevents anyone but the creating user from reading the file:
-rw-r----- 1 root root 73 Dec 23 22:58 .htpasswd

Actual behavior

.htpasswd is created with global read permissions
-rw-r--r-- 1 root root 73 Dec 23 22:58 .htpasswd

Steps to reproduce the behavior

  • Start docker
  • Add a user with docker exec <container_name> create_user <user_name> <password

Do you have any idea what may have caused this?

Default file premissions are not changed by the server.

Do you have an idea how to solve the issue?

The file is created here:

touch "$PASSWORD_FILE"

We should add a chmod 640 "$PASSWORD_FILE"

Did rest-server help you today? Did it make you happy in any way?

Very much. Much easier to maintain and use than AWS in a WORM setup and allows for selfhosting. Much appreciated!

P.S. more than happy to create a PR if you think the fix is okay.

@MichaelEischer
Copy link
Member

I'd prefer to restrict the umask before creating the file. So something like the following. Haven't tested it though.

( umask 027 && touch "$PASSWORD_FILE" )

(Subshell to limit the effect of the umask command).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants