CVE-2023-51889 is a stack overflow in the validate function of Mathtex 1.05 and earlier. A crafted string in the URL lets a remote attacker run arbitrary code. The record rates it Critical at 9.8. No fixed version is named.
What's affected
Mathtex 1.05 and earlier, a CGI program that renders LaTeX into images for web pages. The record gives no fixed version, and the write-up we read tests against 1.05 and earlier without naming a patched release. Check the project's current release and your package source.
Mathtex is distributed through CTAN and is often copied by hand into a server, so the copy you run may not match any release. Six CVEs were reported against it from one fuzzing session in December 2023, and all of them name 1.05 and earlier. The record for each lists the CTAN mathtex product with no version bound, so treat every version you find as in scope until the maintainers say otherwise.
The record gives a CVSS score of 9.8 (Critical). The CVSS vector reads as follows. The attack can be reached over the network, and the complexity is low. No account is needed. No user interaction is required. Impact on confidentiality is high, on integrity high, and on availability high. The weakness class is CWE-787.
How to check if you're exposed
Find out whether mathtex is installed. On a server, find / -name 'mathtex*' 2>/dev/null lists copies. A web server configuration that maps a cgi-bin path to mathtex.cgi also shows it. Then read the version in the source or documentation for your copy.
If the program is reachable from the internet, treat it as exposed. Most uses are old wiki or forum add-ons that nobody remembers.
Your dependency scanner will not see a copy of a CGI program dropped into a directory. A file system search, plus a review of web server configuration, is the dependable way to find it. You can also scan the application that embeds it with the free in-browser scan at https://gold.safeguard.sh/scan to catch the packaged components around it.
What to do now
- Find mathtex installs, including old wiki or forum add-ons.
- Check for a newer release, and update if one exists.
- Remove the program, or move math rendering to a maintained tool, if you cannot update.
- Do not expose it to the internet. Put it behind authentication or a reverse proxy that limits request size.
- Run it as an unprivileged account with no write access beyond its cache directory.
Why it matters
The weakness is an out of bounds write on the stack, CWE-787. The write-up reports a stack overflow in validate when handling certain input.
Stack memory corruption can lead to code execution, which is why the record lists high impact on all three properties.
With no patch named, the way to cut risk is to take the program off untrusted networks.
Quick check
Is code execution possible?
The record says arbitrary code can be executed by a remote attacker.
What should I do first?
Find out whether the program is reachable from the internet and, if so, close that path.
Sources
Last reviewed: 19 October 2026.