Vulnerability Mining: Spring Cloud injection vulnerability

Vulnerability description

The Spring framework provides a comprehensive programming and configuration model for modern java based enterprise applications (on any type of deployment platform).

The apply method of the RoutingFunction class in the Spring Cloud Function of the service framework in Spring Cloud processes the "spring. Cloud. Function. Routing expression" parameter in the request header as a Spel expression, causing Spel expression injection, which allows attackers to execute arbitrary code.

Utilization conditions

3.0.0.RELEASE <= Spring Cloud Function <= 3.2.2

Environment construction

Create a new Spring boot project on the official website( )Start with idea.

Modify POM XML configuration file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
<relativePath/> <!-- lookup parent from repository -->
<description>Demo project for Spring Boot</description>







Last visit The following page indicates success.

[1 > all resources acquisition < 1]
1. Many out of print e-books that can't be bought
2. Training materials inside the safety factory
3. Complete kit
4. 100 src source code technical documents
5. Basic introduction to network security, Linux, web security, attack and defense videos
6. Emergency response notes 7. Network Security Learning Route
8. Analysis of ctf flag competition
9. Introduction notes to WEB security

Loophole recurrence

Vulnerability principle

The apply method parses the Spel expression in the http header, resulting in Spel expression injection.

View official diff

Enter the springframework/cloud/function/context/config/RoutingFunction file. Enter debug mode and add breakpoints to the apply() method.

After entering the apply() method, it will call route(). In this method, it will judge whether the input is an instance of message and whether the function is empty, and then enter else if to get the header information and get the key value spring cloud. function. Routing expression. Judge whether there are spaces in the middle. Then continue down.

You will enter the springframework/cloud/function/context/config/RoutingFunction/functionFromExpression() method.

routingExpression will be passed as a parameter into the spring framework / expression / common / templateawareexpressionparser / parseexpression() method.

Judge whether its context is none before entering

springframework/expression/spel/standard/SpelExpressionParser/doPareExpression() will create a new InternalSpelExpressionParser class and call doPareExpression() to follow up.

In the springframeworl/expression/spel/stand/InternalSpelExpressionParser/doParseExpression() method, the tokenizer In process (), judge the source code and bytecode of token and continue to go down.

A new SpelExpression() will follow up


In the SpelExpression() method, the expression is assigned to this Expression continue to follow up return to springframework / expression / spel / standard / spexpressionparser / doparseexpression(), return to springframework / expression / common / templateawareexpressionparser / pareexpression(), return

In the functionFromExpression() method, messageutils. Is entered toCaseInsensitiveHeadersStructure().

Call MessageStructureWithCaseInsensitiveHeaderKeys() and enter the putAll() method to get the header information in the message.

Finally, it will enter the vulnerability trigger point.

Vulnerability testing

The construction of Payload can refer to the official test case.

This time, we use to create a file test. Use payload touch / TMP / XXXXXX test. test.

Tags: security Cyber Security Web Security

Posted by renny on Thu, 14 Apr 2022 19:51:13 +0930