【问题标题】:Fix Checkmarx XSS Vulnerabilities exprees js修复 Checkmarx XSS 漏洞 exprees js
【发布时间】:2021-09-24 19:51:34
【问题描述】:

我总是在 exprees 路由器中看到 checkmarx XSS 漏洞,不知道用什么其他功能来修复它。我使用了 express 验证器,但到目前为止没有运气。

  const express = require("express");

const router = express.Router();
const { body, validationResult } = require("express-validator");

router.post(
  `/testData`,
  body("empName").trim().escape().not().isEmpty(),
  async (req, res, next) => {
    try {
     //getting checkmarx xss reflected vulnerability at req.body
      const callTags = req.body
      const errors = validationResult(req);
      if (!errors.isEmpty()) {
        return res.status(400).json({ errors: errors.array() });
      }
      res.status(response.statusCode).json(''hello);
    } catch (ex) {
      
      next(ex);
    }
  }
);
module.exports = router;

}

【问题讨论】:

    标签: node.js express xss checkmarx


    【解决方案1】:

    利用 Checkmarx 识别的“消毒剂”,例如使用 HandleBarsJS 等模板引擎,您的响应将被转义输出

    <p>Hello, {{empName}}</p>
    

    【讨论】:

    • 这是服务器端代码,我也使用了下面的代码,但它仍然显示 XSS 问题,请参阅下面的代码 const calltags= sanitizer.sanitize(JSON.stringify(req.body)) // 这也是显示反射漏洞
    猜你喜欢
    • 2019-08-27
    • 1970-01-01
    • 1970-01-01
    • 2014-12-25
    • 1970-01-01
    • 2023-03-10
    • 2022-04-17
    • 2023-04-07
    • 1970-01-01
    相关资源
    最近更新 更多