Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

CVE-2021-22555: Turning \x00\x00 into 10000$- 561

Andy Nguyen - Google    Reference →Posted 4 Years Ago
  • While looking at old bugs in the Linux kernel, the author of this post decided to simply grep for sketchy looking calls to memcpy or memset. This led the author to a call that had broken logic on the size of the buffer.
  • When IPT_SO_SET_REPLACE is called in compatibility mode and needs to convert the data from 32bit to 64bit in order to be processed by the native functions. Converting data is complicated and tends to be error prone!
  • In the function xt_compat_target_from_user the call to memset is called with an offset that is not accounted for during the allocation. This leads us to an out of bounds write with a few bytes. The size of the overwrite is not directly controllable by the user; but, choosing different structs carefully allows to make the overwrite as big as 0x4C bytes long.
  • The primitive is small though: an out of bounds write with only 4 zeros. In the current structure, we can write up to 0x4C bytes passed the buffer or slightly before. Because of the lack of the control on the bytes being written, we must turn this into another primitive first.
  • Is there anything help we can overwrite? The author mentions reference counters, free list pointers in the heap allocators and a pointer in a struct. In the end, he choose the msg_msg struct to gain a use after free (UAF). This is a good object to spray as well because they are controllable and easy to create.
  • The msg_msg object contains a linked list to the next message in the list at the beginning of the object. The goal of the spraying is to create an insane amount of these messages, overwrite one of the pointer with our vulnerability to point to another one of the messages. Eventually, we will have two pointers pointing to the same message. This is all done by 00ing out a small of the pointer!
  • How do we know which message is the corrupted one though? They tag every message with the index of the message in the queue. If the two tags are different, then we know that the corruption occurred on this chunk.
  • With two pointers pointing to the same message, we can free one of them. Now, we have a use after free on the other object with the forced free that happened. How do we turn this use after free, with controlled values, into something useful?
  • First, we need an information disclosure, such as a heap leak. Using Unix sockets, the author sprayed messages of size 1024 and imitated the struct msg_msg header. By replacing the msg_msg->m_ts value with something large from the socket code, we can leak a substantial amount of information struct with an OOB read.
  • The next pointer in the block above is what we are trying to read. By reading this, we can gather where we are located on the heap. With this heap leak, the double linked list (next and prev from before), can now be re-created. With the pointer fixed, we can free this again when the sk_buff struct is allocated over the top to create a more powerful UAF.
  • The sk_buff buff is better for the uAF because we can use it to free any kind of object in the heap slab. This gives us an even better use after free primitive. They choose the pipe_buffer object because it contains function pointers. A struct within this structure also contains pointers to the .data sections, which is needed for bypassing the code randomization. Reading this is trivial with the current setup.
  • With heap randomization partially broken and the code randomization broken, we can move onto creating a JOP/ROP chain. We overwrite the function pointer within the pipe_buffer object in order to start the chain.
  • The chain calls commit_creds(prepare_kernel_cred(NULL)) to install kernel credentials and switch_task_namespaces(find_task_by_vpid(1), init_nsproxy) to switch namespaces of process 1 to the init process. Now, back in userland, we have root permissions to change process namespaces for Kubernetes.
  • This exploit turns a restricted value write with a limited length into code execution with clever targets and spraying techniques. Wonderful write up!

Aruba in Chains: Chaining Vulnerabilities for Fun and Profit- 560

Aleph Security    Reference →Posted 4 Years Ago
  • Aruba Instant is firmware for routers manufactured by Aruba Networks. The routers running this firmware are mainly bought by the enterprise industry (such as airports, hospitals, universities, conferences).
  • On the WiFi access point page (captive portal), there was functionality for adding a new logo. This functionality was done via a jailed console over SSH/Telnet. The binary takes in a URL, passes it to wget and does a download. Wisely, they sanitized their input from malicious shell characters to prevent command injection.
  • Does a space ( ) seem scary to you? With powerful binaries comes amazing primitives! Because the space had not been added to the filter for the URL, it was possible to escape the URL and pass in arbitrary arguments. Using --post-file=FILE, arbitrary files can be read; using --output-document=FILE let's us write arbitrary files to the server. But, this is only LPE at this point.
  • While trying to exploit the bug above, a patch appeared that fixed the space character. However, we can still use a TAB (\t) to do the same attack in a surprisingly effective way.
  • The next bug allowed for an arbitrary file write to any location via the HTTP server with one restriction: the name ended with .log. While using snprintf with the proper size will prevent buffer overflows, the truncation can be abused to write with an arbitrary file ending! Damn, that is so clever.
  • All of the previous bugs required some form of authentication. How about we change that? The authors found a race condition in one of the binaries responsible for sending PAPI data. PAPI sends a message then awaits for a response. By sending a fake PAPI message prior to the response, it will instruct the service to read from a file that it shouldn't; something like /etc/passwd.
  • At this point, it is gameover with an unauthenticated way to trigger the original set of LPEs. Besides these, the authors found an additional argument injection into wget again. Additionally, they found an XSS bug on the captive portal as well.
  • The steps to exploitation were long and complicated simply because the service is this way! They chained semi-intended features into an amazing set of bugs to own the device. Good work!

Remote code execution in cdnjs of Cloudflare- 559

ryotak    Reference →Posted 4 Years Ago
  • cdnjs is a JavaScript/CSS library CDN that is owned by Cloudflare, which is used by 12.7% of all websites on the internet as of 15 July 2021. So, an extremely popular library. The author of this post was interested in cdnjs/bot-ansible and cdnjs/tools because the library automates the update process.
  • The autoupdate command works by downloading the user-managed Git repository and copying the files from it. When downloading the NPM version of the repository (for updating globally), it downloads a tgz compressed file. With library unzipping, there is the potential for directory traversal (../)!
  • Most CLI programs unpack things securely. However, the library functions to do the same thing in multiple languages are years behind in this. As a result, adding a crafted name would download the repo and extract the files to whenever we wanted on the server. By overwriting a bash script, library or something else, this could be used to get code execution quickly.
  • The above vulnerability was in the npm functionality. When playing around with the git repo functionality, the author of post noticed that symbolic links were NOT being handled. By using the symbolic links, an arbitrary file read primitive could be gained. They used this to read Github automation secrets and many other things on the server.
  • This is a really crazy find! When publishing arbitrary files to Cloudflare, they did not sanitize the input files in properly. If this was exploited, it could have resulted in the compromise of a significant amount of websites on the internet. Symlinks and directory traversal are just attacks that never get old :)

Authentication bypass & Remote code execution in Schneider Electric EVlink Charging Stations- 558

Stefan Viehböck - Sec Consult    Reference →Posted 4 Years Ago
  • EVLink is an electric car charging station provided by Schneider Electric.
  • The first vulnerability is an authentication bypass. When using the admin web interface, there is a hardcoded HTTP cookie value. From reviewing the source code, this indicates that this authentication method is intended for local authentication by the "evse" service on the device. The hardcoded token is b35fcdc1ea1221e6dd126e172a0131c5a with username admin.
  • Once an attacker has bypassed the authentication, they can do lots of things. The device does NOT have a secure update mechanism. By uploading a malicious image, it is trivial to control the device. The reason for the insecure method is that a hardcoded key can be found on the device that is used for the "signing" (hashing) process.
  • Overall, a set of simple bugs that lead to the compromise of the device. A hardcoded password and improper use of cryptography led to the end of this device.

SharePoint Remote Code Execution via Server-Side Control Interpretation Conflict- 557

Zero Day Initiative (ZDI)     Reference →Posted 4 Years Ago
  • According to Microsoft, "empowers teamwork with dynamic and productive team sites for every project team". Regardless, Sharepoint is an important aspect of many companies and access to the material on the server is a big deal.
  • By default, authenticated SharePoint users can create sites/subsites and will have all necessary permissions. In order to prevent malicious things from happening on the server with this permission, the web.config has many different permissions that are dnied for being unsafe and are not allowed.
  • The security issue exists due to an age old problem: inconsistency between verification and processing. In fact, there is only a ONE line difference between the two: text4 = HttpUtility.HtmlDecode(text4);. If the verification step does not match the run time exactly, it may be possible to bypass the security controls.
  • There is parsing done to ensure that only allowlisted tags can be used with the runat="server" is used. However, by HTML encoding this attribute, we can bypass the verification step entirely. This works because the verification does NOT HTML decode but the runtime does.
  • To exploit this vulnerability to the fullest extent is abuse known denylisted functions. For instance, calling System.Web.UI.WebControls.Xml to exfiltrate the machineKey from the web.config.
  • The full exploit exfiltrates the machine key, which allows for the crafting of a bad ViewState. When this gets deserialized by the server, we get easy code execution. A shell has been popped on Sharepoint, but does require SPBasePermissions.ManageLists permission in order to do.

How the Kaseya VSA Zero Day Exploit Worked- 556

Alexander Andersson - TrueSec    Reference →Posted 4 Years Ago
  • Kaseya VSA is a monitoring and management software used by large corporations. As a result, compromising this product leads to complete control over a system. Security flaws used in this product were used for a massive ransomware campaign in the previous weeks.
  • The first vulnerability was an authentication bypass in the application. When logging in users, the default is set to true. So, when not providing a password (but a username), the application sends back true. The username is a long guid though; nobody is sure how the threat actors got a hold of this.
  • CSRF protections were not checked properly. Simply having a string of the proper length and format was enough to pass it off as legit. This was crucial when the attackers were uploading files to the server to execute later. Although there was a type check, the contents of the file were not being validated.
  • The final bug is an arbitrary file execution bug. When processing parsing the contents of a file, it is passed directory to eval in ASP.net for some reason. The idea was to interpret the value of the arguments from the file as literal code.

A brief look at Gitpod, two bugs, and a quick fix - 555

Joern Schneeweisz - Gitlab    Reference →Posted 4 Years Ago
  • Gitpod is a service from Gitlab that allows for spinning up fresh, automated dev environments for each task in the cloud. You can login to Gitpod with your GitLab, GitHub, or Bitbucket account and then use a pretty full-blown, web-based development environment to work on your code, run tests, or even spin up services and expose them from your Gitpod instance to the internet.
  • Gitpod holds an OAuth token with full API access to all of the major Git hosting providers. Because of this, the author decided to take a look at the platform.
  • The product spins up a random workspace name. Once it has booted, all ports of tasks happen from exposed ports to many other things. The web-based IDE uses websockets to communicate with gitpod.io. Using a Cross-Origin WebSocket attack, it is possible to call the API on behalf of the other user. They made the call from another custom domain, which is why it's cross origin instead of cross site.
  • The next attack allowed to login as any account. On Gitpod, a user can add custom integrations. When using a self-hosted Gitlab, it makes sense that you would want to be able to use Gitpod on a self-hosted instance. The author had a big what if moment: " What if I could use a self-hosted instance to log into Gitpod?"
  • In the end, an attacker could set the redirect_uri and client_id values to match those of the self-hosted instance. Because this was technically an OAuth provider, the service blindly accepted the request back. As a result, you can login as any user on the Gitpod.
  • The fix for the previous bug was to validate that the pod user matched the domain of the iDP. This host check can be found at here on Github.
  • Feature rich applications leave room for complicated business logic attacks. Both of these attacks only made sense within the context of the application, requiring a good understanding of the website.

Whose app are you downloading? Link hijacking Binance’s shortlinks through AppsFlyer- 554

Palisade     Reference →Posted 4 Years Ago
  • Several of the Binance shortlinks were being routed through a third-party application called AppsFlyer OneLink. What if these shortlinks could be hijacked? It would send user to bad locations or even download the wrong application entirely.
  • The OneLink platform is used for ads and click analytics. With their platform, you create a subdomain for your site and use it on their domain. The initial attack vector was to simple takeover the subdomain for Binance, such as a subdomain takeover. However, this did not turn up any fruit.
  • What if we could update the link itself? It turns out, that the validation for the links was NOT being done properly. When writing out a longUrl for the link shortener, it only validated the link ID in the URL with a literal string check. If this ID was owned by you, it was fine to edit.
  • With URLs though, we can traverse back with ../ but still have the auth check happen on our ID. This resulted in the ability to change the redirect location of any link on the site! With the ability to change URL shortners, we can do some serious damage.
  • The article was removed from the web (sadly). But, this link has a cached version on the Wayback machine. Once you publish something, it is on the internet whether you like it or not.

UDP Technology IP Camera Vulnerabilities - 553

RandoriSec    Reference →Posted 4 Years Ago
  • UDP Technology provides firmware for a large amount of IP camera vendors, such as Sophus. Going after a product used by many other companies makes the findings significantly more impactful! In the past, there have been many other discovers in this same software.
  • The beginning of the article discusses the reversing process for the device. The first step to reversing the firmware is to open it. The initial usage of binwalk failed. By running an entropy analysis on the files, it was easy to see that the firmware was encrypted.
  • Instead of trying to find the key to decrypt the firmware, they used a previous vulnerability to dump the firmware of a different device. Work smarter not harder!
  • They were hunting for command injection. So, in the webroot, they searched for all files that had popen, system or exec*. This limited the search to 28 files. By going from sink to source, they were able to identify a command injection bug in one of the CGI calls.
  • To find buffer overflow vulnerabilities, they analyzed the decompiled code manually. Unlike the previous vulnerability hunting, there is no shortcut for this. Just checking sources and seeing what can be controlled. From doing this, they found 4 unique buffer overflows.
  • To exploit the buffer overflows (only ASLR is turned on). However, the address of the libraries, such as LibC, was no randomized! By creating a ROP chain and jumping to system, code execution is a fairly standard CTF exercise. Even if the library addresses were randomized, using the PLT code would also work.
  • The authentication was done with HTTP Basic authentication and lighthttpd. The lighthttpd was designed to authenticate for various folder access, such as the CGI files. For instance, there is a list of rules within /uapi-cgi/admin.
  • The different folders under /uapi-cgi/ are all symlinks. Hence, there is a rewriting rule within the lighthttpd configuration that rewrites directories depending actual directory it needs to go to. Depending on the location being accessed, auth may or may not be applied.
  • Because the rewrite rule only checks the path, (not the resolved path), the authentication check can be bypassed with /non-existent/../uapi-cgi/certmngr.cgi. Damn, regexes are hard to do just right!
  • This writeup was a fairly standard IoT device with vulnerabilities everywhere. To me, the most interesting part was the authentication bypass because of the poor logic. The article does not have the best English and took some time to parse what was actually going on.

Old dog, Old tricks - RCE as a Service- 552

Adam - GRIMM    Reference →Posted 4 Years Ago
  • Beagle Software’s ClockWatch product line includes a number of solutions for setting clocks on machines and synchronizing them with high-accuracy time sources such as Global Positioning System (GPS). Old software, that has never been looked at for security, is likely to have some obvious bugs in it.
  • The Beagle Software ESM runs in the background of machines with a listener on TCP port 1001. The simple network protocol used by ClockWatch Enterprise invokes a command on the remote host by sending the string C+ followed by the command to execute. The protocol does not have any authentication or encryption, resulting in any attacker to be able to use it.
  • Because this is command execution as a service, any attacker can hit this and compromise the device. When receiving the commands, ESM passes the command string from the network as an argument to the Visual Basic Shell function executable and any command line arguments. This is equivalent to the Windows API function WinExec and similar to the C runtime library’s system function, since it starts a new child process with the given arguments.
  • This is a horrible design but the team. To be fair, this was created 20+ years ago when no one took cybersecurity seriously. After reporting this vulnerability, the company opted to remove the product from the website instead of trying to fix it. This product may be in use somewhere; so, watch out for this!