Let's say you have access to a remote machine and use it to copy backups occasionally, eg with rsync. Your local machine has credentials stored that allow write access on the remote machine, however if the local account was compromised that could also allow access to the remote machine and the data stored there.

How can you grant access to an account to write remotely, but also protect the data from this account? One possibility could be to change the permissions on the data after it is copied to prevent deletion/interference, although I'm just making this up. Is there a standard practise for this?

all 32 comments

sorted by: hot top controversial new old
[–] 25 points 4 months ago (8 children)

Do pull backups instead of push backups: Backup server connects to local machine.

  • source
  • hideshow 8 child comments
  • [–] 3 points 4 months ago (6 children)

    What's the rationale for this? Genuinely curious.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 21 points 4 months ago (1 child)

    The reasoning is that your backup server should be more secure than production. Production has to have a bunch of stuff open in order to be useful and convenient. The backup server does not. It can be basically fully locked down.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 5 points 4 months ago

    To add - by doing pulls the backup server uses different credentials to run than the credentials used to perform pulls.

    Backup server has it's own credentials database, machines being backed up have their own database. Backup service in backup server uses appropriate credentials from machine being backed up to access the data there (shares, etc). So credentials from compromised machine are unrelated to credentials for backup server.

    And if backups are done properly (full on a schedule, daily incrementals, or something similar) you should be able to revert to a known-good state with minimal data loss.

  • source
  • parent
  • [–] 5 points 4 months ago* (last edited 4 months ago) (2 children)

    If the main site gets compromised the credentials there must be considered lost and known to che attackers.

    with a pull backup that's not an issue because the main site has no access to the remote system; it is a process on the remote site that has credentials to access the main site and not the other way around.

    the remote system may receive retrieve a compromised copy of the data, but the attacker cannot tamper with previous backups so recovery is still possible.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 30 points 4 months ago

    Encrypt before send, and if you want to have protection against deletions of the data have a cold backup offline other than during the copy.

  • source
  • [–] 12 points 4 months ago (1 child)
  • [–] 8 points 4 months ago

    Append only mode.

  • source
  • [–] 7 points 4 months ago*

    I think you could do it somewhat like hetzner does for their storage boxes. You get an account that has read and write access to a directory and nothing outside. The accound can only run a limited set of commands, like ls, cat, nano, rsync etc. but has no access to commands that modify the filesystem.

    Then you can use a copy on write fs like btrfs and make scheduled staggered snapshots.

    I usually do 1x per year, 1x per month of current year, 4 per week of current montg, 7 per day in current week.

    I have no clue what they use to limit the user accounts like that btw. but maybe that gives you a new jump off point for further research.

  • source
  • [–] 7 points 4 months ago

    The suggestion I have heard is to have the remote machine connect to the machine on a schedule and pull the backups onto itself. Then your local machine doesn't have direct access to the backups, making it harder to compromise the backups if hacked. But this also assumes the backup machine is locked down and isolated so it is lower risk than the local machine.

  • source
  • [–] 5 points 4 months ago

    Append only, like others are saying.

  • source
  • [–] 4 points 4 months ago

    What you are talking about is Immutability and an append only backup. The s3 file system and some others has Immutability built in. Not all backups can do append only.

  • source
  • [–] 4 points 4 months ago (1 child)

    I have solved that by giving the distant machine the credentials to connect to the local machine. And the distant machine can't be accessed from the outside.

  • source
  • hideshow 1 child comment
  • [–] 4 points 4 months ago*

    Scheduled snapshots (btrfs or zfs). If the compromised account deletes or modifies files, they're still there in the past snapshots

    Filesystem-level snapshots are quite space-efficient because they don't make copies of all the files or even whole files; just the blocks that changed.

  • source
  • [–] 3 points 4 months ago

    Personally as some extra spice as I worry about ransomeare, I have a few key files I check across my array that should never change. If any of their hashes are off, I abort immediately.

  • source
  • [–] 3 points 4 months ago

    You've got the right idea with the permission change... the key is that you can have code executing on the remote side with different permissions. So the writer process has permission to write in one directory, and the turnsyle procees (often the root super-user) rotates the files or directories at a different time (or on a signal, sometimes).

  • source
  • [–] 2 points 4 months ago

    I mean depends on the solution you are using, but you can have multiple accounts on the remote backup. IE so upon completion of the backup. The remote machine moves the backup to an offline or read only share (depending if you need those credentials to access the data again later),

    Obviously most important thing is your credentials that make the backup... should be very limited in scope to just doing those backups.

  • source
  • [–] 2 points 4 months ago

    WORM: write once, read many. Any good backup software supports this.

    You could also keep offline backups. You can't compromise what you can't reach.

  • source
  • [–] [S] 1 point 4 months ago

    Yep offline backups are useful, although it does require remembering & making the effort to do it each time

  • source
  • [–] [S] 1 point 4 months ago

    Yes that seems like one way to go. Although I am using rsync so maybe keeping the files in place and changing owner could be an option

  • source
  • [–] [S] 1 point 4 months ago

    For doing snapshots did that means the local system identifies the changes? Or it all gets copied each time?

  • source
  • [–] [S] 1 point 4 months ago

    Certainly sounds relevant, although overall it is quite a different approach than in currently using

  • source
  • [–] 1 point 4 months ago (3 children)

    Are you connecting to the victim to push a backup into storage? If so, there's SO much you should improve on that.

  • source
  • hideshow 3 child comments
  • [–] 1 point 4 months ago (1 child)

    What are the vulnerabilities that you're afraid of? Can you answer this purely from the info OP gave, i.e. without making assumptions about what the server authorizes the phone to do? OP's post does not indicate that they're violating the principle of least privilege in any way.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 4 months ago*

    OP’s post does not indicate that they’re violating the principle of least privilege in any way.

    If I wasn't sure whether that was a risk, I would have asked whether that's what was going on. Oh, wait: I did, right? I used a question mark and everything.

  • source
  • parent