【问题标题】:Checkmarx security with Database ResultSet使用数据库结果集的 Checkmarx 安全性
【发布时间】:2021-02-04 16:27:41
【问题描述】:

然后,该元素的值在没有经过适当过滤或编码的情况下流经代码,最终在方法 RepositoryClass 中显示给用户。这可能会启用存储的跨站点脚本攻击。 我没有向用户显示从数据库检索到的任何数据。

如何解决这个问题?或者这是误报? 我有以下代码 sn-p

@RestController
public class TestController {
    
    @GetMapping("/date")
    public String m1(@Pathvariable String date) {
    // call to repository
   List<Employees> employeeList=  repositoryClass.m1(date);
 // then i send this employeeList to kafka topic using Kafka Template

    return "Procedure  ran ";

// @RestController
public class RepositoryClass {

       void List<Employees> m1(String date )
{
     List<Employees> employeeList = jdbcTemplate.execute(date); //call to procdure to get employeeList

}
}

【问题讨论】:

    标签: java spring-boot security owasp checkmarx


    【解决方案1】:

    你从前端获取的“日期”没有被过滤,直接使用这个“日期”执行SQL,可能会导致SQL注入。对于您的情况,“日期”仅用作 SQL 的条件。从您展示的代码来看,我认为这不会是存储型 XSS,但我建议您使用过滤功能来限制“日期”以避免 SQL 注入。

    【讨论】:

    • 如何过滤日期?你的意思是你需要消毒?
    • 这取决于您的日期类型,例如,如果“日期”是像这样的时间戳 943891200,您可以使用像 ^[0-9]*$ 这样的正则表达式来限制日期。
    猜你喜欢
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多