From Moodle Assignment Upload to Ghostscript Code Execution
How a memory error in Ghostscript can affect Moodle assignment conversion. The latest Moodle release can still be exposed if its server uses a vulnerable Ghostscript installation.
Uploading a file to Moodle can start work that continues after the upload is complete. A background task may send the document to Ghostscript for conversion. If the file reaches a vulnerable TrueType font interpreter, it can cause Ghostscript to write outside an allocated memory buffer.
This article explains the memory error, how Moodle reaches the affected code, and the results reported in the lab. The same risk can exist on the latest Moodle release if the server still uses a vulnerable Ghostscript installation.
Scope of the research#
The code review uses upstream Ghostscript 10.05.1. Testing covered Moodle 4.5.15+ Build 20261030 and the latest Moodle release available at the time of testing. The Moodle 5.3 source was also reviewed to trace the conversion route.
The source code shows a mismatch between the buffer used for a bounds check and the buffer used for a write. The lab record reports command execution through Moodle workers on several systems. The full runtime logs and exact distribution source packages were not independently reproduced for this article.
What the attack requires#
Only one Moodle account with permission to upload an assignment is needed.
How Moodle calls Ghostscript#
The background task \assignfeedback_editpdf\task\convert_submission reads the submission ID and attempt. It then calls document_services::get_combined_pdf_for_attempt().
- The worker finds the submission and its files.
- If a combined document is already complete, Moodle can reuse it. Otherwise, it calls
combine_files(). - Files that need PDF compatibility processing are passed to the conversion wrapper.
- The wrapper starts the executable configured in
$CFG->pathtogs. Its options includepdfwrite,-dSAFER,-dBATCH, and-dNOPAUSE.

Moodle escapes the executable and file paths before building the command. This bug concerns how Ghostscript reads the document after it starts. It does not depend on injecting a command through a filename.
A file ending in .pdf does not prove that the vulnerable interpreter ran. The document must reach the affected font code. To confirm which upload a task processed, match the submission, attempt, and file hash.
Can this affect the latest Moodle release#
On 7 November 2026, the official download page lists Moodle 5.3 and its 5.3+ weekly build. The release notes give 5 October 2026 as the release date.
The reviewed MOODLE_503_S revision,
Environment Ghostscript package Architecture Reported worker result Debian 11.11 9.53.3~dfsg-7+deb11u11arm64 Execution as www-dataDebian 12 10.0.0~dfsg-11+deb12u8arm64 Execution as www-dataDebian 13 10.05.1~dfsg-1+deb13u3arm64 Execution as www-dataCentOS Linux 8 9.27-1.el8.aarch64arm64 Execution as apache236a9d7, still has the same route. Its conversion task calls the document service, which calls combine_files(). The combined document code uses a PDF wrapper that starts the configured Ghostscript executable.
The latest Moodle release can therefore remain exposed if its server uses vulnerable Ghostscript code and the document reaches that code. Updating Moodle alone does not update this separate dependency. Testing also covered the latest Moodle release available at the time of testing.
Where the memory check goes wrong#
The buffers have different sizes#
A Type 42 font contains TrueType font data inside a PostScript font. TrueType programs can adjust glyph outlines during rendering. The legacy interpreter keeps coordinate arrays for a main glyph zone and a separate twilight zone. The twilight zone holds temporary points and can be smaller.
| Field | What it counts |
|---|---|
CUR.n_points | The reserved capacity of the main point buffer. |
CUR.pts.n_points | The active points in the main glyph zone. |
CUR.zp2.n_points | The points in the selected destination zone. |
In the reviewed source, Create_Context() reserves face->maxPoints + 2 main points, with a minimum capacity of 100. It allocates twilight arrays separately using maxTwilightPoints. The destination zp2 can refer to either zone.
The check and the write use different buffers#
Move_Zp2_Point() checks an index against the main buffer capacity. It then writes through the selected destination:
if (point >= CUR.n_points)
{
CUR.error = TT_Err_Invalid_Reference;
}
else
{
if ( CUR.GS.freeVector.x != 0 )
{
CUR.zp2.cur_x[point] += dx;
if ( touch )
CUR.zp2.touch[point] |= TT_Flag_Touched_X;
}Source: Move_Zp2_Point. The Y coordinate code follows the same pattern.
An index can fit within CUR.n_points while falling outside the smaller allocation behind CUR.zp2.cur_x. That is the missing check.
The first effect is a read and update outside the buffer: the code adds a displacement to an existing coordinate. This does not immediately give full control over every value written. The freedom vector chooses which coordinate changes, and touch controls the separate flag updates.
SHC gets its range from glyph contours#
Ins_SHC() checks the contour number against CUR.pts.n_contours. It takes point indices from the main glyph contours and passes them to the helper:
last_point = CUR.pts.contours[contour];
/* undocumented: SHC doesn't touch the points */
for ( i = first_point; i <= last_point; i++ )
{
if ( zp.cur_x != CUR.zp2.cur_x || refp != i )
MOVE_Zp2_Point( i, dx, dy, FALSE );
}Source: Ins_SHC. A valid contour does not prove that its points fit inside the selected destination. The reference point check does not check the destination size. The FALSE argument prevents touch flag updates on this route.
SHZ gets its range from a reference zone#
Compute_Point_Displacement() checks a reference point and calculates how far it moved. It returns the reference zone in local zp. Ins_SHZ() uses that zone's point count to control its loop:
last_point = zp.n_points - 1;
/* undocumented: SHZ doesn't touch the points */
for ( i = 0; i <= last_point; i++ )
{
if ( zp.cur_x != CUR.zp2.cur_x || refp != i )
MOVE_Zp2_Point( i, dx, dy, FALSE );
}Source: Ins_SHZ. The loop uses the reference zone's size, the write uses zp2, and the helper checks main capacity. These can be different allocations.
By comparison, Ins_SHP() checks BOUNDS(point, CUR.zp2.n_points) before calling the helper. This shows why each caller also needs review.

What memory corruption can lead to#
A write outside a buffer proves a memory error. Command execution needs more evidence. A crash by itself does not show that an attacker can run commands.
TrueType storage operations use interpreter metadata to find their memory. If corruption changes that metadata, later operations may access memory outside the intended object. A complete exploit must connect that first corruption to wider memory access, changes in policy state, and command execution.
SAFER enforces rules inside the Ghostscript process. Those rules depend on memory in the same process as the parser. Memory corruption can damage that state even when -dSAFER is enabled. The operating system still limits any resulting commands to the worker's account and confinement.
Reported lab results#
Testing covered the latest Moodle release as well as Moodle 4.5.15+ Build 20261030. The table below records the original package results on Moodle 4.5.15+. These results describe specific setups, not every affected version.
| Environment | Ghostscript package | Architecture | Reported worker result |
|---|---|---|---|
| Debian 11.11 | 9.53.3~dfsg-7+deb11u11 | arm64 | Execution as www-data |
| Debian 12 | 10.0.0~dfsg-11+deb12u8 | arm64 | Execution as www-data |
| Debian 13 | 10.05.1~dfsg-1+deb13u3 | arm64 | Execution as www-data |
| CentOS Linux 8 | 9.27-1.el8.aarch64 | arm64 | Execution as apache |
The Debian 13 record includes this output:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
The screenshot supports the reported account identity. To tie it to a particular conversion run, match the document hash, submission attempt, task ID, timestamps, PID, parent PID, executable, and instance. The image alone does not show every step in that link.
The Debian 13 amd64 record includes native testing without a separate confirmed web worker result. The CentOS Stream 9 record using 9.54.0-20.el9 also lacks a confirmed link to the Apache worker. These are not counted as confirmed worker results here.
Conclusion#
The bug checks a point index against main buffer capacity, then uses it to change a selected zone that may be smaller. SHC and SHZ can reach this mismatch using ranges taken from other objects.
Moodle can pass an authenticated user's submission to this code through document conversion. Testing also covered the latest Moodle release, and the route is present in the reviewed Moodle 5.3 source. The risk depends on the Ghostscript installation and the document being processed, so assess the converter as well as Moodle itself.
Continue exploring
Related articles

Research
Jejak Identitas Indonesia dalam Bisnis KYC Claude
Foto pertemuan, dua video, percakapan forum, dan penawaran jasa menuntun penelusuran atas dugaan pemanfaatan identitas warga Indonesia untuk verifikasi akun Claude.
Knowledge for a better understood world.

Research
From Browser Tab to Ransomware: Encrypting Local Files with the File System Access API and Web Crypto
A malicious website can ask Chrome users to “compress photos” and, with one folder permission, encrypt every file in place using only browser APIs. No download, no extension, no native malware. This article breaks down the attack chain, the hybrid RSA/AES design, what works on Android and desktop, and what does not.

Technology
PetaBisnis: Choose a Business Location with Data
Before renting a place for a new shop, owners need to know where the competitors are, how busy the area is, and what the risks are. PetaBisnis answers these questions with a location study for any area in Indonesia.