FREE Lab: Create a Free account to run this lab! Create Account in < 1 min

Spring Cloud Gateway Actuator API SpEL Code Injection (CVE-2022-22947)

cve-2022 | Level: Easy  | Total Lab Runs: 0 | Free Lab

Lab Scoreboard

Introduction

In the first quarter of 2022, an interesting and critical (base score of 10.0) Spring Cloud Gateway Code Injection vulnerability was discovered leveraging the Actuator API to perform SpEL Injection, potentially leading to system compromise.

In spring cloud gateway versions prior to 3.1.1+ and 3.0.7+ , applications are vulnerable to a code injection attack when the Gateway Actuator endpoint is enabled, exposed and unsecured. A remote attacker could make a maliciously crafted request that could allow arbitrary remote execution on the remote host.

Reference: https://nvd.nist.gov/vuln/detail/CVE-2022-22947

The Vulnerability

A route after being added to the /actuator endpoint will be pushed to the routing cache. To publish the route, a refresh request must be made and all the routes in the cache would be converted one by one to a Route. If the passed arguments' value starts with #{ and ends with } it would be considered as a SpEL expression and evaluated.Reference: https://blog.viettelcybersecurity.com/cve-2022-22947-spring-cloud-gateway-code-injection-vulnerability/

Lab Environment

In this lab environment, the user is going to get access to a low-privileged user in an Ubuntu CLI instance. The root user on the same Ubuntu instance is hosting an application leveraging Spring Cloud Gateway, that is vulnerable to CVE-2022-22947 and is accessible from the tools installed on the Ubuntu machine at http://127.0.0.1:8080.

Objective: Exploit the Actuator API SpEL Code Injection vulnerability in the deployed Spring Cloud Gateway-based application to perform privilege escalation and retrieve the flag from the /root/FLAG file.

Acknowledgements

The setup code is based on the following Github repository: https://github.com/vulhub/vulhub/tree/master/spring/CVE-2022-22947

Instructions:

  • This lab is dedicated to you! No other users are on this network :) 

  • Once you start the lab, you will have access to a root terminal of a Kali instance

  • Your Kali has an interface with IP address 192.X.Y.Z. Run "ip addr" to know the values of X and Y.

  • The target server should be located at the IP address 192.X.Y.3. It can be accessed using the hostname demo.ine.local

  • Do not attack the gateway located at IP address 192.X.Y.1


Verify:
1. /root/FLAG
 

The following activities are strictly prohibited on this website unless otherwise explicitly stated as allowed in the mission statement:

  • Using automated scanners
  • Using brute force attacks
  • Denial of Service attacks
  • Attacking other student machines in challenges where you might achieve a shell on the vulnerable system
  • Attacking the lab infrastructure

Users violating the above will be either temporarily or permanently banned from the website. 

If you are unsure about an activity, then please contact support to confirm that it is allowed on our website.

Technical Support for this Lab:

There is a reason we provide unlimited lab time: you can take as much time as you need to solve a lab. However, we realize that sometimes hints might be necessary to keep you motivated!

We currently provide technical support limited to:

  • Giving hints for a lab exercise
  • In rare circumstances, if you have totally given up (NO!!!) then tell you how to solve it. This will be limited to sharing the solution video or lab report
  • A lab exercise fails to load or has errors in it

If you need technical support, please email  attackdefense@pentesteracademy.com  clearly mention the name and link of the lab exercise and other essential details. The more descriptive you are, the faster we can help you. We will get back to you within 24 hours or less. 

For adminitrative queries, billing, enterprise accounts etc. please email feedback@binarysecuritysolutions.com