Explaining Dirty COW local root exploit - CVE-2016-5195

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

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

  • @LiveOverflow
    @LiveOverflow  8 лет назад +147

    godammit! I didn't fade out the music in the beginning. It's super loud. It will stop a few seconds later. Sorry about that.

    • @samsemp10l23
      @samsemp10l23 8 лет назад +1

      Ok

    • @dennisschagt
      @dennisschagt 8 лет назад +36

      The music is also only playing on the right channel. With headphones that is quite irritating to listen to. Anyway, nice explanation!

    • @TemaSMirnov
      @TemaSMirnov 8 лет назад +1

      Anyway, it even added additional awesomeness for your fast actions in terminal & movie in general :P

    • @David-ie7zn
      @David-ie7zn 8 лет назад +1

      that was a dirty trick....and we love it!

    • @marcinszychowski9131
      @marcinszychowski9131 8 лет назад

      I guess you have to give the credit for the music, or this fine explanation might get DMCA-banned :-(
      Take care!

  • @hrnekbezucha
    @hrnekbezucha 6 лет назад +73

    That's why I like the Linux file system so much. Knowing that _everything is a file_ makes everything so much easier. And consistent. Everything can be treated as text. Thinking back I had to write a driver for my laptop backlight be the default didn't work well. It only meant creating a text file with few parameters like max and current brightness. Pressing backlight keys means updating the file with a new value, that gets pushed to the display. It's such an elegant solution to any hardware. Keyboard, temperature sensor or usb dongle, anything.

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

      What exactly parses the file content and send to the hardware?

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

      ​@@EvilSapphireR ioctls, I would guess.

    • @acters124
      @acters124 10 месяцев назад

      To be everything can be treated as bytes, and those bytes can be easily translated to ascii text. Unfortunately this means that there are unreadable stuff passing through, and you can be confident that all files are within readable ascii text. So theoretically, it is text but I want to stay with the idea that everything is just a pointer and that the files are just pointers to the real device/process.

  • @zachariahbullard
    @zachariahbullard 8 лет назад +41

    It's criminal that more folks have not seen your video of the exploit. Perfect!

  • @punkkap
    @punkkap 6 лет назад +82

    10:05 "...according to the patch author" which just so happens to be Linus Torvalds. I'd trust him on that one.

  • @GlorytoTheMany
    @GlorytoTheMany 8 лет назад +42

    An interesting aspect I noticed about the exploit (I tried cowroot specifically) is that the changes to the file remain only in cache - the changed file doesn't get actually written back to disk, even if I call „sync”. If I then tell the kernel to drop caches („echo 3 > /proc/sys/vm/drop_caches”), I get the original file back.

    • @TheStiepen
      @TheStiepen 6 лет назад +10

      This exploit even works on a file system that has the 'ro' option set, probably because of the cache behaviour.

  • @ochgottnochma
    @ochgottnochma 8 лет назад +171

    > EO"F"

    • @LiveOverflow
      @LiveOverflow  8 лет назад +37

      OH WOW! What a missed opportunity

    • @ochgottnochma
      @ochgottnochma 8 лет назад +10

      IKR :D BTW, I love the intuitive way you make your videos. Could you make a video about the video making process? To show which tools you use and how you use them e.g.

    • @LiveOverflow
      @LiveOverflow  8 лет назад +19

      you are not the first one to ask. Infact I have already started with a video about that :)

    • @phyu
      @phyu 7 лет назад +2

      meta ...

  • @tracimorrison7272
    @tracimorrison7272 7 лет назад +4

    I've been trying to understand the exact nature of this race condition for a class, and your video finally made the "aha" light come on - thank you!!

  • @adityapatil325
    @adityapatil325 8 лет назад +37

    Am I getting this right?
    Normal situation:
    1. You read from file. Page table points to original file
    2. You request write.
    3. copy created
    4. page table points to copy
    5. you write
    6. file isn't saved because it was read-only
    Race condition:
    1. You read from file. Page table points to original file
    2. You request write.
    3. copy being created
    4. You write. ouch.... page table wasn't updated yet. write happened on original file
    5. page table points to copy
    6. copy isn't saved because it was read-only. But anyway we have modified the original file.

    • @LiveOverflow
      @LiveOverflow  8 лет назад +52

      pretty much
      2. you request write
      3. copy being created
      4. before the write is done, madvasie(DONTNEED) in the other thread caused a throwing away of the copy,
      5. memory manager only has the original mapping, thus the write goes there to the original file.

    • @adityapatil325
      @adityapatil325 8 лет назад +3

      LiveOverflow Thanks!

  • @Flare03l
    @Flare03l 8 лет назад +6

    This is beautiful and I learnt a lot! I love the little animations and everything! I look forward to more videos like this :)

  • @AlphaZeroOmega
    @AlphaZeroOmega 8 лет назад +48

    "Mad cow. Am I right?" Lol Subbed.

  • @mpasaa
    @mpasaa 8 лет назад +5

    Excellent overview of this and much appreciated! I am NOT a Linux guru by any means but videos like this are simple to understand versus those useless written articles that assume all of us admins are expert Linux users and automatically know about every single Linux file....some of us actually wear more than one hat and have many more responsibilities than just patching Linux....Windows is bad enough :-) Thanks again and I will share this with colleagues...very interesting exploit...

  • @nqinadlamini
    @nqinadlamini 8 лет назад +1

    Thank you for the explanation. I watched the Computerphile take a month ago and didn't fully understand what was going on. Now I get the COW.

  • @WillowEpp
    @WillowEpp 7 лет назад +1

    Wow, this is incredibly approachable! It's more verbose than I was really (personally) looking for, but I really like how you're thorough enough that almost anyone with a little programming experience can probably follow it. Good show!

  • @hyronharrison8127
    @hyronharrison8127 6 лет назад

    Amazing video! Everytime I watch your videos it gets a little clearer to me. (just a little).It's amazing that this has been widespread for 9 years. Also, I think full disclosure is probably the best. As a security professional, your job isn't to worry about less skilled admins, or hackers. Not to mention, someone could have already discovered this and is waiting to use it. The faster the information is out, the better (just my opinion)

  • @sshlyk
    @sshlyk 8 лет назад +64

    "file" Makes me laugh every time :)

  • @I2obiNtube
    @I2obiNtube 8 лет назад +2

    Thanks for the explanation. Very well produced and explained, subbed!

  • @nicolasrouviere1984
    @nicolasrouviere1984 8 лет назад +1

    Very nice. I like the way you present it, switching from the code to diagram make it clear and didactic. Thank you very much for this video :).

  • @jmiranda18
    @jmiranda18 8 лет назад

    I'm so happy this was posted on Engadget. Been a fan for a while. Hopefully it gets more and more views

  • @FuriousGrizz
    @FuriousGrizz 8 лет назад +3

    Very informative, thanks for breaking it down for us!

  • @PoeticMachineDreams
    @PoeticMachineDreams 8 лет назад

    Excellent video write up! This helped fill me in real quickly on what was up with this exploit while I couldn't get to my machine.

  • @arturtamborski2421
    @arturtamborski2421 8 лет назад +18

    Very cool vid,! Can You make a video series of those walk-trough CVE's? Heartbleed maybe?

    • @LiveOverflow
      @LiveOverflow  8 лет назад +12

      I thought about doing exploit walkthroughs for a while now. The AngularJS series was basically a first experiment of that. Not sure if I will cover heartbleed. But generally I like the concept of making videos about CVEs.

    • @GreenyDe
      @GreenyDe 8 лет назад +2

      If it contains simple PoCs (like no full exploit, only a PoC that shows how to overwrite the EIP for example ...) it would be really awesome.

    • @jaredmeit6127
      @jaredmeit6127 8 лет назад

      LiveOverflow I would LOVE to watch those videos.

  • @Koato
    @Koato 8 лет назад +1

    This was seriously great, please keep it going. The "file" bit cracked me up bad.

  • @expert4urahul
    @expert4urahul 8 лет назад

    Thank you very much for explanation through animation. Very easy & interesting to understand...

  • @Trotskisty
    @Trotskisty 8 лет назад

    What a great explanation. Such clarity.
    You need to make a lot more such videos. Kudos.

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

    Amazing explanation, a thousand thanks !!

  • @logerer5633
    @logerer5633 8 лет назад

    Wow this video brought you over 1500 subs! Your work is just awesome!

  • @clanc789
    @clanc789 8 лет назад

    Recently I have started digging deeper into Reverse Engineering and a friend of mine gave me a link to your channel. I really appriciate your videos. Especially the background information on how and why things work in a certain manner. This is really something unique to your channel and which is something I really really like about your way of working.
    Thanks for all the video's already, and I hope there are many more to come!
    Keep up the great work and enjoy your weekend!

  • @Leprechaun-IT
    @Leprechaun-IT 8 лет назад +4

    Thanks for the explanation :)

  • @wgm-en2gx
    @wgm-en2gx 8 лет назад

    Nice video, well presented and at just the right level of detail. FYI, Engadget embedded your video.

  • @ELYESSS
    @ELYESSS 8 лет назад +13

    You earned yourself a new subscriber

  • @anthonybalaraju7687
    @anthonybalaraju7687 8 лет назад +1

    Thanks for the neat and awesome explanation. So many concepts also you covered in small time.!!
    Can I have couple of clarifications?
    1)It is said in video that: "mmap doesnt copy the file into memory but it maps it to memory", what is the difference between the both?
    2)"if we write to the mmaped file, will this never reflected into underlying file" when is this applicable? If we use these flags PROT_READ,MAP_PRIVATE ? Or in every case we use mmap??
    3) what do we mean physically by "creating a copy"?? Does it mean writing to cache or allocating main memory for it? or.?
    4)" mapping a file is different from reading it through a file descriptor.", any explanation for this statement?
    Thank you

    • @LiveOverflow
      @LiveOverflow  8 лет назад +4

      +anthony balaraju
      1) copy a file into memory means you read the bytes from disk and put them in RAM. And then you work on the data in ram. When you directly map the file into memory, and you write to it, you write directly to the file on disk.
      I think the word "memory" is a problem here. You should not thing of memory as your RAM. But generally anything that could be data. All data can be addressed with a memory address. For example 0x040010.
      A computer program can access this memory address, but where the data for this address is coming from, can be different things. In most cases it's probably something in RAM, but when you mmap a file on disk, you access directly the disk.
      This is all down by the memory management layer in the kernel.
      Maybe swap files are easier to understand. If you run low on memory, the operating system might put some data in a swap file on disk. And when a program wants data, that got stored on disk in a swap file, the program doesn't know about this all. The kernel just handles this for you. It's all magic.
      2) obviously when you map a file with write permissions you could also write to it. If you map it read only you can't write to it. But if it is mapped as private, and you write to it, a copy is created and you can write to the copy of it.
      3) Where this copy is stored I actually don't know, maybe a cache or RAM. I assume it stores it in RAM. But not sure to be honest.
      4) reading a file means, you use the syscall read to read from a filedescriptor, which probably refers to a file you opened before with the open syscall. And when you read from the file you read the bytes somewhere into your programs memory, which is RAM.
      The mmapped file behaves like as if you already put the file content somewhere in memory, because you simply access a certain address, and the Linux memory manager will make sure to deliver you the data from the underlying file.
      Sounds like i should make a video about thi

    • @anthonybalaraju7687
      @anthonybalaraju7687 8 лет назад

      Haha.. Really, it sounds like you can make another 3 min video to explain this .!!
      Never mind, your explanation here is as clear and good as in video ..
      Thank you for that.!! :)
      2)so it means PROT_READ flag is not required!!
      I will ask one more and last question probably,
      What I understood is:
      private_write: 1)update pages (page table), 2)write to newly allocated private page/file
      madvice: throw away allocated/updated private page/file
      I seriously tried hard to understand why the data is directly written to actual page when race occurs!! If madvice discard that page, then still data has to be written to same address. !
      I meant to say actual file and private copy, the addresses assigned will be different! so how could it be written to actual file due to race!!May be I am missed something!!

  • @DaviddeKloet
    @DaviddeKloet 8 лет назад +2

    I just tried this and first I thought it didn't work because the program never stops (and just uses 100% CPU). But it turns out it did work and you can stop the program manually with Ctrl+C.

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

    That was very interesting and cognitive explaination, thank you very much!

  • @Bearz314
    @Bearz314 6 лет назад

    Hi LiveOverflow! Our lecturer just shared your video in class! :)

    • @LiveOverflow
      @LiveOverflow  6 лет назад

      That’s awesome! What school/Uni is that?

  • @DuarteOnTheLine
    @DuarteOnTheLine 7 лет назад

    Awesome review! Looking forward for more videos like these, thanks!

  • @BGroothedde
    @BGroothedde 6 лет назад

    "... because I'm a hypocrite" - haha! Nah, that's just your ethics trying to do the right thing. I also feel information should be open and free, however some times we should take careful steps when you share information. I'm stuck in a loop of watching your videos, they are amazing and well done! Even though I read a lot about these vulnerabilities when they came out, I still value your point of view on them and I can use your videos to help explain these issues to others; thanks!

  • @amandamate9117
    @amandamate9117 8 лет назад +3

    can you make a video just showing strategies for privilege escalation? like "look after files that have root privilege and try to write in them some commands" etc. I mean, just a video about different privilege escalation strategies to look in a linux system, without any help from a framework like metasploit, just raw hacking

  • @dejoneltahan1974
    @dejoneltahan1974 9 месяцев назад

    This exploit is so overpowered yet it was forgotten, this was used in many malware's and server break in's

  • @khizernaeem
    @khizernaeem 8 лет назад

    Very nice explanation. You sir have earned a subscriber. Thank you!

  • @HackhappyOrg
    @HackhappyOrg 8 лет назад

    Great video, thanks for posting.

  • @Deses
    @Deses 8 лет назад +1

    Loved the Dr. Evil drawing.

  • @xXoSmegZoXx
    @xXoSmegZoXx 8 лет назад

    Great video! Keep going!! Your channel is awesome! Off to try it myself!

  • @skipmeister123
    @skipmeister123 8 лет назад

    This is fantastic; thank you for posting this!

  • @andreashammargren751
    @andreashammargren751 8 лет назад

    Great explanation. I'll keep watching these videos if you keep making them :)

  • @MULTIRAGE456
    @MULTIRAGE456 8 лет назад

    Excellent explanation. Thanks!

  • @PaoloForte91
    @PaoloForte91 8 лет назад +5

    I still miss the point in the race condition. How come one manages to bypass the mapped memory and write directly into read-only file? Shouldn't the write always spawn a copy of such a file?

    • @LiveOverflow
      @LiveOverflow  8 лет назад +6

      > Shouldn't the write always spawn a copy of such a file?
      Yes it does. But there is this bug that we exploit, madvise(DONTNEED) will always throw away the page again. So while the write triggers a new copy, if we throw the copy away before we get to write, we write to the original mapped memory.
      edit: the concept of file permissions is enforced by the kernel. And this is a bug in the kernel. The read-only mapped memory causes a copy. But because of the race condition of throwing it away, we perform the write to the original mapped file, thus basically bypassing the read-only property.

    • @PaoloForte91
      @PaoloForte91 8 лет назад +3

      I get your point. Still, it looks a bit odd to me because the Write writes on /proc/self/mem + map (that is where the copy of the file should be mapped in the process memory), not on the actual file.
      I mean, even if you free that page, I would have expected that you write in a meaningless part of the process memory where the file was mapped. Instead, it happens that you write to a file that wasn't even addressed by the file pointer f (which referred to /proc/self/mem ). What am I missing? :\

    • @LiveOverflow
      @LiveOverflow  8 лет назад +10

      > (that is where the copy of the file should be mapped in the process memory), not on the actual file.
      no. this is where the real file is mapped to. As read_only. You directly read from that file. BUT when you write to it, you create a copy. And then the kernel's memory manager updates the page table and points to the copy. And that age table update is what you race.
      There is an alternative version of this exploit where you don't write with /proc/self/mem, but with ptrace(). Maybe that makes more sense to understand.
      So as you probably know, ptrace is used for debugging. So you can attach to a process, you can read memory from it, you can single step through the execution and so forth. Now ptrace also supports writing to the memory, because when you set a "breakpoint" with ptrace, you have to write a 0xCC (int 3) instruction to the code segment (code segment is also not-writeable memory). So in the alternative exploit, you ptrace your own process and write to that not-writeable memory. That feature has to be there for debugging purposes as explained above. BUT obviously you don't want to propagate changes to mapped read-only files. So in this case you trigger a copy-on-write and ptrace writes to this copy.
      Now because of that throwing away (madvise(DONTNEED)), you exploit a race condition, that the memory manager just updated the page table to point to the original file and you write to it before it could create a new copy and update the page table again.

    • @PaoloForte91
      @PaoloForte91 8 лет назад +1

      Great, thanks you a lot!

    • @LiveOverflow
      @LiveOverflow  8 лет назад +5

      The github page also has a trace of the exact functions: github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails#analysis

  • @ibrammarzouk2056
    @ibrammarzouk2056 8 лет назад

    Amazing video, thank you!

  • @hikaru-live
    @hikaru-live 5 лет назад

    I don't think the /proc/self/mem file (or /dev/mem for that matter) is really intended to be written using lseek(2)/write(2) so that part of the code can be just written haphazardly. Most of the time those files are immediately mmap(2)'d after open(2)'d.

  • @AB-mv7nt
    @AB-mv7nt 8 лет назад

    Great explanation! Thanks

  • @jeremysmitherman
    @jeremysmitherman 8 лет назад

    Very good video, thank you.

  • @UtkarshK
    @UtkarshK 8 лет назад

    Amazing! Really helpful for newbie sysads :)!

  • @deyaldor
    @deyaldor 7 лет назад

    Hey LiveOverFlow loved this video! I was trying to walk through this on my own, quick question which kernel version did you use when demonstrating the exploit?

    • @LiveOverflow
      @LiveOverflow  7 лет назад

      +Connor Schwalm unfortunately I don't remember. And I'm stupid for not having done a uname when recording.

    • @deyaldor
      @deyaldor 7 лет назад +4

      Thanks for responding! No worries, I was able to figure it out. For anyone else looking to reproduce this video I was able to follow along by installing linux kernel 4.3.6 generic onto my ubuntu 16.04 LTS VM.

  • @kale.online
    @kale.online 8 лет назад

    The fix was summarized in the commit message: "' "yes,
    we already did a COW" rather than play racy games with FOLL_WRITE"
    They explicitly flag the memory as being worked on for the time it takes to copy that file. The next time the copy is tried, it sees "oh, already tried this" and stops.

  • @MrVecheater
    @MrVecheater 5 лет назад

    So this exploit is simply about the cow creation not being thread safe?
    As it doesn't block thread executing write() before it properly finished so write() works with the old pointer

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

    This video is so good omg

  • @muhammadfaizanammar341
    @muhammadfaizanammar341 8 лет назад

    Perfect explanation....!!!

  • @betabenja
    @betabenja 8 лет назад

    Excellent explanation.

  • @TransRightsMatter
    @TransRightsMatter 7 лет назад

    This is useful for rooting android devices!

  • @hyzektalen
    @hyzektalen 7 лет назад

    Just see this drawing at the Dockercon Austin on Intel expo, they use this picture to demonstrate their clear container technology.

    • @LiveOverflow
      @LiveOverflow  7 лет назад

      My drawing is a copy of the logo here: dirtycow.ninja/
      Does a link to the slides/recording/photo exist?

  • @Occcc12
    @Occcc12 6 лет назад

    Man that "file" joke got real annoying real fast.
    Other than that, excellent explanation and extremely instructional as always

  • @user-xo5dn8fe3h
    @user-xo5dn8fe3h 8 лет назад

    awesome walk through!

  • @ttt1971
    @ttt1971 7 лет назад

    another great video ! thumbs up !

  • @MetroidChild
    @MetroidChild 8 лет назад

    would larger files that need more bandwidth be easier to cause race conditions with? since they easily could take more time than the dumping?

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

    there is an exploit for either the xbox 360 or one of the play station consoles where access to the low level stuff for modding or something can be done by repeatedly rapidly resetting the cpu to exploit the very small window between power on and hypervisor kicking in to inject some code.
    is that an example of a race condition?

  • @julianwieg
    @julianwieg 8 лет назад

    sehr gut! danke!

  • @alvinoo9140
    @alvinoo9140 7 лет назад

    Hi there, i have linux kernel version of 2.6.393 will it be vulnerable to dirty cow vulnerability? the Kernel version is derive from nmap

  • @Jango1989
    @Jango1989 8 лет назад

    Great explanation

  • @YoussefMohamed-er6zy
    @YoussefMohamed-er6zy 7 лет назад

    Hi LiveOverflow!,First thanks about the fantastic video secondly i have couple questions<
    the madvise tells the kernel the map part isnt neded so the kernel must remove the contents of map (even if it's dirty) however what you said is the kernel removes the COWed that the procselfmem was writing to?!!! how would that happen (i dont know about if kernel code removes the map and it's copies if it's advised to remove ! is that the case?
    the second question , processor just do what we say so if i told the processor to calculate 1+1 biion time its not going to be tricked and answer 1 at any of them

  • @businesslifeeditor1121
    @businesslifeeditor1121 5 лет назад

    Hi, I have query about Linux privilege. Escalation, if the code is in .c format, and victim machine not having gcc installed, if I convert .c to executable in my kali machine and run that elf in victim system means will it works?

  • @johnandersen4214
    @johnandersen4214 7 лет назад +1

    docker blocks the ptrace system call in the default seccomp profile. How did you get around this? I am unable to reproduce this with that profile in place. I am having to add --security-opt seccomp=unconfined.

    • @johnandersen4214
      @johnandersen4214 7 лет назад

      +LiveOverflow I created a version that uses /proc/self/mem to get around this and works with any vDSO. I'm still curious about seccomp though? Is that in your docker-compose.yml file?

    • @johnandersen4214
      @johnandersen4214 7 лет назад

      My bad. This has already been addressed here: github.com/scumjr/dirtycow-vdso/issues/4

  • @JustJinxed
    @JustJinxed 8 лет назад +3

    Someone caught me watching this... "Wow, you really are a geek"
    I felt ashamed, up until they broke out laughing at the ending, "But I practice ethical .. because .. I'm a hypocrite"
    Just goes to show, even geeks, don't geek out on everything. Including explanations behind their ethics =D

  • @felixbrumm9699
    @felixbrumm9699 8 лет назад +1

    Jo man, wo hast du das alles gelernt? Hast du Studiert? Ich will unbedingt mal sowas können wie du!

  • @javaij
    @javaij 8 лет назад

    thanks @LiveOverflow..I'm wondering something..I'm using debian 8.5 on a thinkpad e431, with 4gb of ram 128gb ssd; & the last presidential debate, I tried streaming it from youtube, found it sluggish toggling from full screen, & back, after 15minutes into the stream the graphics threw a fit, the screen got a tv static - like appearance, then went to into some color checking mode, I attempted to hard reboot, but got a black screen..After hard rebooting 3-4 times, I successfully got into the desktop, & attempted to stream the debate again, only to repeat the hard reboot(s) after another color checking mode, until I was successfully back into the desktop..I thought it was failing hardware, but checked the updates, I had kernel headers, & kernel updates waiting...After updating I haven't had an issue since;could this have been related to the dirty cow exploit?forgot to mention, I had tcpdump running in bash while streaming, with was a root process..

    • @LiveOverflow
      @LiveOverflow  8 лет назад

      sounds unrelated to this exploit. I still suspect slow hardware failure.

  • @typedeaf
    @typedeaf 5 лет назад

    I am confused about how you said that 'mapping' the file was reading directly from disk. Are you sure? I thought the only difference that MAP_PRIVATE made was that when writes occur, they are not committed to the original file (fd) but instead are made local/private to new pages. What makes you say that the file is read 'directly'? I don't see that in any of the mmap documentation.

    • @LiveOverflow
      @LiveOverflow  5 лет назад

      how is "reading from the real file from disk" in any conflict to "writing is not committed to the original file" ;) it's copy-on-write
      MAP_PRIVATE: Create a private copy-on-write mapping. Updates to the
      mapping are not visible to other processes mapping the same
      file, and are not carried through to the underlying file.

    • @typedeaf
      @typedeaf 5 лет назад

      @@LiveOverflow I'm not saying it's conflicting. I'm asking where it says that it reads straight from disk, without mapping it into memory.

    • @LiveOverflow
      @LiveOverflow  5 лет назад

      ahh.. I think there is a small misunderstanding.
      what do you think "mapping to memory" means? Do you think the kernel performs a memcopy from the HDD into RAM? "The basic idea of memory mapping is to map a byte range of a file to a range of process addresses. [...] mapping is made, but no copying is done. Instead when one or the other process requires the data, a page fault occurs and at that time a single copy is obtained off disk," - www.cs.uleth.ca/~holzmann/C/system/mmap.html

  • @eurobum2012
    @eurobum2012 8 лет назад +1

    What is the the "rare condition". How does the discretionary access control system actually get violated by mmap and the page table? I feel like this "explanation" video left out the punchline.

    • @ELYESSS
      @ELYESSS 8 лет назад +1

      race condition not rare, google it and you'll get the punchline maybe

    • @bdon7825
      @bdon7825 8 лет назад +1

      The discretionary access control is not violated directly; this is not where the vulnerability lies. The file mapped into memory must be readable by the executing process. The exploit works but reading in a suid root file and attempting to trigger a race condition in the kernel that allows you to write to the underlying file and flush the changes to disk before triggering a copy-on-write. This works due to the latency between the moment when a write syscall is requested and when the page table for the current process is updated. So, under certain circumstances the write is executed with a "non-updated" page table while the copy-on-write is being executed. Eventually the page table is updated, but you have already made changes to the underlying file. It's not entirely clear how the changes are flushed to disk, though. The patch just makes sure the copy-on-write operating has completed before allowing the write operation to complete.

    • @eurobum2012
      @eurobum2012 8 лет назад

      So you're saying that by default, the page table points to the original file, which the write syscall then uses?

    • @LiveOverflow
      @LiveOverflow  8 лет назад

      by default the memory mapped memory points to the original file. And when we trigger a write, the memory is copied, and we write to that copy.

  • @sankarsanrauta7062
    @sankarsanrauta7062 6 лет назад

    You are gifted

  • @AXDOOMER
    @AXDOOMER 8 лет назад

    What program do you use to make such great videos like this one on Linux?

    • @LiveOverflow
      @LiveOverflow  8 лет назад

      I actually edit everything on Windows with Sony Vegas and making the graphics by hand with a graphics tablet and photoshop.

    • @sudhakarverma2139
      @sudhakarverma2139 8 лет назад

      Your drawings are very good, such as the cow in this video!

    • @LiveOverflow
      @LiveOverflow  8 лет назад

      I cheat. Have a look at the dirtycow.ninja cow. I simply trace it ;) still work though

    • @sudhakarverma2139
      @sudhakarverma2139 8 лет назад

      LiveOverflow seemed like it. Anyways great videos mate!

  • @anis.lounis
    @anis.lounis 8 лет назад

    Well explained! Keep it up!

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

    madvice() has to modify the translation of the map pointer back to the physical location where the real file is loaded. Is it right?

  • @Honzaik
    @Honzaik 8 лет назад

    great video!

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

    im not a hacker, im a developer and i learnt a lot about Os and intricate details of the system.Thanks for the video.
    However, I would still like to know how this race condition is causing this to happen,..i mean the root cause.

  • @wouter11234
    @wouter11234 7 лет назад

    Some time ago I found a pretty serious exploit in a hosting website (I won't name anything) and told them exactly how I did it and how I would take care of the issue. Only thing I got in response was "We will look into this with our team. By doing this, you ware voilating our ToS. Your account may be banned blablabla" :3

  • @cjdana7119
    @cjdana7119 8 лет назад

    Nice illustration & animations

  • @fightbackmatix
    @fightbackmatix 8 лет назад

    Very niceeee!

  • @AtlasMTBRider
    @AtlasMTBRider 8 лет назад +1

    awesome videos . i'm subscribing :)

  • @neoXXquick
    @neoXXquick 8 лет назад

    Nice explanation..

  • @SurajSharma-og9fm
    @SurajSharma-og9fm 7 лет назад

    why are you writing to /prop/self/mem. correct me if I am wrong , the mem contains the whole process memory. so how only mapped page is affected and why are you not using the returned file descriptor of mmap() to write to the file.

    • @LiveOverflow
      @LiveOverflow  7 лет назад

      1. mmap doesn't return a file descriptor, mmap returns the address where the file was mapped to. So it's some address in the process memory. We don't write there, because we are not allowed to write to that file. But we keep spamming the madvise on that memory area.
      2. we open /proc/self/mem and seek (go to) the address where the file was mmaped to. And then we keep writing to that.

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

    Thanks man! +1

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

    when music on wrong sdie

  • @DMNTXxDsSa
    @DMNTXxDsSa 7 лет назад +1

    you were on the hacker news!!!

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

    The answer to your question could be found at the below link.
    From what I understand it's because it simulates a page fault which only happens if /proc/self/mem was used.
    chao-tic.github.io/blog/2017/05/24/dirty-cow

  • @alma6537
    @alma6537 6 лет назад

    thanks!

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

    Unexpected End Of File:
    File Meme Not Over

  • @sfrias
    @sfrias 8 лет назад

    Good work. :-)

  • @TimeoutMegagameplays
    @TimeoutMegagameplays 6 лет назад

    You should equalize the video music, its only playing in my right side

  • @christose9247
    @christose9247 8 лет назад

    thanks

  • @mouadrevealed9518
    @mouadrevealed9518 8 лет назад

    does this work on s5 at&t marshmallow ?

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

    Which language is used to code dirty cow ??

  • @sankarsanrauta7062
    @sankarsanrauta7062 6 лет назад

    This exploit was used by kingroot in wild to root phone

  • @I2obiNtube
    @I2obiNtube 8 лет назад

    Thing is I can still write to the root file anyway with vim/vi if I just use w! or qw!, I couldn't get it to work on say the sudoers file in Debian 8

    • @sudhakarverma2139
      @sudhakarverma2139 8 лет назад

      thats not how the permissions work on linux. Observe carefully the user who owns the file and what the permissions are for other users.

    • @LiveOverflow
      @LiveOverflow  8 лет назад

      +I2obiNtube that is not true. That would be a huge security issue. Look at the permission of the file. It doesn't belong to root anymore after you w! it. And the reason why you were able to delete and write your user file instead is, because you are probably in your home directory which has your user permission. unix.stackexchange.com/questions/58880/how-does-vim-steal-root-owned-files

    • @I2obiNtube
      @I2obiNtube 8 лет назад

      sudhakar verma LiveOverflow superuser.com/questions/900888/vi-can-write-to-file-despite-file-being-read-only
      Have a weird suspicion it's just this. Tested a few more times with non rw'd directories and it didn't work. Probably missing something (pretty sure my kernel is vuln, but could be wrong).
      try mkdir test, chown root:root, chmod 0404 the directory and a file in there and chown it to root:root

    • @stuartb3502
      @stuartb3502 8 лет назад +1

      Great job on this video. Even with my near zero Linux knowledge, I could follow it enough to be interested and understand at least the key concepts. You put in a lot of work to explain, illustrate and make it entertaining. Much appreciated.