Skip to content
RCE Write-up Intermediate

Exploiting Grafana To achieve Remote Command Execution

A Grafana instance was left with default admin credentials, and the attacker used the built-in SQL Server data source with Windows Authentication to connect to a local SQL Server without credentials. They then enabled the xp_cmdshell procedure to execute system commands on the Windows host.

konqi Follow

Published on medium.com

Today I was conducting internal penetration testing for a mid-size company when I came across a Grafana(v10) instance with default admin credentials.

Vahagn Israelian, on medium.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

Root cause

Likely the Grafana instance was deployed with default admin credentials and the underlying Windows SQL Server allowed Windows Authentication from the Grafana service account, enabling privilege escalation to command execution.

Impact

An attacker with default credentials could execute arbitrary system commands on the Windows host running Grafana and SQL Server.

What the attacker needed

Grafana with default admin credentials; Grafana installed on Windows; SQL Server with Windows Authentication enabled; Network access to Grafana and SQL Server

How it was found

  1. Log in to Grafana using the default admin credentials.
  2. Add a new Microsoft SQL Server data source, setting the authentication type to Windows Authentication.
  3. Connect to the SQL Server without providing a username or password.
  4. Execute SQL queries through the data source.
  5. Enable the xp_cmdshell procedure via SQL configuration commands.
  6. Run system commands through SQL Server.

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.

The Grafana dashboard was protected by the factory default username and password, which anyone can look up. Once logged in, the attacker added a connection to a database on the same machine that trusted the Windows login of the Grafana service, so no separate password was needed. From there they turned on a database feature that lets SQL run operating system commands, giving them control of the server.

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 konqi

View all

4 more disclosed reports, best first.

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.