Skip to content
RCE Write-up Advanced

Exploiting CVE-2022-24816: A Code Injection In The Jt-jiffle Extension Of Geoserver

The Jiffle scripting language in GeoServer's jt-jiffle extension failed to escape Javadoc comments when generating Java source code, allowing an attacker to inject arbitrary Java code. By overriding the Double class with a static initialiser, an unauthenticated attacker could execute arbitrary commands on the server.

Rémi Matasse Follow

Published on synacktiv.com

Written by Vincent Herbulot, Rémi Matasse - 12/08/2022 - in Pentest - Download

Remsio (@_remsio_), Us3r777 (@us3r777), on synacktiv.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Impact

An unauthenticated attacker could execute arbitrary commands on the server, as demonstrated by running the id command and receiving its output.

What the attacker needed

GeoServer with JAI-EXT prior to 1.1.22; Network access to the GeoServer instance; No authentication required

The fix

The vulnerability was fixed in JAI-EXT 1.1.22 by validating Jiffle input variable names and escaping Javadoc comments when including Jiffle sources in output.

How it was found

  1. Send a WPS Execute request to the /geoserver/wms endpoint with a Jiffle script containing a comment terminator to break out of the Javadoc comment.
  2. Observe a verbose error showing the generated Java source, confirming the injection point.
  3. Craft a payload that closes the comment, defines a rogue Double class with a static initialiser, and reopens a comment.
  4. Send the request; the static initialiser executes when the Double class is loaded, running the injected command.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

GeoServer is a map server that lets users run small scripts called Jiffle to process images. The server turns these scripts into Java code and compiles them. Because it did not properly handle comments in the script, an attacker could sneak in their own Java code, which then ran on the server. This meant anyone could run commands on the machine without logging in.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.