Skip to content
RCE Write-up Advanced

RCE via SSTI on Spring Boot Error Page with Akamai WAF Bypass

A Spring Boot error page evaluated user input as a Spring Expression Language (SpEL) expression, allowing an attacker to execute arbitrary Java code. The attacker bypassed an Akamai WAF by constructing strings character by character and using reflection to reach Runtime.exec, achieving remote code execution.

h1pmnh.github.io

Published on h1pmnh.github.io

Dec 4, 2022 · 10 min read · writeuprcebugcrowdwaf ·

The author, on h1pmnh.github.io

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 Spring Boot error page rendered the exception message using SpEL without sanitising user-controlled input, allowing recursive evaluation of expressions.

Impact

An attacker could execute arbitrary operating system commands on the server, leading to full remote code execution, though the Akamai WAF initially blocked simple attempts and had to be bypassed.

What the attacker needed

Vulnerable Spring Boot version; user input reflected in error page; Akamai WAF present (bypass needed)

The fix

The application should be updated to a version of Spring Boot that does not evaluate SpEL in error messages, or error messages should be sanitised to prevent expression evaluation.

How it was found

  1. Identify that the q parameter supports SpEL injection and returns mathematical results.
  2. Try the obvious payload to access java.lang.Runtime, which is blocked by the WAF.
  3. Discover that quotes are transformed, preventing straightforward string construction.
  4. Find a way to build arbitrary strings using Character.toString and charAt.
  5. Use reflection to access Class.forName and Runtime.getRuntime, then invoke exec.
  6. Assemble the final payload and execute a command, confirming RCE.

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 application showed error messages that included user input, and it treated that input as code to run. An attacker could send a special error message that made the server run commands of their choosing. A web firewall tried to block this, but the attacker found a way around it.

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.