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

Security issue: RESTIC_PASSWORD and other envieonmant variables are available to every user in systemd service unit #367

Open
Vanav opened this issue Jun 12, 2024 · 1 comment
Assignees

Comments

@Vanav
Copy link

Vanav commented Jun 12, 2024

If I install systemd service then every environment variable defined in config file is available to any user on server.
How to reproduce:
Config file /etc/restic/profiles.yaml:

default:
  env:
    RESTIC_REPOSITORY: 'rest:http://login:[email protected]:8000/project'
    RESTIC_PASSWORD: 'restic-pass'
schedule:
  inherit: default
...

Install systemd service: resticprofile schedule.schedule.
Run as any user: systemctl cat [email protected]:

# /etc/systemd/system/[email protected]
[Unit]
Description=resticprofile backup for profile schedule in /etc/restic/profiles.yaml

[Service]
Type=notify
WorkingDirectory=/home/user
ExecStart=/usr/local/bin/resticprofile --no-prio --no-ansi --config /etc/restic/profiles.yaml --name schedule --log /var/log/restic.log backup
Nice=5
Environment="RESTIC_REPOSITORY=rest:http://login:[email protected]:8000/project"
Environment="RESTIC_PASSWORD=restic-pass"
Environment="HOME=/root"
Environment="SUDO_USER=user"

I expect the same issue with AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and any other environment variables:

Environment: job.Environment,

This issue was mentioned in #211 (comment), but since then #212 was implemented and all passwords are added from private config file to public service unit by default.

Is there a way to hide RESTIC_REPOSITORY, RESTIC_PASSWORD and AWS_SECRET_ACCESS_KEY for other users?

@jkellerer jkellerer self-assigned this Jun 12, 2024
@jkellerer
Copy link
Collaborator

Thanks a lot for the report. It is caused by the environment capture function.

As a workaround it can be configured not to capture env variables (see schedule-capture-environment). But we should actually fix it by encrypting the values.

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