Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • 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 (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. Quickly dove into the copy.fail exploit.

Quickly dove into the copy.fail exploit.

Scheduled Pinned Locked Moved Uncategorized
17 Posts 7 Posters 0 Views
  • 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.
  • q3k@social.hackerspace.plQ This user is from outside of this forum
    q3k@social.hackerspace.plQ This user is from outside of this forum
    q3k@social.hackerspace.pl
    wrote last edited by
    #1

    Quickly dove into the copy.fail exploit.

    1. Yes, it's real.
    2. Current chain can write any arbitrary content to any user-readable file (into the page cache).
    3. Current chain relies on an available target suid binary that you can open() as a lowpriv user.
    4. Current exploit relies on that binary being /bin/su and then being able to execve(/bin/sh, 0, 0) (which doesn't work on alpine, etc.). The former is easily replaced in the code. The latter needs a rebuilt payload ELF (also easy).

    q3k@social.hackerspace.plQ wolf480pl@mstdn.ioW hillu@infosec.exchangeH astraleureka@social.treehouse.systemsA penguin42@mastodon.org.ukP 5 Replies Last reply
    1
    0
    • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

      Quickly dove into the copy.fail exploit.

      1. Yes, it's real.
      2. Current chain can write any arbitrary content to any user-readable file (into the page cache).
      3. Current chain relies on an available target suid binary that you can open() as a lowpriv user.
      4. Current exploit relies on that binary being /bin/su and then being able to execve(/bin/sh, 0, 0) (which doesn't work on alpine, etc.). The former is easily replaced in the code. The latter needs a rebuilt payload ELF (also easy).

      q3k@social.hackerspace.plQ This user is from outside of this forum
      q3k@social.hackerspace.plQ This user is from outside of this forum
      q3k@social.hackerspace.pl
      wrote last edited by
      #2

      5. The authors say they have other chains (including ones that allow container escapes). I believe them.
      6. A mildly de-minified PoC for Alpine with a new payload ELF is at hackerspace[pl]/~q3k/alpine.py . You'll need /bin/ping from iputils. Tested on an ancient Alpine ISO from my cringe^Wdownloads directory.

      shiz@mastodon.socialS q3k@social.hackerspace.plQ 2 Replies Last reply
      0
      • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

        5. The authors say they have other chains (including ones that allow container escapes). I believe them.
        6. A mildly de-minified PoC for Alpine with a new payload ELF is at hackerspace[pl]/~q3k/alpine.py . You'll need /bin/ping from iputils. Tested on an ancient Alpine ISO from my cringe^Wdownloads directory.

        shiz@mastodon.socialS This user is from outside of this forum
        shiz@mastodon.socialS This user is from outside of this forum
        shiz@mastodon.social
        wrote last edited by
        #3

        @q3k ayy I was wondering about the Alpine suid situation, blacklisted the alg module to be sure, nice job

        1 Reply Last reply
        0
        • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

          Quickly dove into the copy.fail exploit.

          1. Yes, it's real.
          2. Current chain can write any arbitrary content to any user-readable file (into the page cache).
          3. Current chain relies on an available target suid binary that you can open() as a lowpriv user.
          4. Current exploit relies on that binary being /bin/su and then being able to execve(/bin/sh, 0, 0) (which doesn't work on alpine, etc.). The former is easily replaced in the code. The latter needs a rebuilt payload ELF (also easy).

          wolf480pl@mstdn.ioW This user is from outside of this forum
          wolf480pl@mstdn.ioW This user is from outside of this forum
          wolf480pl@mstdn.io
          wrote last edited by
          #4

          @q3k would this primitive also work for overwriting code of an already-running privileged process?

          q3k@social.hackerspace.plQ implr@social.hackerspace.plI 2 Replies Last reply
          0
          • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

            5. The authors say they have other chains (including ones that allow container escapes). I believe them.
            6. A mildly de-minified PoC for Alpine with a new payload ELF is at hackerspace[pl]/~q3k/alpine.py . You'll need /bin/ping from iputils. Tested on an ancient Alpine ISO from my cringe^Wdownloads directory.

            q3k@social.hackerspace.plQ This user is from outside of this forum
            q3k@social.hackerspace.plQ This user is from outside of this forum
            q3k@social.hackerspace.pl
            wrote last edited by
            #5

            Oh yeah the above will turn your /bin/ping into a setuid(0) su until you drop caches (maybe) or reboot. So, uh, keep that in mind.

            penguin42@mastodon.org.ukP 1 Reply Last reply
            0
            • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

              Quickly dove into the copy.fail exploit.

              1. Yes, it's real.
              2. Current chain can write any arbitrary content to any user-readable file (into the page cache).
              3. Current chain relies on an available target suid binary that you can open() as a lowpriv user.
              4. Current exploit relies on that binary being /bin/su and then being able to execve(/bin/sh, 0, 0) (which doesn't work on alpine, etc.). The former is easily replaced in the code. The latter needs a rebuilt payload ELF (also easy).

              hillu@infosec.exchangeH This user is from outside of this forum
              hillu@infosec.exchangeH This user is from outside of this forum
              hillu@infosec.exchange
              wrote last edited by
              #6

              @q3k Another route would be to patch a root password hash into /etc/passwd (yes, that still works though shadow passwords have been a thing for decades) and use any login mechanism with that password.

              1 Reply Last reply
              0
              • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

                Oh yeah the above will turn your /bin/ping into a setuid(0) su until you drop caches (maybe) or reboot. So, uh, keep that in mind.

                penguin42@mastodon.org.ukP This user is from outside of this forum
                penguin42@mastodon.org.ukP This user is from outside of this forum
                penguin42@mastodon.org.uk
                wrote last edited by
                #7

                @q3k I don't think you need any suid binary though; I mean, if you can modify an arbitrary file that you're allowed to open, you could change /etc/passwd or libc.

                q3k@social.hackerspace.plQ 1 Reply Last reply
                0
                • penguin42@mastodon.org.ukP penguin42@mastodon.org.uk

                  @q3k I don't think you need any suid binary though; I mean, if you can modify an arbitrary file that you're allowed to open, you could change /etc/passwd or libc.

                  q3k@social.hackerspace.plQ This user is from outside of this forum
                  q3k@social.hackerspace.plQ This user is from outside of this forum
                  q3k@social.hackerspace.pl
                  wrote last edited by
                  #8

                  @penguin42 Right, I'm just talking about the current exploit. I just managed to inject code into an arbitrary process by opening its file, too.

                  1 Reply Last reply
                  0
                  • wolf480pl@mstdn.ioW wolf480pl@mstdn.io

                    @q3k would this primitive also work for overwriting code of an already-running privileged process?

                    q3k@social.hackerspace.plQ This user is from outside of this forum
                    q3k@social.hackerspace.plQ This user is from outside of this forum
                    q3k@social.hackerspace.pl
                    wrote last edited by
                    #9

                    @wolf480pl Yes.

                    1 Reply Last reply
                    0
                    • wolf480pl@mstdn.ioW wolf480pl@mstdn.io

                      @q3k would this primitive also work for overwriting code of an already-running privileged process?

                      implr@social.hackerspace.plI This user is from outside of this forum
                      implr@social.hackerspace.plI This user is from outside of this forum
                      implr@social.hackerspace.pl
                      wrote last edited by
                      #10

                      @wolf480pl @q3k
                      If you managed to get the page swapped out first (with an oom condition or sth), then probably yes, but idk how the page cache interacts with .text mappings to be sure.
                      If that is possible, then there should be plenty of tasty targets in pid1 - systemd is a pretty thicc binary

                      q3k@social.hackerspace.plQ 1 Reply Last reply
                      0
                      • implr@social.hackerspace.plI implr@social.hackerspace.pl

                        @wolf480pl @q3k
                        If you managed to get the page swapped out first (with an oom condition or sth), then probably yes, but idk how the page cache interacts with .text mappings to be sure.
                        If that is possible, then there should be plenty of tasty targets in pid1 - systemd is a pretty thicc binary

                        q3k@social.hackerspace.plQ This user is from outside of this forum
                        q3k@social.hackerspace.plQ This user is from outside of this forum
                        q3k@social.hackerspace.pl
                        wrote last edited by
                        #11

                        @implr @wolf480pl You can just write to any running process' .text if you have access to the binary.

                        You should just be able to write a better implementation of close() into /lib/libc.so.6 - one that also drops you a +s, no questions asked su in /tmp before actually closing the file, and wait until a privileged process bites.

                        wolf480pl@mstdn.ioW 1 Reply Last reply
                        0
                        • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

                          @implr @wolf480pl You can just write to any running process' .text if you have access to the binary.

                          You should just be able to write a better implementation of close() into /lib/libc.so.6 - one that also drops you a +s, no questions asked su in /tmp before actually closing the file, and wait until a privileged process bites.

                          wolf480pl@mstdn.ioW This user is from outside of this forum
                          wolf480pl@mstdn.ioW This user is from outside of this forum
                          wolf480pl@mstdn.io
                          wrote last edited by
                          #12

                          @q3k
                          @implr
                          people have done that with dirtypipe before https://github.com/polygraphene/DirtyPipe-Android/blob/master/TECHNICAL-DETAILS.md

                          1 Reply Last reply
                          0
                          • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

                            Quickly dove into the copy.fail exploit.

                            1. Yes, it's real.
                            2. Current chain can write any arbitrary content to any user-readable file (into the page cache).
                            3. Current chain relies on an available target suid binary that you can open() as a lowpriv user.
                            4. Current exploit relies on that binary being /bin/su and then being able to execve(/bin/sh, 0, 0) (which doesn't work on alpine, etc.). The former is easily replaced in the code. The latter needs a rebuilt payload ELF (also easy).

                            astraleureka@social.treehouse.systemsA This user is from outside of this forum
                            astraleureka@social.treehouse.systemsA This user is from outside of this forum
                            astraleureka@social.treehouse.systems
                            wrote last edited by
                            #13

                            @q3k working around the broken execve is trivial enough like you said; https://social.treehouse.systems/@astraleureka/116490148181953204
                            it's pretty amusing seeing the trodden pagecache results persist afterwards

                            1 Reply Last reply
                            0
                            • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

                              Quickly dove into the copy.fail exploit.

                              1. Yes, it's real.
                              2. Current chain can write any arbitrary content to any user-readable file (into the page cache).
                              3. Current chain relies on an available target suid binary that you can open() as a lowpriv user.
                              4. Current exploit relies on that binary being /bin/su and then being able to execve(/bin/sh, 0, 0) (which doesn't work on alpine, etc.). The former is easily replaced in the code. The latter needs a rebuilt payload ELF (also easy).

                              penguin42@mastodon.org.ukP This user is from outside of this forum
                              penguin42@mastodon.org.ukP This user is from outside of this forum
                              penguin42@mastodon.org.uk
                              wrote last edited by
                              #14

                              @q3k So I guess you can disable it by a seccomp or bpf that blocks hmm, socket(2) with AF_ALG ?

                              q3k@social.hackerspace.plQ 1 Reply Last reply
                              0
                              • penguin42@mastodon.org.ukP penguin42@mastodon.org.uk

                                @q3k So I guess you can disable it by a seccomp or bpf that blocks hmm, socket(2) with AF_ALG ?

                                q3k@social.hackerspace.plQ This user is from outside of this forum
                                q3k@social.hackerspace.plQ This user is from outside of this forum
                                q3k@social.hackerspace.pl
                                wrote last edited by
                                #15

                                @penguin42 Yeah, or just yeet the vulnerable module (`algif_aead`).

                                penguin42@mastodon.org.ukP 1 Reply Last reply
                                0
                                • q3k@social.hackerspace.plQ q3k@social.hackerspace.pl

                                  @penguin42 Yeah, or just yeet the vulnerable module (`algif_aead`).

                                  penguin42@mastodon.org.ukP This user is from outside of this forum
                                  penguin42@mastodon.org.ukP This user is from outside of this forum
                                  penguin42@mastodon.org.uk
                                  wrote last edited by
                                  #16

                                  @q3k ..if your distro hasn't built that in.

                                  1 Reply Last reply
                                  0
                                  • q3k@social.hackerspace.plQ This user is from outside of this forum
                                    q3k@social.hackerspace.plQ This user is from outside of this forum
                                    q3k@social.hackerspace.pl
                                    wrote last edited by
                                    #17

                                    @kasperd @penguin42 While I am a security consultant I am not _your_ security consultant, so the best I can offer you is an enthusiastic 'yeah, I guess so!'.

                                    1 Reply Last reply
                                    0
                                    • R relay@relay.mycrowd.ca shared this topic
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups