Docker - PRIVILEGE ESCALATION Technique

Поделиться
HTML-код
  • Опубликовано: 16 дек 2024

Комментарии • 72

  • @crazyland7507
    @crazyland7507 4 года назад +37

    Video starts at 2:34

  • @westernvibes1267
    @westernvibes1267 4 года назад +53

    Me : " i wish someone can give osce review"
    John : *uploads osce review*
    Me : " mmm i wish i could learn more vulnserver commands i just know trun, gter"
    John : *makes a vulnserver video*
    Me : "man i know nothing about docker and active directory privescs"
    John : *makes docker priv esc*
    Damn john right here reading minds

    • @_JohnHammond
      @_JohnHammond  4 года назад +3

      Ha! Our priorities are aligned mwahaha. Thanks so much for watching!

  • @ashishkhanduri1327
    @ashishkhanduri1327 Год назад

    Sleek... after watching u for years constantly...now i can watch what ur doing in 1.2x ...and the funny part is i can get all that info bombarded.....thx for upgrading my free of cost journey to ur world....hahha

  • @9000fail
    @9000fail 4 года назад +1

    Congrats on the sponsorship! If anyone deserves it it's you man

    • @_JohnHammond
      @_JohnHammond  4 года назад

      Thank you! Good to get those in every now and again. :) Thanks for watching!

    • @potatoonastick2239
      @potatoonastick2239 4 года назад

      Damn, screw your username
      This gives me flashbacks to spamming those characters wherever i could to fuck with people lmao

  • @adminservice9459
    @adminservice9459 3 года назад +1

    Dude this is one of your best videos. Very powerful!! Thx

  • @vlmath314
    @vlmath314 4 года назад +1

    that why you shall configure the user namespace, and use a difference socket for each user, otherwise, giving a user docker acces (via the docker group) is the same as giving him the root group

  • @exoooooooo
    @exoooooooo 2 года назад

    I believe I'm not the only one who expect the video is about escaping container

  • @davidhernandeze
    @davidhernandeze 4 года назад +8

    Great video as always, I would like if you share some links or advises to avoid the exploits you talk about

    • @_JohnHammond
      @_JohnHammond  4 года назад +5

      Thanks so much!
      I can try put something together like that... for this one, just avoid having low-privilege users that do not need to be running Docker commands within the Docker group. Try and remove as much as you can from the Docker group.

  • @uploadvoice
    @uploadvoice 2 года назад

    Well, the issue here is that a mount to the host root file system has been given, if it was not the case, this truck wouldn’t have worked…

  • @נועםפלמר
    @נועםפלמר Год назад

    Strong

  • @Kabbone
    @Kabbone 4 года назад +2

    That's why you never give access to the docker daemon or map the docker socket to a container.
    Note: This only works with privileged containers

    • @davidyanceyjr
      @davidyanceyjr 3 года назад

      and not just privileged? you would have to be in the same "mount" namespace. correct?

  • @sjorsborsoborsobors
    @sjorsborsoborsobors 4 года назад +9

    So if you give someone permission to run Docker on a machine, is there any way to prevent them from getting root access as well? Or should you never give access to Docker to someone you don't trust?

    • @_JohnHammond
      @_JohnHammond  4 года назад +12

      Never give access to Docker for a user that might not be trusted. Their documentation has a good warning: "The docker group grants privileges equivalent to the root user."
      docs.docker.com/install/linux/linux-postinstall/
      They also have some suggested techniques here:
      docs.docker.com/engine/security/security/#docker-daemon-attack-surface

    • @atanaspashov2437
      @atanaspashov2437 4 года назад +7

      Standard docker daemon runs as root so if somebody can run containers they can alway PrivEsc like in this example. There is rootless mode of docker: docs.docker.com/engine/security/rootless/ which let's you run docker daemon with your user ID (Not root)so you cannot write to files that your user does not have write access to. In other words no PrivEsc.

    • @bmitch3020
      @bmitch3020 4 года назад +1

      You'd need to run docker rootless. Support for that was recently released, but requires some settings on the host to make it possible. In general, don't give untrusted users docker API access, it's effectively giving them root.

  • @raphaeloester4753
    @raphaeloester4753 3 года назад +2

    Actually the dockerfile part is useless, you can just run this technique from a simple ubuntu:latest image without creating the workdir in the first place. That makes it a one-liner. But anyway, nice vid as always :)

  • @eatsoup01
    @eatsoup01 4 года назад +3

    Hi John, great video!
    Could you tell us why we see CPU registers during your Docker build process @7:02 ?

    • @_JohnHammond
      @_JohnHammond  4 года назад +6

      That doesn't typically happen. For some reason every now and again on my machine Docker spits all that nonsense out -- something somehow goes wrong somewhere -- but it still creates the image. ¯\_(ツ)_/¯
      Thanks for watching!

  • @artemcodes
    @artemcodes 2 года назад

    awesome explanation, thank you so much👍

  • @priyanshukumarpu
    @priyanshukumarpu 4 года назад

    2:34 Start

  • @anuradhalakruwan1918
    @anuradhalakruwan1918 4 года назад +1

    Good lesson. 👍 Thank you. 🕵️‍♂️🕵️‍♀️🕵️‍♂️🕵️‍♀️🕵️‍♂️

  • @nandandesai6524
    @nandandesai6524 4 года назад

    This is so cool!! Thanks John!

  • @erickramones2167
    @erickramones2167 4 года назад

    wait for 4 second before pressing enter and running a command. sometimes it is hard to read what you type in the terminal

  • @nullnull6032
    @nullnull6032 2 года назад

    How would you protect against that? I mean a lot of us have docker on their system?

  • @bigfood2001
    @bigfood2001 2 года назад

    thanks :)

  • @trunglongng4237
    @trunglongng4237 Год назад

    i got stuck in a docker container. "docker command not found". i got a bash script and a .dockerenv file...

  • @dimplegajra8564
    @dimplegajra8564 2 года назад

    Can this privilege escalation be detected by EDR? The confusing part for me from this video was, how can a user change host os permissions while in docker?

  • @i_sometimes_leave_comments
    @i_sometimes_leave_comments 4 года назад +1

    Besides not adding a user to the docker group and not having docker run on startup (or without sudo), how can we fix this? Is this an open exploit?

    • @Kabbone
      @Kabbone 4 года назад

      you could run unprivileged containers with podman without the docker daemon

  • @hatit8074
    @hatit8074 3 года назад

    Hi John. I wonder wt if we don't have internet access in the victim machine for downloading weezy. I think a good idea would be to download the weezy image in our local system and export and save it as a file. Then transfer that image file to victim and import it locally using docker import. And then run the container. I just thought this idea. I don't know how far that works. I have to try this. I got this idea watching ur video. Thnx a lot. Big fan of yours.

  • @Lacsap3366
    @Lacsap3366 2 года назад

    I also always confuse the order of the usermod syntax haha

  • @Operaatoors
    @Operaatoors 4 года назад

    So basically it means if I everybody is saying that I have to keep seperate user for running docker commands, then this becomes quite useless since there is this loophole, right? I guess, gonna look into that rootless way.

  • @mccoysebrell630
    @mccoysebrell630 3 года назад

    You created a docker image of the target's file system and then spunn up a docker file and hopped inside with privileges because why wouldn't docker give the user/owner privilege of a container that's the point.... Great video john learned some docker syntax too 👍🏿

  • @j3r3miasmg
    @j3r3miasmg 4 года назад +1

    This is because docker user/group has the permissions right?

    • @_JohnHammond
      @_JohnHammond  4 года назад +3

      Right -- the issue is that the `mark` user is in the `docker` group so he can run docker commands and build docker images -- and the docker service is running as `root`. Thanks for watching!

    • @DePhoegonIsle
      @DePhoegonIsle 4 года назад

      @@_JohnHammond You wanna know the absurd thing... it would be a non-issue, if docker relied on the user permissions that ran the command rather then it's own (to be clear it should have a set as well, but just not ignoring the user level permissions in regards to the host access of any sort)

  • @jvr8360
    @jvr8360 3 года назад

    cool

  • @densi97
    @densi97 4 года назад

    Nice video! Did you investigate this topic a bit more after I pointed out that adding a user to the docker group can cause harm in your video about dvwa in docker? :D

    • @_JohnHammond
      @_JohnHammond  4 года назад

      Oh, ha, no, those weren't correlated -- I had known this technique for years, I just saw it resurface in a CTF over the weekend. :P
      My personal user has the Docker privileges since, I need that to use Docker, and that account already has sudo permissions. Thanks for watching!

    • @densi97
      @densi97 4 года назад

      @@_JohnHammond Yeah of course you know that, I just wanted to know if that brought up the idea to make a video about it :D

  • @dannydevito8986
    @dannydevito8986 3 года назад

    I'm really new to docker and I don't really understand what John Hammond did exactly in the video. Can comeone please clarify what happened so that someone as dumb as me can understand it.

  • @DePhoegonIsle
    @DePhoegonIsle 4 года назад

    That seems like an extremely short sited failure. I am glad the warnings are out there, but honestly if docker gets to be more used & 'mainstream' for universal programs & games, this flaw alone will compromise security and we'll start to see docker just not allowed on education systems, cooperate systems, and likely advised against for enterprise systems that are leased out.
    Where windows has it's security flaws ( that can be easily locked down by a knowledgeable user/admin ), I can't imagine one person worth their weight to ever suggest leaving a program that would be able to escalate to system level privilege's w/o the admin password/access first & each time the setup has changed.
    There are a few warnings to be had here, but what I don't get is.. if this flaw is inherent within docker structure... how the hell does anyone ever think it'll ever be a suitable program for the masses to run programs in, if all they have to do is what amounts to 1-2min of typing at most to get un fettered access to the system (well beyond what even admin users of windows get without extensive combing through varied security setups )

  • @cocosloan3748
    @cocosloan3748 4 года назад

    Does anyone else see the black dotted vertical line over the mid part of the comments? What is that?

    • @Falfner727
      @Falfner727 4 года назад

      It's called Zalgo text

  • @zeyadkenawi8268
    @zeyadkenawi8268 4 года назад

    whoa

  • @Luftbubblan
    @Luftbubblan 4 года назад

    Nice

    • @_JohnHammond
      @_JohnHammond  4 года назад +1

      Thanks for watching!

    • @Luftbubblan
      @Luftbubblan 4 года назад

      @@_JohnHammond Thank you for interesting videos :)

  • @chaterboxnumberone
    @chaterboxnumberone 4 года назад

    Any way of protecting against this other then not letting untrusted people run docker?

  • @davidjohnhamm
    @davidjohnhamm 4 года назад

    ding that dong

  • @mattfowler6504
    @mattfowler6504 4 года назад +1

    big pp vibes

  • @albertobarbieri8280
    @albertobarbieri8280 3 года назад

    Nice video, thanks. I played that at 0.75 as a beginner to understand everything ahah U are too fast ahah :D
    The only thing I didnt understood is this command :
    docker run -v /:/privesc -it privesc /bin/bash
    Why do we put /:/ before the first "privesc"?
    I mean, which should be the general syntax of this command? Cause I dont understand /:/

    • @chainer22
      @chainer22 3 года назад +2

      the "/:/privsec" is meant for the volume flag "-v".
      "-v /:/privesc" is telling docker to mount the root directory "/" onto the "/privesc" directory when running the container.
      the last part "/bin/bash" is telling docker what command to run in this container, which in this case is shell access into the container
      now with the root directory "/" mounted and shell access into container, the exploit can be carried out

    • @albertobarbieri8280
      @albertobarbieri8280 3 года назад

      @@chainer22 ty :)

  • @desjomp
    @desjomp 4 года назад

    smashed the bell , ! , @rootsh3ll1 :)