CrushFTP Server-Side Template Injection (SSTI)

Overview

SonicWall Capture Labs threat research team became aware of a fully unauthenticated server-side template injection vulnerability within CrushFTP, assessed its impact, and developed mitigation measures. CrushFTP is an enterprise file transfer tool. Such tools have seen increased attention from attackers over the last several years. This vulnerability, CVE-2024-4040, has a CVSS score of 10.0 and has been reported to be exploited in the wild by CISA.  A PoC and vulnerability scanner script has been released on GitHub, making it relatively easy for attackers to leverage. Shodan indicates around 5,200 instances of exposure on the internet at the time of writing. CrushFTP has released an update to fix this vulnerability and anyone using this software should update to version 11.1 or newer.

Technical Overview

CrushFTP is designed to provide an anonymous or unprivileged session token for any unauthenticated request to any page with a “/WebInterface” prefix. This session token can then be used to access other API endpoints. The vulnerability exists due to an accessible endpoint – ServerSessionAJAX – that allows these tokens to access its API features. The ServerSessionAJAX API functions as a server-side templating engine by performing variable replacements. This API is susceptible to a server-side template injection vulnerability within the writeResponse function. If an attacker manages to insert data enclosed within %% or {} symbols in the argument, the server will execute and render the attacker-specified template. This results in arbitrary file read as root, authentication bypass for administrator account access, and can lead to theft of all files stored on the instance. To perform our analysis, we installed CrushFTP version 10.6 using a docker container hosted on docker hub.

Triggering the Vulnerability

In order to leverage and trigger this vulnerability, an attacker must first obtain an unprivileged session token by sending a basic GET request to any endpoint in “/WebInterface,” as seen in Figure 1.

Figure 1: Obtaining a session token

Using a session token, the attacker can attempt to access resources that should only be accessed by a fully authenticated account, such as an API implemented by ServerSessionAJAX. In Figure 2, we are trying to access an API feature we shouldn’t have permission to access — the zip function. Upon trying to access, an error appears instead of the expected “access denied” message.

Figure 2: Indication of unauthenticated access to API

Through this unauthenticated API, we can send legitimate template commands to obtain information about the server, which will be returned in the response. The code allows an extensive list of legitimate commands to be sent into the request. Figure 3 shows a small subset of the list from the code, including one that returns the working directory of where the application is running, which is crucial for exploitation.

Figure 3: change_vars_to_values_static function

Attempting to access this command via an unauthenticated request, as seen in Figure 4, proves an attacker can effectively leverage the SSTI. Notice that the working directory is returned in the server’s response when the “working_dir” template is provided.

Figure 4: Successful template injection

Exploitation

To exploit this vulnerability, an attacker can use this access to obtain an administrator login or session token. By examining the possible templates that can be leveraged within the “change_vars_to_values” function, we run across “INCLUDE” tags among many others, as seen in Figure 5.

Figure 5: Injectable Tags

As demonstrated in Figure 4, it is easy to obtain the working directory of the application. Within the application’s main directory, a file named sessions.obj contains all of the session data for the instance, including session tokens.  If an administrator is logged into the application, their token will be in this file. An attacker can exploit the SSTI vulnerability using <INCLUDE>, as seen in Figure 6, to have the file’s contents returned in the response.

Figure 6: SSTI using <INCLUDE>

Within the response, it is easy to locate a list of assigned session tokens. In Figure 7, the administrator token is highlighted in yellow. While an attacker may not know which token is dedicated to the administrator, trial and error will eventually allow them to utilize the correct token.

Figure 7: Output of SSTI including the sessions.obj file

SonicWall Protections

To ensure SonicWall customers are prepared for any exploitation that may occur due to this vulnerability, the following signatures have been released:

  • IPS:4396 CrushFTP Server-Side Template Injection
  • IPS:4400 CrushFTP Server-Side Template Injection 2
  • IPS:4402 CrushFTP Server-Side Template Injection 3

Remediation Recommendations

CrushFTP has released an update to fix this vulnerability, and anyone using this software is advised to update to version 11.1 or newer.

Relevant Links

 

Fake Windows Explorer Installs a Crypto Miner

Overview

This week the SonicWall Capture Labs threat research team came across a sample purporting to be Windows Explorer. At a glance, everything checks out – it uses the legitimate Windows Explorer icon and the file properties say Microsoft – but, once executed, it installs and runs a crypto miner.

Infection Cycle

The sample arrives as a Windows executable file using the following icon and bearing these file properties:

Figure 1: Malware installer’s file properties showing Windows Explorer from Microsoft

Upon execution, it drops malicious files in the /Windows/Fonts/ directory, including the main crypto miner file, a batch file containing malicious commands to start the mining process, and two registry files whose registry subkeys and values will later be inserted into the system registry using regedit.exe.

  • svchost.exe
  • 1.bat
  • server.reg
  • restart.reg

It then spawns the Windows command interpreter to execute the batch file.

Figure 2: Cmd is used to run 1.bat

Simultaneoulsy, it also runs the attrib command to set attributes of the entire %fonts% directory as a read-only (+r) and archive (+a).

Figure 3: The malicious Explorer.exe will run the attrib command to change attributes of the Fonts directory

Meanwhile, the 1.bat file contains the following commands:

Figure 3A: Commands

The command installs and runs a crypto miner using the specified mining pool address, port and xmr wallet. It then installs the contents of the two .reg files using regedit.exe. Next, it deletes these registry files and proceeds to change the attributes of several component files.

Figures 4 and 5 show the contents of the reg files which were imported into the system registry.

Figure 4: Contents of server.reg

Figure 5: Contents of restart.reg

Our static analysis revealed another mining configuration that uses a different mining pool address, port and xmr wallet which we did not observe being used during runtime.

Figure 6: Alternate mining pool address and xmr wallet that may be used by this malware

SonicWall Protections

SonicWall Capture Labs provides protection against this threat via the following signature:

  • GAV: Miner.XMR_1 (Trojan)

This threat is also detected by SonicWall Capture ATP w/RTDMI and Capture Client endpoint solutions.

Vintage Bugs: Data Shows Old Vulnerabilities Still Menace Small Businesses

When you hear phrases like “increasingly sophisticated cyber threats” or “the ever-evolving cyber threat landscape”, it’s easy to glean from that that the most pressing, dangerous threats must be unknown threats. And for many, this may be true. Unknown threats are dangerous because they’re new. We haven’t had years to study these threats, the way they’re used or the best defenses to combat them. But what if I told you that – for small businesses at least – the most likely attacks used against them are several years old or older?

That’s what our recent review of our telemetry data suggests. It appears that the most widely used network vulnerabilities on small- to medium-sized businesses (SMBs) are taking advantage of older vulnerabilities that have a large amount of publicly available information and primarily affect major vendors.

The Data

We looked at our IPS data from between January 2022 and March 2024 to find the top five most widespread network attacks used against SMBs, which you can see below.

Figure 1: Top 5 most widespread network attacks

When you take a deeper look, you can see that the “newest” vulnerability among these five is nearly three years old, with the oldest being ten years old, which is ancient in the modern cyber threat landscape.

What Does This Mean?

With the top five threats to SMBs ranging from three to ten years old, this means CISOs and other organizational cybersecurity leaders need to ensure that they’re assessing threats based on a healthy understanding of the risk landscape as it pertains to their own organizations. The buzz in cybersecurity is typically focused on new, scary threats, whether those be zero-day threats or AI-based threats, and those are concerning and need to be taken seriously. But this IPS data shows that SMBs need to also maintain focus on threats that we’ve seen before and have been seeing for years. It still pays dividends to spend time and resources protecting yourself from threats like Heartbleed and Log4j. For many SMBs, focusing on protecting your organization from those threats may be more valuable than worrying about the latest zero-day or AI threats.

Why Is This the Trend?

If patches exist for these older threats, it begs the question, why is this the trend? Like most humans, attackers are more likely to take the easiest path to obtain their end goal. This means that they’ll often test older attacks just to see if they work. And if it does, well, there you have it. Another factor to consider is that the longer a vulnerability has been around, the more time and research threat actors can put into perfecting these techniques. This means that, despite their age and available patches, they may still be more reliable attack methods than many newer threats. And, for smaller businesses especially, patching can be a struggle. In highly regulated industries like healthcare, finance and OT, what may be a simple patch for others could result in mission-critical systems becoming unusable or even require the purchase of a new device altogether. And that’s on top of other challenges SMBs face such as having the personnel in place to patch effectively to begin with.

What Can You Do?

The identification of a problem is key, but a solution is better.  Like many issues in cybersecurity, there isn’t one easy solution; however, we can take several steps to improve, starting with not ignoring what the data is indicating.  Notice two of the five identified vulnerabilities (Log4j and Heartbleed) are underlying library issues, in other words, part of the supply chain. What makes these so effective for attackers is that there are likely many places where a small business has no idea that they’re using these libraries. The hardest step is identification. Product security testing is a fantastic methodology and concept to help reduce this problem. By doing deep technical testing of the products you are or plan to use in your networks, you can seek out and possibly prevent these types of older underlying supply chain issues.

As resources are often the second largest issue which can lead to less effective patching, MSPs are a key difference maker in helping to elevate these issues for small businesses.  An MSP partner can remove the need to hire and train new employees and purchase expensive tools.  Many times, MSPs can very quickly set up automated patching in your environment and even perform product security testing where needed.

Prioritization Is Key

What this  boils down to is that leadership needs to properly prioritize threats and resources based on threat intelligence for their industry. You must understand the attacks, vulnerabilities and tactics that your enemies are using to exploit your organization and organizations like yours. You must also have a deep understanding of your own organization’s risk landscape to determine where attacks are most likely to come from. While some circumstances require the acceptance of risk, this should be used sparingly and only when a deep understanding of the risk to your organization is understood. Relying too heavily on industry best practices or any isolated factor could lead to an incomplete view of the risks associated with any vulnerability.

In order to stay ahead of nefarious actors in an increasingly dangerous world, you must focus on prioritization, and, to prioritize correctly, you have to know the biggest threats to you.

Android Remote Access Trojan Equipped to Harvest Credentials

Overview

The SonicWall Capture Labs threat research team has been regularly sharing information about malware targeting Android devices. We’ve encountered similar RAT samples before, but this one includes extra commands and phishing attacks designed to harvest credentials.

This malware uses famous Android app icons to mislead users and trick victims into installing the malicious app on their devices. This malicious app uses any of the following icons:

 

Figure 1: The app icon used by the malware.

Figure 2: Installed malicious app

Infection Cycle

After the malicious app is installed on the victim’s device, it prompts the victim to enable two permissions:

  • Accessibility Service
  • Device Admin Permission

By requesting these permissions, the malicious app aims to gain control over the victim’s device, potentially allowing it to carry out harmful actions or steal sensitive information without the user’s awareness or consent.

Figure 3: Prompt for accessibility permission

Figure 4: Device admin activation

The malicious app establishes a connection with the Command-and-Control server to receive instructions and execute specific tasks accordingly.

Here are some of the commands received from the malware’s Command-and-Control (C&C) server:

Command Description
dmpsms Read Messages
dmpcall Read Call logs
dmpcon Device Contact list
getpackages Installed package name
changewall Change device wallpaper
toasttext Notification data
opweb Open URLs on web browser for phishing
vibratedev Vibrate device
sendsms Send messages
tont Turn on the camera flashlight
tofft Turn off the camera flashlight

 

The resource file contains the URL of the C&C server, but it was not active during the analysis.

Figure 5: C&C server

Here you see it receiving commands from the C&C server to access a specific URL in the browser to harvest credentials.

Figure 6: Browser to open specific URL

Some malicious HTML files related to well-known Android applications are in the ‘asset\website’ folder, as shown in the figure below:

Figure 7: Fraudulent HTML Pages

Figure 8: Instances of fraudulent HTML page -1.

Figure 9: Instances of fraudulent HTML page -2.

In these HTML files, the attacker prompts the victim to enter their user ID and password into the input fields.

Figure 10: Retrieves user input

After taking credentials using JavaScript, it collects and shares all the user information to the ‘showTt’ function.

Figure 11: Collect user credential

It retrieves all phone numbers stored on the victim’s device.

Figure 12: Fetching contact List

It attempts to change the device’s wallpaper to a specific resource if the ‘str’ parameter matches the decrypted value, such as 0, 1, or 2.

Figure 13: Changing the Device Wallpaper

It retrieves information about installed apps on the victim’s device.

Figure 14: Collecting installed package info

The below code snippet utilizes the “CameraManager” to toggle the flashlight of the victim’s device’s camera to either on or off.

Figure 15: Camera flashlight on-off

It sends a message to a number based on input received from the C&C server.

Figure 16: Sending a message from the victim’s device

We also noticed that certain malicious files have been recently uploaded to malware-sharing platforms like VirusTotal.

Figure 17: Latest sample found on VT

SonicWall Protections

SonicWall Capture Labs provides protection against this threat via SonicWall Capture ATP w/RTDMI.

Indicators of Compromise (IOCs)

0cc5cf33350853cdd219d56902e5b97eb699c975a40d24e0e211a1015948a13d

37074eb92d3cfe4e2c51f1b96a6adf33ed6093e4caa34aa2fa1b9affe288a509

3df7c8074b6b1ab35db387b5cb9ea9c6fc2f23667d1a191787aabfbf2fb23173

6eb33f00d5e626bfd54889558c6d031c6cac8f180d3b0e39fbfa2c501b65f564

9b366eeeffd6c9b726299bc3cf96b2e673572971555719be9b9e4dcaad895162

a28e99cb8e79d4c2d19ccfda338d43f74bd1daa214f5add54c298b2bcfaac9c3

d09f2df6dc6f27a9df6e0e0995b91a5189622b1e53992474b2791bbd679f6987

d8413287ac20dabcf38bc2b5ecd65a37584d8066a364eede77c715ec63b7e0f1

ecf941c1cc85ee576f0d4ef761135d3e924dec67bc3f0051a43015924c53bfbb

f10072b712d1eed0f7e2290b47d39212918f3e1fd4deef00bf42ea3fe9809c41

Why Multi-Factor Authentication (MFA) Is Not Enough

One of the scariest things about supply-chain attacks is how little control you have. Even if you’ve done everything right, security-wise, you have no good way of knowing that every single one of your trusted vendors has—as countless Cisco Duo customers recently learned.

In early April, Cisco Duo’s security team disclosed an attack on their telephony provider, which resulted in hackers stealing customer VoIP and SMS logs used in multifactor authentication (MFA) messages.

Such attacks aren’t new: Last year, the U.S. FBI warned that threat actors were increasingly leveraging SMS phishing and voice calls in social engineering attacks on corporate networks. But they’re becoming more frequent, due to being a highly successful avenue of attack. They can, however, be stopped—with a little help from SonicWall’s recent acquisition, Banyan Security.

MFA: May Fail Alone

Before we look at how Banyan can enhance MFA and prevent this type of attack, it’s helpful to understand how we got here. The earliest form of user security, consisting of a username and password, wasn’t very secure at all: Many people retained the manufacturers’ default credentials, some kept their login info on a Post-It stuck to their monitor, while many others chose a password and used it for everything from their corporate email to their child’s school portal to the website selling socks with their pet’s face on them.

MFA and one-time passwords corrected a lot of the resulting issues, but they weren’t fail-proof, either. What’s more, identity systems such as Microsoft Active Directory or token-based systems from RSA, Google Authenticator and others used to sit behind a firewall and VPN, but have now evolved into SaaS solutions.

As incredible as it may seem—particularly since so many sites and apps still use basic username and password logins—the days of using an authentication strategy built on something you have, something you know and an inherence factor are likely behind us. MFA phishing attacks are now the norm, and standard Identity and Access Management (IAM) practices are no longer sufficient to protect access and authorization to mission-critical resources. MFA can be better.

How Cloud Secure Edge enhances MFA

So if MFA alone is no longer enough, what is? Simply stated, factoring user and device identity and trust into the equation could have prevented the attacks.

Banyan’s ZTNA solution integrates with solutions from leading MFA vendors. These offerings can be configured to use certificate-based authentication, also known as “cert-auth.” These intelligent certificates tie the device to the user: Without them, no access will even be considered. Once the user is identified, the device identity and posture assessment process is completed, and a TrustScore (which quantifies the level of trust to attribute to accessing principals) is generated. User identity, including MFA, or device identity and trust alone are never enough to get access.

To summarize, before any access is granted, the following must be true:

  • Banyan must trust the specific MFA vendor
  • Banyan must deploy the Banyan app to a very specific end-user device
  • Banyan must authenticate the user and ensure that they can enroll their specific end-user device
  • Banyan must generate an intelligent certificate for that specific user and specific device
  • Banyan must check the identity and authorization level of the user
  • Banyan must, in a timely matter, validate a component of the user identity with the MFA vendor
  • Banyan must check the identity and authorization level of the device
  • Banyan must check the posture level of the device
  • Banyan must check the configured risk tolerance of the resource

This is a secure, defense-in-depth, multi-step process — if any step is skipped, no access is granted! Luckily for end users, most of this magic happens behind the scenes, so they aren’t jumping through hoops just to get secure access.

But what if an attacker has credentials and has phished MFA? Can they enroll a new device and gain access? With Banyan’s ZTNA solution, new device enrollment can be blocked by rotating invite codes, or the process can be completely disabled by leveraging Unified Endpoint Management (UEM) to push out the Banyan app along with the intelligent certificate.

Banyan’s granular ZTNA policies also ensure that applications can only be accessed by devices with a known and specific identity and posture. Unknown or unauthorized devices are banned from even attempting enrollment and access.

No one knows when the next supply-chain attack will occur—but with the right tools in place, you can know you’ll be ready when it does. SonicWall’s Banyan technology is a flexible, cloud-native and easy-to-use solution designed to fill in the gaps left by MFA-based security. To find out how Banyan can be quickly deployed to provide device-centric threat protection to your network, book a demo here.

GitLab XSS Via Autocomplete Results

Overview

The SonicWall Capture Labs threat research team became aware of a cross-site scripting vulnerability in GitLab, assessed its impact and developed mitigation measures. GitLab, an open-source code-sharing platform, published an advisory on this vulnerability affecting GitLab CE/EE in all versions starting from 16.7 to 16.8.6, 16.9 before 16.9.4 and 16.10 before 16.10.2. Identified as CVE-2024-2279, it allows remote threat actors to perform arbitrary actions on behalf of victims, earning a high CVSS score of 8.7. To mitigate this threat, GitLab users are strongly encouraged to upgrade their instances to the latest versions, as mentioned in the vendor advisory.

Technical Overview

This vulnerability arises due to a flaw in the input validation mechanism while displaying suggestions to the user using the feature called ‘autocomplete for issues reference’ in the rich text editor. Autocomplete characters are a handy way for users to enter field values into markdown fields swiftly. While creating and displaying an issue enforces the escape of the special characters, the same is missing when the user types the character “#” and the backend engine tries to autocomplete from the list of issues.

This enables an attacker with access to ‘issues’ in the project to create an ‘issue’ using a crafted payload in the title field, leading to stored cross-site scripting. The exploit payload triggers when a victim is trying to mention any issue in the textbox using the autocomplete character #, which leads to an automatic execution of arbitrary action specified in the payload. This could include actions such as requesting a resource from the attacker-controlled server.

An escape method from the Lodash library is used to address this vulnerability, as seen in the related diff between version 16.10.1 and 16.10.2 in Figure 1. This method replaces special characters like &, <, >, “, and ‘ with their corresponding HTML entities before adding them to the Document Object Model (DOM).

Figure 1: Utilization of the escape method to resolve the issue

Triggering the Vulnerability

Leveraging this XSS vulnerability requires the attacker to meet the prerequisites below.

  • The attacker must have network access to the target vulnerable system along with the rights to create the ‘issue’.
  • The attacker must create an issue with a malformed payload. For instance, Malicious issue <img src=”http[:]//<attacker_controlled_server>/x.svg”>. This payload will load images from the server if the vulnerability is present.
  • The victim must try to mention any issue using the autocomplete character #.

Exploitation

While the steps to trigger the vulnerability are straightforward, it can test the attacker’s patience since the exploitation requires the victim to try to mention any issue using the rich text editor, to be specific.

To begin with, the issue needs to be created with the crafted payload as seen in Figure 2. The attacker needs to host the x.svg image file at the server specified in the payload.

Figure 2: Malicious issue creation

The created issue will be listed as shown in Figure 3.

Figure 3: Issues list

When a user tries to refer to any issue by typing # in the rich text box, for instance, in the comment box of any other issue, the payload will be triggered. The exploitation can be verified by checking the access logs of the web server, where the access request on behalf of the victim can be seen, as shown in Figure 4.

Figure 4: Triggering XSS

SonicWall Protections

To ensure SonicWall customers are prepared for any exploitation that may occur due to this vulnerability, the following signatures have been released:

  • IPS: 4383 GitLab Autocomplete Results XSS
  • IPS: 4385 GitLab Autocomplete Results XSS 2

Remediation Recommendations

GitLab users are strongly encouraged to upgrade their instances to the latest versions as mentioned in the vendor advisory.

Relevant Links

SonicWall at RSAC 2024: The Art of the Platform

The RSA Conference is the epicenter where the industry’s brightest minds gather, foster enlightening discussions, and unveil groundbreaking solutions to elevate your organization.

During this year’s conference, which runs from May 6-9, we’ll be at Booth 5353 in the Moscone Center North Hall — where we’ll unveil our latest developments that showcase our commitment to serving our partner community through greater integration and interoperability.

RSAC’s Theme Meets SonicWall’s Strategy

This year’s theme, “The Art of Possible,” is about going beyond ones and zeros. More than ever, it’s about harnessing the power of collective strength, embracing the power of community, and driving towards making “the impossible seem more possible.” SonicWall also understands that to remain resilient and anticipate future challenges requires combining the wisdom of our instincts with the power of collaborative expertise and shared experiences. That’s why we recently enhanced our portfolio with the acquisition of managed services and secure service edge offerings.

These offerings are pivotal in SonicWall’s cybersecurity platform approach, which will integrate our suite of solutions — including network, endpoint, wireless, cloud email and threat intelligence — under a single, multi-tenant portal. These advancements offer our partners and our customers the latest technology in a hybrid, remote world.

Greater Simplicity. Enhanced Flexibility. A Wave of Momentum.

Platformization in cybersecurity refers to the shift towards integrating various cybersecurity tools and technologies into a unified platform, rather than relying on a disjointed collection of individual solutions.

SonicPlatform is an innovative cybersecurity platform designed specifically for our Managed Service Providers (MSPs) and Managed Security Service Providers (MSSPs). It unifies all SonicWall products under a singular, integrated interface, and represents a significant stride toward a more integrated, efficient, and secure management ecosystem for SonicWall’s diverse product suite. It not only streamlines management tasks; it also fosters deep integration, enabling the sharing of contextual information across all enforcement points within the product family and with third-party vendors.

SonicPlatform incorporates several key features, including:

  • Unified Console: A single, intuitive interface for managing all clients and their resources.
  • Unified System Health Visibility: Comprehensive insights into the health and performance of clients’ products – including maintenance needs.
  • Enhanced Security Management: Advanced capabilities for detecting and mitigating threats.
  • Expanded Inventory Management: Efficient management of clients’ resources, including appliances, subscriptions, and licenses, across on-premises and cloud environments.

MSPs (Managed Service Providers) and MSSPs (Managed Security Service Providers) in particular will benefit from the advancements built into SonicPlatform: This comprehensive approach allows organizations to develop a more robust and effective cybersecurity posture in the face of evolving cyber threats by addressing several critical challenges in cybersecurity management. It’s designed to streamline processes, enhance visibility and control, improve threat detection and response, reduce costs, ensure compliance, facilitate integration and scalability, and mitigate the impact of skill gaps.

Underpinning its business momentum is the momentum SonicWall is seeing across its valued partner community. SonicWall’s ongoing commitment to provide meaningful initiatives to its partners is paying dividends in the form of key wins for our partners.

Visit with SonicWall’s Executive team and Product Experts

At the conference, we’ll demonstrate the latest SonicWall technology and answer questions about recent acquisitions, SonicPlatform and more:

SonicWall | Booth 5353, North Hall | Moscone Center

  • Tues., May 7: 10 a.m. – 6 p.m. PT
  • Wed., May 8: 10 a.m. – 6 p.m. PT
  • Thurs., May 9: 10 a.m. – 2 p.m. PT

We also encourage you to join us for three special sessions.

  • “SonicWall: Listening and Taking Action – Empowering MSPs”
    Wednesday, May 8 at 4 PM
    Businesses now require the flexibility of internal IT teams and the expertise of managed services. The answer lies in co-managed IT, which brings both worlds together in a unified platform. SonicWall’s Chandro Prasad, Michael Crean and Tarun Desikan will tackle trends in SMBs, including adoption of hybrid/cloud strategy via service providers and acquisitions that bring Managed Detection and Response and Security Service Edge to MSPs.
  • What Hacking the Planet Taught Us About Defending Against Supply-Chain Attacks
    Monday, May 6 at 1:10 PM
    SonicWall Executive Director of Threat Research and SANS Instructor Douglas McKee will be joining SANS Senior Instructor Ismael Valenzuela to discuss how “hacking the planet” has provided key insight into how to defend against supply chain attacks. They will present a repeatable methodology and process to help protect your organization from this rapidly growing threat.

Douglas will also be on hand in the SonicWall Booth—stop by to catch “Prioritizing Protection: Navigating Cyber Risks with Data” and get the answers to all your questions about cyberthreat trends and the latest SonicWall technology.

As always, RSA 2024 will offer countless opportunities for learning, reconnecting, and reenergizing, and we’d love to see you there! For more information, or to request a one-on-one meeting with a SonicWall cybersecurity expert, visit SonicWall.com/RSA.

Analysis of Native Process CLR Hosting Used by AgentTesla

Overview

SonicWall Capture Labs threat research team has observed fileless .Net managed code injection in a native 64-bit process.  Native code or unmanaged code refers to low-level compiled code such as C/C++.  Managed code refers to code that is written to target .NET and will not work without the CLR (Microsoft .NET engine) runtime libraries. The injected code belongs to AgentTesla malware.

Technical Analysis

The initial infection vector is a Word document that the client received as an email attachment. Upon opening this document, it will ask the user to enable a VBA macro. If enabled, this VBA macro downloads a 64-bit executable from the internet and executes it.

The downloaded binary is a 64-bit, Rust-compiled binary. We are focusing on the techniques used by this binary to inject the malicious AgentTesla payload into its own process memory using CLR Hosting.

The following are details of the 64-bit downloaded executable file.

MD5 : 4521162D45EFC83FA76C4B5C0D405265

SHA256 :  F00ED06A1D402ECF760EC92F3280EF6C09E76036854ABACADCAC9311706ED97D

URL from which 64-bit executable downloaded:

https[:]//New-Coder[.]cc/Users/signed_20240329011751156[.]exe

Disabling Event Tracing for Windows (ETW)

On execution of the Rust binary, it patches the “EtwEventWrite” API from NTDLL using the NtProtectVirtualMemory, WriteProcessMemory and FlushInstructionCache APIs.

Figure 1:  After the malware patches the “EtwEventWrite” API

This 64-bit malware process downloads an encoded shellcode from the following URL which contains the AgenetTesla payload.

URL of the shellcode:

https[:]//New-Coder[.]cc/Users/shellcodeAny_20240329011339585[.]bin

Next, the malware starts the execution of the downloaded shellcode using the “EnumSystemLocalesA” API by passing the address of the shellcode to the API as the callback function argument.

Figure 2: Moved shellcode from read-write memory to executable memory and starts its execution

The shellcode parses PEB and PEB_LDR_DATA to resolve the API dynamically. It will resolve the VirtualAlloc, VirtualFree, and RtlExitUserProcess APIs using an API hashing technique.

Next, the shellcode allocates read-write memory using the “VirtualAlloc” API and moves 0x3E3C0 bytes from the shellcode to the allocated memory.  These bytes are the encoded AgentTesla payload.

Figure 3: Moved shellcode data in read-write memory and starts decryption routine

As shown in Figure 3 above, the first 4bytes (DWORD) are the size of encoded data followed by encoded data.

Next, it proceeds to decrypt the payload. The shellcode uses a customized decryption routine where it performs single-byte XOR decryption in a loop, and for every iteration, it decrypts 0x10 bytes in the payload with a 0x10-byte encryption key. In a decryption loop, every time the malware uses a different encryption key derived from a combination of XOR and arithmetic operations. It decrypts the 0x3E184 bytes of the memory buffer to get the final payload.

Figure 4: Single-byte XOR decryption

Next, the shellcode reads the DLL name array, which contains the names of DLLs that are required for the malware to perform its operation. This array is “ole32;oleaut32;wininet;mscoree;shell32”.

The shellcode parses the PEB structure to check for the presence of the above-mentioned DLLs in the loaded modules list and loads the DLL using the “LoadLibraryA” API if they are not present.

Once the required DLLs are loaded into memory, it resolves a few more APIs such as “VirtualProtect”, “SafeArrayCreate”, “CLRCreateInstance” etc., using the API Hashing technique.

AMSI Bypass Using Memory Patching

Next, the shellcode patches the “AmsiScanBuffer” and “AmsiScanString” API, as shown below.

Figure 5: “AmsiScanBuffer” API after patching

Figure 6: “AmsiScanString” API after patching

Disabling Event Tracing (2nd time)

We have observed the second time patching in shellcode to disable Event Tracing, this might be to confirm the patching continues. It patches “EtwEventWrite” API with a single byte “0xCC” (return instruction).

Next, the shellcode starts CLR hosting.

These are the steps required to perform CLR Hosting, in order:

  • Create a CLR MetaHost instance:

ICLRMetaHost* pMetaHost = NULL;

CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, (LPVOID*)&pMetaHost);

  • Enumerate the installed runtimes:

pMetaHost->EnumerateInstalledRuntimes(&installedRuntimes);

Enumerate through runtimes and try to locate a specific dotnet version installed on the system.

One has to use “GetVersionString” method from the ICLRRuntimeInfo interface to find the supported .NET Framework version.  This .NET Framework version string will be passed to the GetRuntime API.

  • Get RuntimeInfo using “GetRuntime”:

ICLRRuntimeInfo* runtimeInfo = NULL;

pMetaHost->GetRuntime(sz_runtimeVersion, IID_ICLRRuntimeInfo, (LPVOID*)&runtimeInfo);

  • Get ICorRuntimeHost interface:

ICorRuntimeHost Interface allows more control over the managed runtime from the native code, It can be retrieved using ICLRRuntimeInfo::GetInterface

ICorRuntimeHost* pCorRuntimeHost =NULL;

runtimeInfo->GetInterface(CLSID_CorRuntimeHost,IID_ICorRuntimeHost,(LPVOID*)& pCorRuntimeHost);

  • Retrieve the default AppDomain for the current process:

ICorRuntimeHost interface allows retrieval of the default AppDomain for the current process.

IUnknown* appDomainThunk;

pCorRuntimeHost->GetDefaultDomain(&appDomainThunk);

_AppDomain* defaultAppDomain = NULL;

appDomainThunk->QueryInterface(IID_AppDomain, &defaultAppDomain);

  • Create SafeArray:

we must create SafeArray and copy the MSIL payload to this SafeArray since we can’t provide an unmanaged byte array to the “Load_3” method which loads the assembly into the app domain.

SAFEARRAYBOUND bounds[1];

bounds[0].cElements = sizeof (rawAssemblyByteArray);

bounds[0].lLbound = 0;

SAFEARRAY* safeArray = SafeArrayCreate(VT_UI1, 1, bounds);

SafeArrayLock(safeArray);

memcpy(safeArray->pvData, rawAssemblyByteArray, sizeof (rawAssemblyByteArray));

SafeArrayUnlock(safeArray);

  • Load the assembly to the AppDomain:

_AssemblyPtr  managedAssembly = NULL;

defaultAppDomain->Load_3(safeArray, &managedAssembly)

  • Find an entry point to the loaded assembly:

_MethodInfoPtr  pMethodInfo = NULL;

managedAssembly->get_EntryPoint(&pMethodInfo)

  • Call the entry point:

pMethodInfo->Invoke_3(VARIANT(), SafeArray_Pointer_To_Arguement , &VARIANT())

The second parameter for the “Invoke_3” function is the SafeArray pointer to the arguments that will be passed to the MSIL payload.

ShellCode Executing Managed Code from a Native Code Using CLR hosting

Next, the shellcode calls the “CLRCreateInstance” API from mscoree.dll. The CLRCreateInstance API returns the new CLR MetaHost instance which will be used by malware to prepare a runtime so it can execute the MSIL AgentTesla payload in memory.

We can see in the below figure that multiple GUIDs have been used while retrieving CLR Hosting Interfaces, for e.g., to retrieve “ICorRuntimeHost” interface, it passed “CLSID_CorRuntimeHost” ,  “IID_ICorRuntimeHost” as an argument to the “GetInterface” API.

Figure 7: GUID used while CLR hosting

Next, the shellcode retrieves the ICorRuntimeHost interface and starts the CLR.

Figure 8: Call to GetInterface API to retrieve the ICorRuntimeHost interface

Figure 9: Call start method from ICorRuntimeHost interface to start CLR

Next, the shellcode retrieves the default app domain for the current process, as shown below.

Figure 10: Retrieve the default AppDomain for the current process.

Next, the shellcode creates SafeArray using the “SafeArrayCreate“ API by passing an argument as the size of managed code which is 0x3CC00. This SafeArray does have a pointer to the buffer where malware copies the MSIL payload.

Figure 11: Create a SafeArray and copy AgentTesla payload to it

Once a SafeArray was created, it could be loaded into an AppDomain with the “Load_3” method, this “Load_3” method gives a pointer to an Assembly object.

Figure 12:  Calls “Load_3” method to load the SafeArray into AppDomain

Next, the shellcode zeros out the MSIL payload from the region where it got decrypted then it destroys the SafeArray using the “SafeArrayDestroy” API.

Finally, the shellcode retrieves the entry point for the assembly and calls the “Invoke_3” method to start the 32-bit MSIL AgentTesla process within the context of the 64-bit native process.

Figure 13: Starts the MSIL AgentTesla process

Figure 14: Browser folder enumerated by 64-bit process once the fileless managed code injection has been done

In Figure 14 above, it looks like the 64-bit process is enumerating the browser folder, but its AgentTesla malware started its execution within the .NET engine.

SonicWall Protections

SonicWall Capture Labs provides protection against analyzed 64-bit executable (4521162d45efc83fa76c4b5c0d405265) as GAV: MalAgent.QZ (Trojan).

This threat was also detected by SonicWall Capture ATP w/RTDMI.

The initial infection vector which is a Word document file has been detected by SonicWall Capture ATP w/RTDMI.

IOCs

Document file:

MD5 : D99020C900069E737B3F4AB8C6947375

SHA256 : A6562D8F34D4C25A94313EBBED1137514EED90B233A94A9125E087781C733B37

64-bit downloaded executable:

MD5 : 4521162D45EFC83FA76C4B5C0D405265

SHA256 : F00ED06A1D402ECF760EC92F3280EF6C09E76036854ABACADCAC9311706ED97D

Shellcode blob:

MD5 : CD485BF146E942EC6BB51351FA42B1FF

SHA256 : 02C03E2E8CA28849969AE9A8AAA7FDE8A8B918B5A29548840367F3ECAC543E2D

Injected AgentTesla Payload:

MD5 : 6999D02AA08B56EFE8B2DBBD6FDC9A78

SHA256 : 7B6867606027BFCA492F95E2197A3571D3332D59B65E1850CB20AA6854486B41

URLs used by malware:

https[:]//New-Coder[.]cc/Users/signed_20240329011751156[.]exe  (64-bit exe downloaded)

https[:]//New-Coder[.]cc/Users/shellcodeAny_20240329011339585[.]bin (shellcode downloaded)

HydraCrypt Ransomware Targets Brazil and Charges $5,000 for Decryption

Overview

The SonicWall Capture Labs threat research team has recently been tracking ransomware known as HydraCrypt. HydraCrypt originates from the CryptBoss ransomware family and was first seen in early 2016.  The sample that we analyzed demands $5,000 in Bitcoin for file retrieval, but no contact information is given to ensure this or to negotiate a price.  This variant of HydraCrypt is aimed at Brazil and claims to have successfully attacked many Brazilian firms.

The malware is written in .NET.  We can see the inner workings of the malware after decompilation. It first checks if an instance of itself is already running by looking for a mutex matching a specific pattern:

After passing the above check, the malware injects itself into svchost.exe and then proceeds to encrypt files:

Files on the system are encrypted.  Each encrypted file is given a random four-alphanumeric-character file extension.  After file encryption, a file called “read_it.txt” is dropped into directories containing encrypted files.  It contains the following message in Portuguese and is displayed on the desktop using Notepad:

The message roughly translates to:

” … :::: Legal warning :::: …

Due to numerous flaws in the company Infomach, you have suffered this ransomware attack.

We were indignantly indignant to all the customers of this company. For, as a company that supposedly sells security, has no security?

They live deceiving their customers, offering Pentest and delivering vulnerabilities scanner that solves nothing.

And another, besides selling cat by hare, like to entice the guys of IT. Giving goodies, taking to trips, paying dinners lunch anyway. If you are receiving this message, we suggest you look for a new Cyber security company most responsible.

This time our attack was very simple. Next time will lose everything: data, backup, and all your files will be leaked on the internet for everyone to download.

Infomach you are an amateur company that deceives your customers. Her owners is worth nothing. It is very rich selling dreams.

We did our homework, we studied all your steps to many, many years.

The price of the software is $ 5,000. Payment can be made only in bitcoin

 

Payment Information Amount: 0.08 BTC

Bitcoin Address: BC1QH2K3S6Z32V6787XN2QX4V655ZK5ZADP9ES4DTZ

Other customers who are exposed due to the incompetence of Infomach.

…. ”

A list of targeted directories can be seen in the code:

A list of targeted file extensions is also visible:

The malware takes several measures to disable system recovery:

An jpeg image is embedded in the malware file and is base64 encoded:

After being decoded and written to disk, it is set as the desktop wallpaper:

SonicWall Capture Labs provides protection against this threat via the following signature:

  • GAV: HydraCrypt.RSM_1(Trojan)

 

This threat is also detected by SonicWall Capture ATP w/RTDMI and the Capture Client endpoint solutions.

Atlassian’s Confluence Server Unauthenticated Remote Code Execution

Overview

The SonicWall Capture Labs threat research team became aware of a noteworthy vulnerability—an Unauthenticated Template Injection —in Atlassian Confluence platforms, assessed its impact and developed mitigation measures for it. Atlassian’s Confluence Server and Data Center published an advisory on this vulnerability affecting multiple Confluence releases. Confluence is a web-based corporate wiki software. Atlassian wrote Confluence in the Java programming language and it is utilized for collaboration, project management, process and quality management, and knowledge management.

This vulnerability is identified as CVE-2023-22527 and was assigned a critical CVSS score of 10.0.  Considering the sizeable user base, low attack complexity and publicly available exploit code(s) including a Metasploit module, Confluence users are strongly encouraged to upgrade their instances to the latest versions with utmost priority. According to ShadowServer, around 11,000 Atlassian Confluence instances are publicly exposed, and adversaries are scanning for vulnerable instances.

As per the advisory, the affected Confluence Data Center and Server versions are 8.0.x, 8.1.x, 8.2.x, 8.3.x, 8.4.x, and 8.5.0-8.5.3.

Technical Overview

This vulnerability allows threat actors to circumvent the authentication mechanism by sending a crafted request to the web server.

The primary condition that led to exploiting the vulnerability in Atlassian’s Confluence Server and Data Center is improper user input handling. As a result, attackers can leverage the injection of malicious templates without any authentication, leading to remote code execution. As Confluence is written in Java, OGNL expressions are associated with code. A specially crafted exploit that can inject an arbitrary OGNL object can execute Java code. When the application fails to validate and sanitize user input before using it in OGNL expressions, it may lead to an OGNL injection vulnerability. In OGNL injection attacks, nefarious actors input specially crafted strings containing OGNL expressions into user interfaces or input fields. When the application processes this input without proper validation, the injected OGNL expressions get executed within the application’s context. This can lead to various security issues, including authentication bypass, unauthorized access to sensitive data and remote code execution.

Triggering the Vulnerability

Within the Confluence server, it was observed that actual “views” are rendered using Velocity template files. To trigger the vulnerability, an attacker sends a POST request to “/template/aui/text-inline.vm”, demonstrating that including a .vm file helps get a hands-on unauthenticated attack surface to the Confluence instance. In this scenario, findValue is an OGNL expression that accepts a crafted string in $parameters that are not sanitized properly. As seen in Figure 2, using the OGNL expression #request[‘.KEY_velocity.struts2.context’].internalGet(‘ognl’) will grant access to the class  org.apache.struts2.views.jsp.ui.OgnlTool and calls the method Ognl.findValue(String, Object) method. Furthermore, in a comparison between the unpatched Confluence instance and the patched one, there is a .vm file named text-inline.vm. Figure 1 shows the text-inline.vm file code – the one that is deprecated in patched versions of Confluence.

Figure 1: text-inline.vm

Attackers can leverage this vm file to create a payload utilizing #parameters which pass arguments to the exec method, bypassing authentication and executing system commands.

Figure 2: CVE-2023-22527 OGNL payload

A crafted POST request sent to unpatched Confluence servers leads to OGNL template injection, which results in arbitrary command execution. By changing the payload parameter value, one can execute different commands remotely.

The attack request has the command id injected in the exec() function, as shown in Figure 3. Once this crafted request is sent, the response from the server includes the user id(uid), group id (gid), and groups from the Confluence server.

Figure 3: CVE-2023-22527 attack request

Exploiting the Vulnerability

The working PoC is an exploit tool for Confluence servers vulnerable to CVE-2023-22527. It leads to RCE in vulnerable instances of Confluence data centers and servers. Using this, an attacker can execute arbitrary code on a vulnerable instance.

Figure 4: CVE-2023-22527 PoC

SonicWall Protections

To ensure SonicWall customers are prepared for any exploitation that may occur due to this vulnerability, the following signatures have been released:

  • IPS: 2366 – Atlassian Confluence Data Center and Server SSTI
  • IPS: 4249 – Atlassian Confluence Data Center and Server SSTI 2

Remediation Recommendations

Considering the severe consequences of this vulnerability and the trending of unauthenticated nefarious activists trying to get Confluence Data Center & Confluence Server access using the exploit in the wild, users are strongly encouraged to upgrade their instances as published in the vendor advisory.

Relevant Links