Skip to content

Commit 1b079d1

Browse files
author
“threedr3am”
committed
feat:spring-session-data-redis RCE
1 parent 9dff6f8 commit 1b079d1

File tree

18 files changed

+568
-0
lines changed

18 files changed

+568
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<module>nexus</module>
2828
<module>apache-poi</module>
2929
<module>java-compile</module>
30+
<module>spring-session-redis-sync</module>
3031
</modules>
3132

3233
<name>learn-java-bug</name>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring-session-redis-sync</artifactId>
7+
<groupId>com.xyh</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>1</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-starter-web</artifactId>
18+
<version>2.3.0.RELEASE</version>
19+
</dependency>
20+
</dependencies>
21+
22+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package me.threedr3am.bug.spring.redis.session;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* @author threedr3am
8+
*/
9+
@SpringBootApplication
10+
public class Application {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(Application.class, args);
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package me.threedr3am.bug.spring.redis.session.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
5+
6+
/**
7+
* @author threedr3am
8+
*/
9+
@Configuration
10+
@EnableRedisHttpSession(redisNamespace = "threedr3am-session", maxInactiveIntervalInSeconds = 2 * 60 * 60)
11+
public class SpringHttpSessionConfig {
12+
13+
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.threedr3am.bug.spring.redis.session.controller;
2+
3+
import javax.servlet.http.HttpSession;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestParam;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
/**
9+
* @author threedr3am
10+
*/
11+
@RestController
12+
public class TestController {
13+
14+
@GetMapping("/cache")
15+
public String cacheData(@RequestParam(name = "data", required = false) String data, HttpSession httpSession) {
16+
if (data == null) {
17+
return String.valueOf(httpSession.getAttribute("data"));
18+
} else {
19+
httpSession.setAttribute("data", data);
20+
return data;
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
server:
2+
port: 30001
3+
4+
spring:
5+
reids:
6+
host: 127.0.0.1
7+
port: 6379
8+
password:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring-session-redis-sync</artifactId>
7+
<groupId>com.xyh</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>2</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-starter-web</artifactId>
18+
<version>2.3.0.RELEASE</version>
19+
</dependency>
20+
</dependencies>
21+
22+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package me.threedr3am.bug.spring.redis.session;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* @author threedr3am
8+
*/
9+
@SpringBootApplication
10+
public class Application {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(Application.class, args);
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package me.threedr3am.bug.spring.redis.session.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
5+
6+
/**
7+
* @author threedr3am
8+
*/
9+
@Configuration
10+
@EnableRedisHttpSession(redisNamespace = "threedr3am-session", maxInactiveIntervalInSeconds = 2 * 60 * 60)
11+
public class SpringHttpSessionConfig {
12+
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.threedr3am.bug.spring.redis.session.controller;
2+
3+
import javax.servlet.http.HttpSession;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestParam;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
/**
9+
* @author threedr3am
10+
*/
11+
@RestController
12+
public class TestController {
13+
14+
@GetMapping("/cache")
15+
public String cacheData(@RequestParam(name = "data", required = false) String data, HttpSession httpSession) {
16+
if (data == null) {
17+
return String.valueOf(httpSession.getAttribute("data"));
18+
} else {
19+
httpSession.setAttribute("data", data);
20+
return data;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)