Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS0zZ2g2LXY1djktNnY5as4AA13n

Jetty vulnerable to errant command quoting in CGI Servlet

If a user sends a request to a org.eclipse.jetty.servlets.CGI Servlet for a binary with a space in its name, the servlet will escape the command by wrapping it in quotation marks. This wrapped command, plus an optional command prefix, will then be executed through a call to Runtime.exec. If the original binary name provided by the user contains a quotation mark followed by a space, the resulting command line will contain multiple tokens instead of one. For example, if a request references a binary called file” name “here, the escaping algorithm will generate the command line string “file” name “here”, which will invoke the binary named file, not the one that the user requested.

if (execCmd.length() > 0 && execCmd.charAt(0) != '"' && execCmd.contains(" "))
execCmd = "\"" + execCmd + "\"";

Exploit Scenario

The cgi-bin directory contains a binary named exec and a subdirectory named exec” commands, which contains a file called bin1. The user sends to the CGI servlet a request for the filename exec” commands/bin1. This request will pass the file existence check on lines 194 through 205. The servlet will add quotation marks around this filename, resulting in the command line string “exec” commands/bin1”. When this string is passed to Runtime.exec, instead of executing the bin1 binary, the server will execute the exec
binary with the argument commands/file1”. In addition to being incorrect, this behavior may bypass alias checks, and it may cause other unintended behaviors if a command prefix is configured.

If the useFullPath configuration setting is off, the command need not pass the existence check. The attack would not rely on a binary and subdirectory having similar names, and the attack will succeed on a much wider variety of directory structures.

Impact

Users of the org.eclipse.jetty.servlets.CGI Servlet with a very specific command structure may have the wrong command executed.

Patches

No patch.
In Jetty 9.x, 10.x, and 11.x the org.eclipse.jetty.servlets.CGI has been deprecated.
In Jetty 12 (all environments) the org.eclipse.jetty.servlets.CGI has been entirely removed.

Workarounds

The org.eclipse.jetty.servlets.CGI Servlet should not be used. Fast CGI support is available instead.

References

Permalink: https://github.com/advisories/GHSA-3gh6-v5v9-6v9j
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0zZ2g2LXY1djktNnY5as4AA13n
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Low
Classification: General
Published: 8 months ago
Updated: 6 months ago


CVSS Score: 3.5
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:N/I:L/A:N

Identifiers: GHSA-3gh6-v5v9-6v9j, CVE-2023-36479
References: Repository: https://github.com/eclipse/jetty.project
Blast Radius: 13.7

Affected Packages

maven:org.eclipse.jetty.ee8:jetty-ee8-servlets
Dependent packages: 3
Dependent repositories: 1
Downloads:
Affected Version Ranges: <= 12.0.0-beta1
Fixed in: 12.0.0-beta2
All affected versions:
All unaffected versions: 12.0.0, 12.0.1, 12.0.2, 12.0.3, 12.0.4, 12.0.5, 12.0.6, 12.0.7, 12.0.8
maven:org.eclipse.jetty.ee9:jetty-ee9-servlets
Dependent packages: 3
Dependent repositories: 1
Downloads:
Affected Version Ranges: <= 12.0.0-beta1
Fixed in: 12.0.0-beta2
All affected versions:
All unaffected versions: 12.0.0, 12.0.1, 12.0.2, 12.0.3, 12.0.4, 12.0.5, 12.0.6, 12.0.7, 12.0.8
maven:org.eclipse.jetty.ee10:jetty-ee10-servlets
Dependent packages: 13
Dependent repositories: 1
Downloads:
Affected Version Ranges: <= 12.0.0-beta1
Fixed in: 12.0.0-beta2
All affected versions:
All unaffected versions: 12.0.0, 12.0.1, 12.0.2, 12.0.3, 12.0.4, 12.0.5, 12.0.6, 12.0.7, 12.0.8
maven:org.eclipse.jetty:jetty-servlets
Dependent packages: 951
Dependent repositories: 8,474
Downloads:
Affected Version Ranges: >= 11.0.0, <= 11.0.15, >= 10.0.0, <= 10.0.15, >= 9.0.0, <= 9.4.51
Fixed in: 11.0.16, 10.0.16, 9.4.52
All affected versions: 10.0.0, 10.0.1, 10.0.2, 10.0.3, 10.0.4, 10.0.5, 10.0.6, 10.0.7, 10.0.8, 10.0.9, 10.0.10, 10.0.11, 10.0.12, 10.0.13, 10.0.14, 10.0.15, 11.0.0, 11.0.1, 11.0.2, 11.0.3, 11.0.4, 11.0.5, 11.0.6, 11.0.7, 11.0.8, 11.0.9, 11.0.10, 11.0.11, 11.0.12, 11.0.13, 11.0.14, 11.0.15
All unaffected versions: 10.0.16, 10.0.17, 10.0.18, 10.0.19, 10.0.20, 11.0.16, 11.0.17, 11.0.18, 11.0.19, 11.0.20