Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix snake yaml decode rce #1239

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
@RequestMapping(path = "/api/apps", produces = {APPLICATION_JSON_VALUE})
public class AppController {

private static final String[] RISKY_STR_ARR = {"ScriptEngineManager", "URLClassLoader"};

@Autowired
private AppService appService;

Expand Down Expand Up @@ -92,6 +94,13 @@ public ResponseEntity<Message<Void>> deleteAppDefineYml(
@Operation(summary = "Add new monitoring type define yml", description = "新增监控类型的定义YML")
public ResponseEntity<Message<Void>> newAppDefineYml(@Valid @RequestBody MonitorDefineDto defineDto) {
try {
for (String riskyToken : RISKY_STR_ARR) {
if (defineDto.getDefine().contains(riskyToken)) {
return ResponseEntity.ok(Message.<Void>builder()
.code(CommonConstants.FAIL_CODE)
.msg("can not has malicious remote script").build());
}
}
appService.applyMonitorDefineYml(defineDto.getDefine(), false);
} catch (Exception e) {
return ResponseEntity.ok(Message.<Void>builder()
Expand All @@ -105,6 +114,13 @@ public ResponseEntity<Message<Void>> newAppDefineYml(@Valid @RequestBody Monitor
@Operation(summary = "Update monitoring type define yml", description = "更新监控类型的定义YML")
public ResponseEntity<Message<Void>> updateAppDefineYml(@Valid @RequestBody MonitorDefineDto defineDto) {
try {
for (String riskyToken : RISKY_STR_ARR) {
if (defineDto.getDefine().contains(riskyToken)) {
return ResponseEntity.ok(Message.<Void>builder()
.code(CommonConstants.FAIL_CODE)
.msg("can not has malicious remote script").build());
}
}
appService.applyMonitorDefineYml(defineDto.getDefine(), true);
} catch (Exception e) {
return ResponseEntity.ok(Message.<Void>builder()
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<lombok.version>1.18.20</lombok.version>
<slf4j.version>1.7.36</slf4j.version>
<xml.bind.version>2.3.0</xml.bind.version>
<snake.yaml.version>1.32</snake.yaml.version>
<snake.yaml.version>1.33</snake.yaml.version>
<kafka-clients.version>3.4.0</kafka-clients.version>

<mysql.version>8.0.30</mysql.version>
Expand Down
Loading