I have a few Linux servers at home that I regularly remote into in order to manage, usually logged into KDE Plasma as root. Usually they just have several command line windows and a file manager open (I personally just find it more convenient to use the command line from a remote desktop instead of directly SSH-ing into the system), but if I have an issue, I’ve just been absentmindedly searching stuff up and trying to find solutions using the preinstalled Firefox instance from within the remote desktop itself, which would also be running as root.

I never even thought to install uBlock Origin on it or anything, but the servers are all configured to use a PiHole instance which blocks the vast majority of ads. However, I do also remember using the browser in my main server to figure out how to set up the PiHole instance in the first place, and that server also happens to be the most important one and is my main NAS.

I never went on any particularly shady websites, but I also don’t remember exactly which websites I’ve been on as root, though I do seem to remember seeing ads during the initial pihole setup, because it didn’t go very smoothly and I was searching up error messages trying to get it to work.

This is definitely on me, but it never crossed my mind until recently that it might be a bad idea to use a browser as root, and searching online everyone just states the general cybersecurity doctrine to never do it (which I’m now realizing I shouldn’t have) but no one seems to be discussing how risky it actually is. Shouldn’t Firefox be sandboxing every website and not allowing anything to access the base system? Between “just stop doing it” and “you have to reinstall the OS right now there’s probably already a virus on there,” how much danger do you suppose I’m in? I’m mainly worried about the security/privacy of my personal data I have stored on the servers. All my servers run Fedora KDE Spin and have Intel processors if that makes a difference?

  • Illecors@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    66
    ·
    6 months ago

    Is it actually dangerous to run Firefox as root?

    Yes, very. This is not specific to Firefox, but anything running as root gets access to everything. Only one thing has to go wrong for the whole system to get busted.

    usually logged into KDE Plasma as root.

    Please don’t do this! DEs are not tested to be run as root! Millions of lines of code are expected to not have access to anything they shouldn’t have and as such might be built to fail quietly if accessing something they shouldn’t in the first place. Same thing applies to Firefox, really.

    • HiddenLayer5@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      3
      ·
      6 months ago

      Please don’t do this! DEs are not tested to be run as root! Millions of lines of code are expected to not have access to anything they shouldn’t have and as such might be built to fail quietly if accessing something they shouldn’t in the first place. Same thing applies to Firefox, really.

      Could you elaborate on this? I’m genuinely surprised because Fedora just asks you if you want to have the option to log into root from KDE during installation, so I always just assumed that it’s intended to be used that way.

      • Illecors@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        29
        ·
        edit-2
        6 months ago

        I don’t know the specifics on Fedora’s installer, but normally that question is about disabling root account, not logging into a DE.

        Not sure what else to elaborate here. There’s a bunch of code that is not tested to be run as root. A whole class of exploits becomes unavailable, if you stick to an unprivileged user.

        Say there’s some exploit that allows some component of KDE to be used to read a file. If it’s running under an unprivileged user - it sucks. Everything in user’s homedir becomes fair game. But if it runs as root - it’s simply game over. Everything on the system is accessible. All config, all bad config, files of all applications (databases come to mind). Everything.

        • HiddenLayer5@lemmy.mlOP
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          1
          ·
          edit-2
          6 months ago

          Thank you.

          Say there’s some exploit that allows some component of KDE to be used to read a file. If it’s running under an unprivileged user - it sucks. Everything in user’s homedir becomes fair game. But if it runs as root - it’s simply game over. Everything on the system is accessible. All config, all bad config, files of all applications (databases come to mind). Everything.

          This is also something I’m thinking about: All the hard drives mounted on the server is accessible to the only regular user as that is what my other computers use to access them. I’m the only one with access to the server so everything is accessible under one user. The data on those drives is what I want to protect, so wouldn’t a vulnerability in either KDE or Firefox be just as dangerous to those files even running as the regular user?

          Also, since my PC has those drives mounted through the server and accessible to the regular user that I use my PC as, wouldn’t a vulnerability in a program running as the regular user of my PC also compromise those files even if the server only hosted the files and did absolutely nothing else? Going back to the Firefox thing, if I had a sandbox breach on my PC, it would still be able to read the files on the server right? Wouldn’t that be just as bad as if I had been running Firefox as root on the server itself? Really feels like the only way to 100% keep those files safe is to never access them from an internet accessible computer, and everything else just falls short and is just as bad as the worst case scenario, though maybe I’m missing something. Am I just being paranoid about the non-root scenarios?

          How does a “professional” NAS setup handle this?

          • 4am@lemm.ee
            link
            fedilink
            arrow-up
            14
            ·
            6 months ago

            You never log in as root. On every new VM/LXC I create, I delete the root password after setting it up so that my regular user can use sudo.

            Run as your regular user and sudo the commands that need privileges.

            Also if these are servers, run them headless. There’s no need for a GUI or a browser (use wget or curl for downloads, use your local browser for browsing)

          • TreeGhost@lemm.ee
            link
            fedilink
            arrow-up
            5
            ·
            6 months ago

            You keep your files safe by having backups. Multiple copies. Set up the backups to gets copied to another server or other system your regular user doesn’t have access to. Ideally, you follow the 3-2-1 backup standard if the files are important. That is 3 copies, on 2 different media, and 1 offsite. There are many ways of accomplishing that and its up to you to figure out what works best.

  • remotelove@lemmy.ca
    link
    fedilink
    arrow-up
    65
    ·
    6 months ago

    Your frame of mind is “dangerous”. If you are browsing on your servers as root, you need to not manage servers anymore. If that sounded harsh, learn about attack surface area first and then I might let you back in the server room.

    You won’t find discussions about running browsers as root because it’s not something you should need to discuss. Also, you don’t need to be browsing “shady” websites to get compromised. Get that myth out of your head.

    find it more convenient to use the command line from a remote desktop instead of directly SSH-ing into the system

    How is extra steps and added latency more convenient? The latency of a console via remote desktop would drive me crazy. Hell, I haven’t installed any kind of desktop environment on Linux server for over 20 years. It’s not needed and a waste of resources. Who needs file managers anyway?

    • Potatos_are_not_friends@lemmy.world
      link
      fedilink
      arrow-up
      33
      ·
      edit-2
      6 months ago

      Your frame of mind is “dangerous”. If you are browsing on your servers as root, you need to not manage servers anymore. If that sounded harsh, learn about attack surface area first and then I might let you back in the server room.

      You sir/ma’am hit it right on the head.

      The “run root on Firefox” isn’t the issue, it’s the red flag. Security is a mindset. Failure to understand the core philosophy of why we have roles and permissions means you’re untrusted. It really isn’t personal. It’s security.

  • MimicJar@lemmy.world
    cake
    link
    fedilink
    arrow-up
    59
    ·
    6 months ago

    https://www.mozilla.org/en-US/security/advisories/mfsa2023-56/

    That’s a link to the most recent release of Firefox and the security vulnerabilities that were fixed.

    You’ll notice the first one listed says, “This issue could allow an attacker to perform remote code execution and sandbox escape.”

    So if you visited a site that exploited that bug, it escaped the sandbox and ran whatever code it wanted to. Since you were running as root it could do anything it wants. Your device is now the property of someone else. Potentially all your data has been stolen. You probably didn’t even notice.

    Now. Realistically. You probably didn’t get exploited. Your device may not be vulnerable to that particular bug. But new bugs are found, and fixed, and created every day. Can you be sure you weren’t exploited?

    Let’s look at it a different way. Think of it like driving a car with no seatbelt or airbags. As long as you don’t crash, you’re fine. The car still works fine without seatbelts and you have more freedom to move your arms around.

    Let’s look at it a different way. Do you ever lock the door to your home/apartment? Heck do you even close the door? Why not leave it wide open?

    At the end of the day security is about layers and the trade offs for convenience. You can run KDE as root, and you can run Firefox as root. You’ll probably be fine. It’s like driving without a seatbelt or leaving your front door wide open, but you can do it. If you do drive with a seatbelt and at least close your front door, you can probably run KDE and Firefox as a regular user.

  • Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    44
    ·
    6 months ago

    I think there are many security issues with your setup. You really, really shouldn’t do everything as root. That is just a time bomb waiting to blow.

  • FishFace@lemmy.world
    link
    fedilink
    arrow-up
    33
    ·
    6 months ago

    An overarching principle of security is that of minimum privilege: everything (every process, every person) should have the minimum privileges it needs to do what it does, and where possible, that privilege should be explicitly granted temporarily and then dropped.

    This means that any issue: a security breach or a mistake can’t access or break anything except whatever the component or person who had the issue could access or break, and that that access is minimal.

    Suppose that you hit a page which exploits the https://www.hkcert.org/security-bulletin/mozilla-firefox-remote-code-execution-vulnerability_20230913 vulnerability in Firefox, or one like it, allowing remote code execution. If Firefox is running as root, the remote attacker now completely controls that machine. If you have SSH keys to other servers on there, they are all compromised. Your personal data could be encrypted for ransom. Anything that server manages, such as a TV or smart home equipment, could be manipulated arbitrarily, and possibly destroyed.

    The same is true for any piece of software you use, because this is a general principle. Most distributions I believe don’t let you ssh in as root for that reason.

    In short: don’t log in to anything as root; log in as a regular user and use sudo to temporarily perform administrator actions.

    P.S. your description of the situation shows you don’t know the nature of vulnerabilities and security - if you’re running servers then this is something you should learn more about in short order.

  • Amju Wolf@pawb.social
    link
    fedilink
    arrow-up
    21
    ·
    edit-2
    6 months ago

    I don’t want to step on your workflow too much since it somehow seems to work for you but your main issue stems from the fact that you clearly don’t work with your server as if it actually was a server.

    You shouldn’t really have a desktop interface running there in the first place (let alone as root and then using it as a regular user). You should ask yourself what it actually solves for you and be open to trying different (and more standard) solutions to what you’re trying to achieve.

    It’d probably consist of less clicking and using the CLI a bit more, but for stuff like file management you can still easily use mc.

    If you need terminal sessions that keep scrollback and don’t stop when you disconnect you should learn to use tmux or screen or something like that. But then again if you’re running actual software in there then you should probably use a service (daemon) for that.

    As for whether it’s a security issue, yeah it most definitely is. Just like it’s a security issue to run literally any networked application as root. Security isn’t black and white and there are trade offs to be made but most people wouldn’t consider what you’re doing a reasonable tradeoff.

    • HiddenLayer5@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      edit-2
      6 months ago

      I had actually moved from a fully CLI server to one with a full desktop when I upgraded from a single board computer to x86. The issue is that it’s not just a NAS, but I regularly use it to offload long operations (moving, copying, or compressing files, mostly) so I don’t need to use my PC for those. To do that I just remote into it and type in the command, then I can turn my PC off or do whatever without affecting the operation. So in a way it’s a second PC that also happens to be a server for my other machines.

      I use screen occasionally, and I used to use it a lot more when it was CLI only, but I find it really unwieldy due to how it manages multiple active terminals where you have to type in the ID of each screen to go back into it, and also because it refuses to scroll even when run in a terminal emulator that supports scrolling, where it just cycles between recent commands when you move the scroll wheel.

      Not trying to make excuses, just trying to explain my reasoning. I know it’s bad practice and none of these are things I’d do if I was managing an actual production server, but since it’s only accessible from my LAN I tend to be a lot more lax with it.

      I’m wondering if I could benefit from some kind of virtualized setup that separates the server stuff while still letting me remote into a desktop on the same machine for doing stuff, or if I can get away with just remoting into not the root user. Though I’ve never used a hypervisor and have no idea how to so I’m not sure how well that would go, since the well-known open source ones like Xen seem really technical and really feels like something not meant to be used outside an actual data centre.

      • Amju Wolf@pawb.social
        link
        fedilink
        English
        arrow-up
        9
        ·
        edit-2
        6 months ago

        I see. In that case you should really try tmux; I didn’t vibe with screen either but I find tmux quite usable.

        For the most part I just open several terminal windows/tabs on my local machine and remote with each one to the server, and I use tmux only when I explicitly need to keep something running. Since that’s usually just one thing I can use like two tmux commands and don’t need anything else.

        Oh and for stuff like copying and such I’d use rsync instead of primitive cp so that in case it gets interrupted I only copy what’s needed.

        I wouldn’t bother with virtualization and such; you’d only complicate things for yourself. Try to keep it simple but do it properly: learn some command line basics and you’ll see that in a year it’ll become second nature.

      • Illecors@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        8
        arrow-down
        1
        ·
        edit-2
        6 months ago

        Sorry, this is very much a PEBKAC issue. This is a excerpt from my tmux config:

        # Start windows and panes at 1, not 0
        set -g base-index 1
        setw -g pane-base-index 1
        
        # Use Alt-arrow keys without prefix key to switch panes
        bind -n M-Left select-pane -L
        bind -n M-Right select-pane -R
        bind -n M-Up select-pane -U
        bind -n M-Down select-pane -D
        
        # Shift arrow to switch windows
        bind -n S-Left  previous-window
        bind -n S-Right next-window
        
        # No delay for escape key press
        set -sg escape-time 0
        
        # Increase scrollback buffer size from 2000 to 50000 lines
        set -g history-limit 50000
        
        # Increase tmux messages display duration from 750ms to 4s
        set -g display-time 4000
        
        # Bind pane creation keys to reuse current directory
        bind % split-window -h -c "#{pane_current_path}"
        bind '"' split-window -v -c "#{pane_current_path}"
        

        I hope the comments are self explanatory.

        Scrolling works with Ctrl+b Page Up/Down. There are other shortcuts, but this is probably the most obvious. q to quit scrolling.

        Ctrl+b d to detach from a session. tmux a to attach. As always, many options are available to have many named sessions running simultaneously, but that is for a later time.

      • giloronfoo@beehaw.org
        link
        fedilink
        arrow-up
        6
        ·
        6 months ago

        I’d go for remoting in as not root as the first (and maybe only) step for better security.

        From there, running the services in VMs would probably be the next step. Docker might be better, but I have gotten into that yet myself.

        As for hypervisor, KVM has worked great for me.

        • pbjamm@beehaw.org
          link
          fedilink
          English
          arrow-up
          2
          ·
          6 months ago

          KVM is awesome. It is the core of Proxmox which is my preferred way to manage VMs and LXC containers now. I used to run debian+KVM+virt-manager or cockpit but Proxmox does all the noodling setup for me and then just works.

  • rottingleaf@lemmy.zip
    link
    fedilink
    arrow-up
    15
    ·
    6 months ago

    Yes, it is. As a user you compromise only that user as a consequence of some sandbox escape. Then there may or may not be some successful privilege elevation.

  • Falcon@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    6 months ago

    I have no clue how dangerous running Firefox as root is, but it begs the question…why would you do that?

    Create a user account for managing things and create a separate user for each service and/or containers.

    For managing things use tmux with ssh, if you want to manage files etc. just use ranger/lf/mc. One can also mount the file system with sshfs.

  • ThankYouVeryMuch@kbin.social
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    6 months ago

    I just wanted to add that you can run gui applications through ssh with x11 forwarding, options -X or -Y (untrusted/trusted but at least in Debian back in the day they behaved the same). So if you wanted a gui file manager you run it in the ssh session on the remote server, sudo if you need but NEVER logged as root, and the window will pop on your local DE instead of having to run an entire desktop on each server

  • arjache@kbin.social
    link
    fedilink
    arrow-up
    12
    ·
    6 months ago

    As a general best practice, you should never directly login as root on any server, and those servers should be configured to not allow remote connections as the root user. You should always log in as a non-root user and only run commands as root using sudo or similar features offered by your desktop environment. You should be wary of even having an interactive root shell open; usually I would only do so on a VM console, when first setting up a system or debugging it.

    By doing this, you not only guard against other people compromising your system, but also against accidentally running commands as root that could damage your system. It’s always best to only run things with the minimum permissions they need, and then only grant them additional permissions on an as-needed basis.

  • Dyskolos@lemmy.zip
    link
    fedilink
    arrow-up
    13
    arrow-down
    1
    ·
    6 months ago

    Just don’t do that 😁

    I don’t get it anyway, if you login remotely, why don’t you just open firefox locally but on the remote servers? This makes not much sense.

    But If you absolutely have to. … At least be careful with your surf-targets. A search-engine and wiki would most likely be fine. Some pron-, stream- or warez-sites? Nah. Surely not.

  • BigTrout75@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    1
    ·
    6 months ago

    This is like removing a safety feature in your car. Like removing seatbelts or maybe anti-lock brakes.

  • dbx12@programming.dev
    link
    fedilink
    arrow-up
    9
    ·
    6 months ago

    Without any judgement: why are your servers running X11? Just because you dislike SSH’ing to them?

    • HiddenLayer5@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      3
      ·
      6 months ago

      Mainly that. I want to be able to have multiple terminal windows open and have them stay open independent of my main PC. Part of the reason I have a file server instead of plugging all the drives into my PC is so I can offload processor heavy operations onto it (namely making archives and compressing files for long term storage) so I don’t have to use my PC for that.

      People have mentioned programs like screen but IMO it’s way more annoying to juggle multiple terminals with it than if they were just windows, and also screen doesn’t scroll so whatever goes beyond the top edge is just inaccessible which I find really annoying. I’ve also been screwed by mistyped file operations on the terminal before (deleting stuff I didn’t mean to mainly) and I just find it safer to use a GUI file manager where it’s a lot harder to subtly mess something up and not notice until it’s too late.

      • Hexarei@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        6 months ago

        screen doesn’t scroll

        Screen (and any other muxer) can scroll just fine. You just have to learn how to do it in each one. Tmux, for example, is ctrl+b [ to enter scroll mode.

        mistyped file operations

        Get a good TUI file manager. I use and recommend ranger.

        • tslnox@reddthat.com
          link
          fedilink
          arrow-up
          3
          ·
          6 months ago

          Screen uses Ctrl-a Esc (you press Ctrl+a, release them and then tap Esc, then you can scroll with arrows or pup/pgdown)

      • blobjim [he/him]@hexbear.net
        link
        fedilink
        English
        arrow-up
        2
        ·
        6 months ago

        tmux has long been the better replacement to screen. SFTP makes it so you can use desktop software for file system operations.