Skip to content

Commit 7f77be4

Browse files
committed
feat: add hook to guide towards SpEL injection
1 parent f2a603f commit 7f77be4

File tree

7 files changed

+450
-5
lines changed

7 files changed

+450
-5
lines changed

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ VULNERABLE_TEST_MAVEN_ARTIFACTS = [
136136
"org.apache.xmlgraphics:batik-xml:1.14",
137137
"org.glassfish:javax.el:3.0.1-b06",
138138
"org.hibernate:hibernate-validator:5.2.4.Final",
139+
"org.springframework.cloud:spring-cloud-function-context:3.1.6",
140+
"org.springframework.cloud:spring-cloud-function-core:3.1.6",
141+
"org.springframework:spring-messaging:6.1.4",
139142
]
140143

141144
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")

examples/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,26 @@ java_fuzz_target_test(
334334
],
335335
)
336336

337+
java_fuzz_target_test(
338+
name = "SpringCloudFunctionRoutingFuzzer",
339+
srcs = [
340+
"src/main/java/com/example/SpringCloudFunctionRoutingFuzzer.java",
341+
],
342+
allowed_findings = [
343+
"com.code_intelligence.jazzer.api.FuzzerSecurityIssueHigh",
344+
],
345+
fuzzer_args = ["-runs=100000"],
346+
tags = ["no-jdk8"],
347+
target_class = "com.example.SpringCloudFunctionRoutingFuzzer",
348+
verify_crash_reproducer = False,
349+
deps = [
350+
"@maven//:com_fasterxml_jackson_core_jackson_databind",
351+
"@maven//:org_springframework_cloud_spring_cloud_function_context",
352+
"@maven//:org_springframework_cloud_spring_cloud_function_core",
353+
"@maven//:org_springframework_spring_messaging",
354+
],
355+
)
356+
337357
java_fuzz_target_test(
338358
name = "JacksonCborFuzzer",
339359
srcs = [
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2025 Code Intelligence GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example;
18+
19+
import com.fasterxml.jackson.databind.ObjectMapper;
20+
import java.util.Arrays;
21+
import java.util.logging.Level;
22+
import java.util.logging.LogManager;
23+
import org.springframework.cloud.function.context.FunctionProperties;
24+
import org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry;
25+
import org.springframework.cloud.function.context.config.RoutingFunction;
26+
import org.springframework.cloud.function.json.JacksonMapper;
27+
import org.springframework.messaging.Message;
28+
import org.springframework.messaging.converter.CompositeMessageConverter;
29+
import org.springframework.messaging.converter.StringMessageConverter;
30+
import org.springframework.messaging.support.MessageBuilder;
31+
32+
/**
33+
* Reproduce <a href="https://spring.io/security/cve-2022-22963">CVE-2022-22963</a> by fuzzing the
34+
* routing-expression header in Spring Cloud Function.
35+
*/
36+
public class SpringCloudFunctionRoutingFuzzer {
37+
private static RoutingFunction router;
38+
39+
public static void fuzzerInitialize() {
40+
LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE);
41+
// Empty function registry
42+
SimpleFunctionRegistry registry =
43+
new SimpleFunctionRegistry(
44+
null,
45+
new CompositeMessageConverter(Arrays.asList(new StringMessageConverter())),
46+
new JacksonMapper(new ObjectMapper()));
47+
router = new RoutingFunction(registry, new FunctionProperties());
48+
}
49+
50+
public static void fuzzerTestOneInput(String payload, String expr) {
51+
try {
52+
Message<String> message =
53+
MessageBuilder.withPayload(payload)
54+
.setHeader("spring.cloud.function.routing-expression", expr)
55+
.build();
56+
router.apply(message);
57+
} catch (Throwable ignored) {
58+
// Most inputs will cause parsing or routing errors; that is fine.
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)