|
What is a Shared Object File |
5/20/2025 - Brian O'Neill |
IntroductionShared Object files (.so files) are a compiled library file type following the ELF (Executable and Linkable Format) structure. They’re used by Linux and Unix-based operating system like Ubuntu, Debian, and CentOS, and they allow applications to share functionality by dynamically loading various features at runtime. In this article, you’ll learn about .so files in more detail, how they interact with the dynamic linker, and why they’re extremely dangerous file types when threat actors exploit them. We’ll look at some real-world threat examples involving malicious .so payloads, and we’ll take a broader look at the techniques attackers generally use to bypass upload protections when delivering .so payloads. At the end, we’ll discuss how Cloudmersive’s Advanced Virus Scan API protects against .so-based attacks with deep content verification and malware signature detection. How Shared Object Files Operate in Linux and Unix SystemsShared Object files serve as dynamically linked libraries in Linux systems. If you’re more familiar with Windows systems, their comparable file type is .dll. These file types are designed to load at runtime, rather than compiling directly into the program binary – and this benefits applications tremendously. It makes them smaller, easier to maintain, and more efficient because they’re sharing common functionality. Examples of .so files in action are easy to come by. When a media player on Ubuntu plays an MP3 file, for instance, it needs a library to handle file decoding – and it isn’t the only application that needs to do that. So, instead of carrying that functionality independently, it loads a shared library. That library is only stored and loaded once into memory. The key concepts to bear in mind here are Dynamic Linking, Dynamic Linkers themselves, and ELF structure. These are shared ideas across most operating systems.
Linux and Unix-based systems provide welcome functionality in managing libraries. Toos like Why Shared Object Files Pose a Serious Security RiskWhen shared library files are used malicious (or improperly), they become a serious liability. Sophisticated attackers with deep knowledge of OS behaviors and .SO file structure can exploit these dynamic linking files in ways that don’t require any actual changes to a program’s main executable. If, for instance, an attacker uploads a malicious .so file to a web server that uses a plugin architecture, they might gain the opportunity to trigger malicious code during normal operations without leaving an immediately noticeable trace. On the extreme end, attackers might replace or modify system-wide .so files like In environments running CentOS, Debian, or Ubuntu, these risks are particularly amplified. In these examples, many services dynamically link to core .so files, providing numerous targets for exploitation. Below are brief summaries of some of the most common techniques employed in .SO-based attacks.
.SO Vulnerabilities in the Wild: CVE-2021-4034Back in 2021, a critical Linux vulnerability was identified. This showed that environment manipulation could cause a legitimate application – in this case, pkexec – to load a malicious .so file. By injecting a crafted shared object, an attacker could exploit this vulnerability to gain root access to a system without any authentication. This vulnerability highlights how shared objects can quickly become weapons under the right set of conditions. Bypassing Security Policies with Basic Shared Object ManipulationsThere’s a common misconception that extension blocking solves the problem of mitigating insecure files in file upload- and file transfer-based attacks. It’s important to dispel this logic. Attackers can easily disguise .so files (and many other insecure file types) with manually changed extensions like .jpg or .txt and re-name the file correctly after it enters the target system. Shared Object file headers can also be spoofed to show non-executable internal file signatures. Additionally, as we alluded to in the prior section, .so files can be nested deeply within archives – often more than one archive at a time. There’s nothing stopping an attacker from hiding .so payloads in a .tar file compressed in a .zip file compressed in a .rar file. In classic trojan-type attacks, malicious .so files can be snuck into otherwise legitimate .deb packages as “installer bait”. Downloading apparently legitimate software from illegitimate websites can initiate this type of attack. Detecting Shared Object Threats with CloudmersiveCloudmersive’s Advanced Virus Scan API is designed to identify sophisticated threats by looking deep under the hood of each file and its nested objects. Files with spoofed extensions are identified through rigorous content verification, confirming that the file contents don’t rigorously conform with the formatting requirements associated with the given file extension. Archives are unpacked and scanned recursively, ensuring each subfile, folder, and nested sub-archive is opened and scoured thoroughly. Traditional malware signature detection policies take care of known virus and malware libraries, and heuristic & behavioral analysis identify unusual or obfuscated patterns typical of malicious shared libraries. Whether a malicious .so file is named “helper.jpg” or embedded 5 layers deep in a .tar.gz, Cloudmersive’s Advanced Virus Scan engine will uncover and identify the true nature of the underlying content. ConclusionShared Object files are essential to the operation of Linux and Unix systems, but they also represent a significant attack surface. Exploiting the dynamic linker, hijacking path resolution, or injection malicious .so code into legitimate workflows can give attackers powerful control over a system. As ever, prevention is better than cure, so it’s important to carefully defend against .SO-based attacks with rigorous content inspection. *To learn more about defending against .SO threats with Cloudmersive’s Advanced Virus Scan API, please contact a member of our team. |