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?

  • ShellMonkey@piefed.socdojo.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

  • TheFogan@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

  • dieTasse@feddit.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    Just a small sidenote: If you do not trust your local machine you should think about why and how to change that.

    • eyesaremosaics@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 month ago

      Well I think she amount of caution is still appropriate no matter how much you manage to secure the local machine

  • frongt@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

  • bacon_pdp@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    Append only permissions.

    Encrypted deltas.

    Basically the time of the connection is the name of the only that folder that you have access to.

    You can also setup a yubikey (or nitrokey) that requires you to physically process and would be immune to the host being compromised.

  • HelloRoot@lemy.lol
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

    • groet@feddit.org
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 month ago

      Nano and rsync are 100% designed to modify the filesystem. But yes the idea is correct.

      Same with got over ssh, you restrict the connection to the got shell that can only do the things you want.

      • HelloRoot@lemy.lol
        link
        fedilink
        English
        arrow-up
        0
        ·
        1 month ago

        Are they? I thought they only write/modify/delete data to the fs, not change the fs itself.

        • groet@feddit.org
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 month ago

          Yeah precice phrasing ia hard sometime. I was refering to delete/modify of files as “changes to the fs”. Not sure how changing the actuall fs would be relevant to the backup question.

          OP needs a restricted shell that can take backup data and write it to disk but not be able to modify anything that is already there. Nano and rsync can both do that.

  • zorflieg@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

  • corsicanguppy@lemmy.ca
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

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

    • glibg10b@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 month ago

      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.

  • Gagootron@feddit.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    A system like proxmox backup server can do this scurely. There you can create a user that can only add new backups and read the existing ones, but cannot delete any or read anything else on the remote host.

    Otherwise if you only care to protect the remote machine, then something like an ssh chroot jail would also work.

  • glibg10b@lemmy.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

  • Eirikr70@jlai.lu
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month ago

    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.

  • Scrubbles@poptalk.scrubbles.tech
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.

  • monkeyman512@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 month 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.