The SAP Package Whose Folder Is a Link to /etc: How Link Entries in SAR Archives Work
Nov 30, 2026, 9:13:50 AM by Joerg Schneider-Simon
A SAP archive can contain an entry that is not a file but a link, and the next file in the archive can be written through that link into a system folder. This is episode 16 of File Security 101, our series on file-based threats your anti-malware does not see.
The video explains it in about two minutes.
The article adds the details and the research behind it.
A patch is just a box of files
SAP ships kernel patches, support packages and many tools as SAR files, the archive format of SAP's own tool SAPCAR. Administrators unpack them on the application server, usually with a command such as SAPCAR -xvf <archive>.SAR. Depending on the step and the local practice, that can happen as the SAP system administrator or as root. To most people, a SAR file is a box of program files and nothing more.
Entries: file, folder, link
Inside, a SAR file starts with a header ("CAR 2.01" in current archives) followed by a list of entries. Each entry carries a two-letter type. The open-source pysap library, an OWASP project, documents them: RG for a regular file, DR for a directory, LK for a Unix soft link, SC for a Windows shortcut, and a few more. A link entry tells the unpacking tool to create a symbolic link that points somewhere else on the system. That is a normal feature, the same one tar and other Unix archive formats have.
The attack: write through the link
The attacker builds a SAR file with two crafted entries. The first is a link named cfg that points to /etc. The second is a regular file named cfg/cron.d/sapupd. When SAPCAR unpacks the archive, it creates the link first and then writes the second file through it. The file does not end up in the extraction folder but in /etc/cron.d.
If the person unpacking the archive is root, that write succeeds. A file in /etc/cron.d is a scheduled job; a line such as * * * * * root <command> runs the command every minute as root. From then on, the attacker can run any command on the SAP server with full rights. Other targets in /etc work as well, from login scripts to service configuration.
A known weakness in archive tools
The technique is well documented in other archive tools:
- In August 2021, the Node.js
tarlibrary fixed three vulnerabilities in which a crafted archive with a directory and a symbolic link of the same name could write files outside the extraction folder: CVE-2021-32803, CVE-2021-37701 and CVE-2021-37712. - In June 2025, Python fixed CVE-2025-4517 and CVE-2025-4138: the
tarfileextraction filters, designed to block exactly this kind of archive, could be bypassed with crafted links (Seth Larson, Python Software Foundation). - SAPCAR itself has had path problems. In July 2025, SAP fixed CVE-2025-42970 (SAP Note 3595156): a crafted archive with directory traversal sequences could make SAPCAR write files outside the target folder when a highly privileged user extracts it. Earlier, in 2016, Core Security reported a hard-link race in SAPCAR that let a local user change permissions of other files (CVE-2016-5847).
None of these CVEs is in CISA's catalog of known exploited vulnerabilities.
When we built the demo file for this episode, we tested it against SAPCAR 7.53 (patch level 1400). It removed ../ sequences and leading slashes itself, but it created the link cfg -> /etc and wrote cfg/harmless.txt through it.
Why nobody notices
A malware scanner finds nothing, because there is nothing to find: the archive holds a link entry and a short line of text, no malicious code. A filter that does not parse the SAR format sees only compressed data. The danger appears only when SAPCAR follows the link on the server, after every check has already been done.
What to do
- Unpack SAP archives as an ordinary user into a new, empty folder, never directly into the target directory and not as root.
- Before copying anything into place, look for symbolic links in the unpacked tree, for example with
find . -type l. - Keep SAPCAR current; SAP Note 3595156 fixes CVE-2025-42970.
bowbridge Content Disarm and Reconstruct reads the SAR format itself and builds a new archive from only the plain files and folders. Link entries are dropped and counted, and members whose names climb with .. are refused. The rebuilt archive is still a valid SAR file that SAPCAR unpacks normally, but it contains no link that a later file could be written through.
Join the bowbridge CDR beta program
Sources
- pysap SAPCAR format definitions, OWASP pysap project
- CVE-2025-42970, National Vulnerability Database, July 8, 2025
- CVE-2016-5847, National Vulnerability Database, August 13, 2016
- CVE-2021-32803, CVE-2021-37701, CVE-2021-37712, National Vulnerability Database, August 2021
- CVE-2025-4517 and CVE-2025-4138, National Vulnerability Database, June 3, 2025
- Python tarfile extraction filter vulnerabilities, Seth Larson, Python Software Foundation, June 2025
Share this on social: