-
Notifications
You must be signed in to change notification settings - Fork 687
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
Adds option to restore from backup file already on server. #5909
Conversation
when the '--no-transfer' argument is used with `./securedrop-admin restore`, instead of transferring the backup tarball to the Application Server, the local copy of the tarball will be compared with an expected remote file of the same name in `/tmp` on the server. If checksums match, the remote copy will be used to perform the backup. This is intended to address cases where backups are too large to reliably transmit over Tor via the Ansible synchronize module. Instead, backups can be copied to the server using rsync, or via an encrypted transfer USB.
5ebe435
to
68c86bb
Compare
|
||
- name: Calculate remote backup file checksum | ||
stat: | ||
path: "/tmp/{{ restore_file }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about allowing a full path, to allow for /tmp
on the server not having enough free space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not in favour of it - points against:
- The SD setup instructions as they stand don't result in a separate
/tmp
partition, so if there's enough space on/
this isn't an issue - and the backup job would have failed in the first place as it also uses/tmp
- this is the current backup location - it would introduce more changes and would require extra work to make sure backup tempfiles are purged from whatever alternate location was specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, writing sensitive files to /tmp
is not recommended [1], due to the permissions of that partition, and the ability of all system users to write to it. In this case, the servers are effectively single-user systems, so the risks are relatively low, but in the case where an attacker has unprivileged access to the system, they may have access to more information.
[1] some links/references in https://security.openstack.org/guidelines/dg_using-temporary-files-securely.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following steps failed:
- on the app server:
sudo cp v2nv3.tar.gz /tmp/
- on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
- confirm that the restore process completes sucessfully, and that the task to transfer the tarball does not run.
- on the app server:
sudo rm /tmp/v2nv3.tar.gz
- on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
- confirm that the restore process completes sucessfully, and that the task to transfer the tarball does run.
The error message:
TASK [restore : Verify that local and remote backup file checksums match] **************************************
fatal: [app]: FAILED! => {}
MSG:
The conditional check 'remote_backup_file.stat.checksum == local_backup_file.stat.checksum' failed. The error was: error while evaluating conditional (remote_backup_file.stat.checksum == local_backup_file.stat.checksum): 'dict object' has no attribute 'checksum'
NO MORE HOSTS LEFT *********************************************************************************************
NO MORE HOSTS LEFT *********************************************************************************************
PLAY RECAP *****************************************************************************************************
app : ok=10 changed=6 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
I guess the test step is wrong, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with
-
on the admin workstation:
./securedrop-admin --force restore --preserve-tor-config --no-transfer install_files/ansible-base/v2-only.tar.gz
- confirm that the restore process quits with a message about a checksum mismatch without performing any server-side steps.
-
on the app server:
sudo cp v2-only.tar.gz /tmp/
-
on the admin workstation:
./securedrop-admin --force restore --preserve-tor-config --no-transfer install_files/ansible-base/v2-only.tar.gz
- confirm that the restore process completes sucessfully, and that the task to transfer the tarball does not run.
-
on the app server:
sudo rm /tmp/v2-only.tar.gz
-
on the admin workstation:
./securedrop-admin --force restore --preserve-tor-config install_files/ansible-base/v2-only.tar.gz
- confirm that the restore process completes sucessfully, and that the task to transfer the tarball does run.
-
on the app server:
sudo cp v2-only.tar.gz /tmp/v2nv3.tar.gz
-
on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
- confirm that the restore process quits with a message about a checksum mismatch without performing any server-side steps.
-
on the app server:
sudo cp v2nv3.tar.gz /tmp/
-
on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
- confirm that the restore process completes sucessfully, and that the task to transfer the tarball does not run.
-
on the app server:
sudo rm /tmp/v2nv3.tar.gz
-
on the admin workstation:
./securedrop-admin --force restore install_files/ansible-base/v2nv3.tar.gz
- confirm that the restore process completes sucessfully, and that the task to transfer the tarball does run.
I am okay to merge this. Will do so after the standup.
Status
Ready for review
Description of Changes
Fixes #5906 .
when the
--no-transfer
argument is used with./securedrop-admin restore
,instead of transferring the backup tarball to the Application Server, the
local copy of the tarball will be compared with an expected remote file of the
same name in
/tmp
on the server. If checksums match, the remote copy will beused to perform the backup.
This is intended to address cases where backups are too large to reliably
transmit over Tor via the Ansible synchronize module. Instead, backups can be
copied to the server using rsync, or via an encrypted transfer USB.
Testing
Acquire some backup files (one v2-only (
v2-only.tar.gz
), one v2+v3(v2nv3.tar.gz
))Set up a prod Focal instance
switch to this branch on the admin workstation
copy the backup files to the ad admin home directory on the app server
on the app server:
sudo cp v2nv3.tar.gz /tmp/v2-only.tar.gz
on the admin workstation:
./securedrop-admin --force restore --preserve-tor-config --no-transfer install_files/ansible-base/v2-only.tar.gz
on the app server:
sudo cp v2-only.tar.gz /tmp/
on the admin workstation:
./securedrop-admin --force restore --preserve-tor-config --no-transfer install_files/ansible-base/v2-only.tar.gz
on the app server:
sudo rm /tmp/v2-only.tar.gz
on the admin workstation:
./securedrop-admin --force restore --preserve-tor-config install_files/ansible-base/v2-only.tar.gz
on the app server:
sudo cp v2-only.tar.gz /tmp/v2nv3.tar.gz
on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
on the app server:
sudo cp v2nv3.tar.gz /tmp/
on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
on the app server:
sudo rm /tmp/v2nv3.tar.gz
on the admin workstation:
./securedrop-admin --force restore --no-transfer install_files/ansible-base/v2nv3.tar.gz
for extra points, try playing around with other backup files - take chances, make mistakes, get messy!
Deployment
Deployed with admin workstaiton update
Checklist
If you made changes to
securedrop-admin
:make -C admin test
) pass in the admin development containerIf you made non-trivial code changes:
Choose one of the following: