Spring Cloud Gateway Server Unauthorized Access Vulnerability

Vulnerability Description

Spring Cloud Gateway is an API gateway in Spring. Versions 3.1.0 and 3.0.6 (inclusive) and prior contain a SpEL expression injection vulnerability. If an attacker can access the Actuator API, the vulnerability can be exploited to execute arbitrary commands.

Environment Setup

Run the following command to start a web service that uses Spring Cloud Gateway 3.1.0:

docker-compose up -d

After the service starts, access http://your-ip:8080 to see the demo page, and the upstream of this page is example.com.

image-20220519211640099

Vulnerability Reproduction

Exploiting this vulnerability requires multiple steps.

First, send the following packet to add a route containing malicious SpEL expression:

image-20220519211737396

Then, send the following packet to apply the newly added route.

image-20220519212128250

This packet will trigger the execution of the SpEL expression:

image-20220519212220678

Finally, send the following packet to clean up and delete the added route:

image-20220519212306237

Refresh the routes:

image-20230130134103788

Last updated