Skip to content
XSS Advisory Intermediate

GHSL-2024-075_GHSL-2024-076: Stored Cross-Site Scripting (XSS) and Remote Code Execution (RCE) via Velocity Template Evaluation in Sonatype Nexus 2

Sonatype Nexus 2 suffers from stored XSS in artifact content and RCE via Velocity template evaluation. An attacker could execute JavaScript in an admin's browser or run arbitrary commands on the server.

Michael Stepankin Follow

Originally disclosed on GitHub Security Lab

Sonatype Nexus 2 is affected by multiple high severity vulnerabilities, including Stored Cross-Site Scripting (XSS) and Remote Code Execution (RCE) via Velocity Template Evaluation. The first Cross-Site Scripting vulnerability in the artifact’s content allows unauthenticated users to perform privileged actions on the…

artsploit, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the root cause is that artifact content is served from the same origin as the admin interface without proper sanitisation, and access controls on the internal attributes directory can be bypassed, allowing template injection.

Impact

This could lead to full compromise of the Nexus instance, allowing an attacker to modify settings, artifacts, and potentially achieve remote code execution on systems using artifacts from Nexus.

What the attacker needed

Victim opens a link; attacker can upload an artifact; or attacker can publish to proxied repo

The fix

The vulnerabilities were fixed in version 2.15.2.

How it was found

  1. Start Nexus with default settings and create a proxy repository pointing to a malicious Maven repository.
  2. As an admin, navigate to the URL of a malicious POM file in the browser.
  3. The JavaScript in the POM executes in the context of the Nexus origin.
  4. For RCE, upload a maven-metadata.xml file containing a Velocity template.
  5. Send a PUT request to update the attributes of that file to set contentGenerator to velocity.
  6. Send a GET request to the file to trigger template evaluation and command execution.

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 report has not been written yet. The Original tab links to the source.

This report describes two security holes in a software called Nexus 2, which is used to store and manage software packages. One hole lets an attacker run malicious code in a victim's web browser (cross-site scripting), and the other lets an attacker run commands on the server itself (remote code execution). Both can be triggered by tricking a user into opening a link or by uploading a specially crafted file.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Michael Stepankin

View all

16 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.