Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Support
  3. Impersonate user privilege escalation

Impersonate user privilege escalation

Scheduled Pinned Locked Moved Solved Support
security
14 Posts 4 Posters 2.3k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • iamthefijI Offline
    iamthefijI Offline
    iamthefij
    App Dev
    wrote on last edited by girish
    #1

    Note: I haven't tested this method yet as I am not sure which Apps already have the Docker addon, but making a custom one and installing it via the CLI after taking over the admin account with the temp password would be simple enough.

    I was just reading the documentation on how to do user impersonation and it appears that you only need access to write to /tmp. This is something that any non-privileged Unix user can write to.

    Theoretically, a normal user could do this to gain access to an Admin user and then be able to modify users or gain access to user information. They could also install an app with privileged access to the Docker socket and then use that to gain access to the machine by starting a container as root with access to the root filesystem. Eg. docker run -it -v /:/host ubuntu

    murgeroM 1 Reply Last reply
    0
    • girishG Offline
      girishG Offline
      girish
      Staff
      wrote on last edited by girish
      #2

      Only JupyterHub app on the app store uses docker addon. Normal users don't have access to docker containers as a privileged user in the app. For custom apps, only admins can install apps in the first place. Current, an admin can already generate reset password links of other users and fellow admins (clicking the plane button in the users view).

      So, I think the attack vector here is that an unknowing admin installs a custom app with the docker addon. Maybe, we need to add security warning in https://cloudron.io/documentation/custom-apps/addons/#docker for admins ? We could make it the docker addon unavailable for custom apps altogether. Not sure if this breaks "hackability"/tinkering

      1 Reply Last reply
      0
      • iamthefijI Offline
        iamthefijI Offline
        iamthefij
        App Dev
        wrote on last edited by
        #3

        The issue is that any unix user can gain access to admin through impersonation by writing to /tmp. Then they are free to install anything they want, ignoring any warnings and use that to escalate to unix root.

        girishG 1 Reply Last reply
        0
        • iamthefijI Offline
          iamthefijI Offline
          iamthefij
          App Dev
          wrote on last edited by
          #4

          Disallowing impersonation of an Admin would be one way to mitigate the escalation.

          Also, managing impersonation in app would do away with this as well.

          1 Reply Last reply
          0
          • iamthefijI iamthefij

            The issue is that any unix user can gain access to admin through impersonation by writing to /tmp. Then they are free to install anything they want, ignoring any warnings and use that to escalate to unix root.

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #5

            @iamthefij said in Impersonate user privilege escalation:

            The issue is that any unix user can gain access to admin through impersonation by writing to /tmp. Then they are free to install anything they want, ignoring any warnings and use that to escalate to unix root.

            True but we have not designed Cloudron to be safe from users with SSH/terminal access. For example, the database itself is available to all users. Our idea has always been that only the Cloudron admin has SSH access. In fact, with Cloudron 5, we are making this distinction a bit more clearer. The first admin is now called an 'owner'. Owner is someone who has access to server / administers the server / installed the Cloudron. Owner can add one or more admins who install apps and manage users. Admins don't require or need ssh access.

            1 Reply Last reply
            2
            • iamthefijI Offline
              iamthefijI Offline
              iamthefij
              App Dev
              wrote on last edited by
              #6

              This is not necessarily a Cloudron privilege escalation, but that Cloudron provides an attack vector for system privilege escalation.

              The process I laid out will allow one to get system root access.

              It puts a Cloudron server one arbitrary code execution bug away from a fully pwned system. Even an admin running a non-privileged script will allow someone to gain access to the entire server.

              This will be very easy to mitigate. I believe the easiest way is rather than using/tmp, which is world writable, put the files in a directory that is owned by the cloudron user. Users can write to it by doing echo '{"blah": "blah"}' | sudo -u cloudron tee /var/cloudron/ghost.json, then have Cloudron delete the file afterwards.

              1 Reply Last reply
              0
              • girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by girish
                #7

                @iamthefij I guess we tend to think Cloudron more as an appliance which nobody ssh's into and plays around. But there is ample evidence that people do run arbitrary stuff on the server after installing Cloudron even if we tell them it's not supported... I made a fix similar to your suggestion. I moved the ghost file into /home/yellowtent/platformdata and changed the owner as well. This way non-root users cannot create such a file and cannot read an existing file either (commit).

                Thanks for reporting!

                1 Reply Last reply
                2
                • iamthefijI iamthefij

                  Note: I haven't tested this method yet as I am not sure which Apps already have the Docker addon, but making a custom one and installing it via the CLI after taking over the admin account with the temp password would be simple enough.

                  I was just reading the documentation on how to do user impersonation and it appears that you only need access to write to /tmp. This is something that any non-privileged Unix user can write to.

                  Theoretically, a normal user could do this to gain access to an Admin user and then be able to modify users or gain access to user information. They could also install an app with privileged access to the Docker socket and then use that to gain access to the machine by starting a container as root with access to the root filesystem. Eg. docker run -it -v /:/host ubuntu

                  murgeroM Offline
                  murgeroM Offline
                  murgero
                  App Dev
                  wrote on last edited by
                  #8

                  @iamthefij said in Impersonate user privilege escalation:

                  I was just reading the documentation on how to do user impersonation and it appears that you only need access to write to /tmp. This is something that any non-privileged Unix user can write to.

                  /tmp is only writable when in CLI or an app that has a feature to write to this (in the docker container, not the cloudron server)

                  --
                  https://urgero.org
                  ~ Professional Nerd. Freelance Programmer. ~

                  iamthefijI 1 Reply Last reply
                  1
                  • murgeroM murgero

                    @iamthefij said in Impersonate user privilege escalation:

                    I was just reading the documentation on how to do user impersonation and it appears that you only need access to write to /tmp. This is something that any non-privileged Unix user can write to.

                    /tmp is only writable when in CLI or an app that has a feature to write to this (in the docker container, not the cloudron server)

                    iamthefijI Offline
                    iamthefijI Offline
                    iamthefij
                    App Dev
                    wrote on last edited by
                    #9

                    @murgero I’m not sure what you mean. Anyone with shell access to the server as any user could do this.

                    @girish thanks for the quick update! L

                    Thinking on it a bit more, for more defense in depth I’m realizing that if the server is running as yellowtent the directory ought to be read only for that user. Otherwise a remote execution vulnerability is enough to own the server and escalate privileges.

                    I’m not a proper security auditor though...

                    Have you considered getting a professional audit?

                    fbartelsF 1 Reply Last reply
                    1
                    • iamthefijI iamthefij

                      @murgero I’m not sure what you mean. Anyone with shell access to the server as any user could do this.

                      @girish thanks for the quick update! L

                      Thinking on it a bit more, for more defense in depth I’m realizing that if the server is running as yellowtent the directory ought to be read only for that user. Otherwise a remote execution vulnerability is enough to own the server and escalate privileges.

                      I’m not a proper security auditor though...

                      Have you considered getting a professional audit?

                      fbartelsF Offline
                      fbartelsF Offline
                      fbartels
                      App Dev
                      wrote on last edited by
                      #10

                      @iamthefij talking about irresponsible disclosure. For the benefit of other Cloudron users it may be wiser to have a non public channel to discuss something like this.

                      (But it's indeed good that is was noticed and changed)

                      iamthefijI 1 Reply Last reply
                      0
                      • fbartelsF fbartels

                        @iamthefij talking about irresponsible disclosure. For the benefit of other Cloudron users it may be wiser to have a non public channel to discuss something like this.

                        (But it's indeed good that is was noticed and changed)

                        iamthefijI Offline
                        iamthefijI Offline
                        iamthefij
                        App Dev
                        wrote on last edited by
                        #11

                        @fbartels good point. @girish Is there a non-public channel for this?

                        1 Reply Last reply
                        0
                        • girishG Offline
                          girishG Offline
                          girish
                          Staff
                          wrote on last edited by
                          #12

                          Our bad that we don't have any specific guidelines to report security issues. We will add this to our site. In the meantime:

                          • Write to support@cloudron.io
                          • Alternately, you can open a "confidential" issue in https://git.cloudron.io/cloudron/box/issues (this does require you to register in our gitlab and enable 2FA).
                          1 Reply Last reply
                          2
                          • girishG Offline
                            girishG Offline
                            girish
                            Staff
                            wrote on last edited by
                            #13

                            Just to follow up on this. Now that we have owner role in Cloudron 5, install/update/repair/exec of apps that use the docker addon is restricted to owner in 5.1. This then means that an admin cannot get access to some shell and access docker and hijack the system.

                            On a technical note, docker is accessed by apps via proxy. This proxy verifies that only apps that request the docker addon can access the docker API. The proxy also ensures that random volumes cannot be mounted (only /app/data of the app can be volume mounted).

                            1 Reply Last reply
                            3
                            • iamthefijI Offline
                              iamthefijI Offline
                              iamthefij
                              App Dev
                              wrote on last edited by
                              #14

                              Thanks @girish!

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Bookmarks
                              • Search