Checkmarx:React 应用程序中缺少 HSTS 标头

问题描述 投票:0回答:1

我已经对 React 应用程序执行了 Checkmarx 扫描。它显示以下扫描结果:

缺少 HSTS 标头:
Web 应用程序未定义 HSTS 标头,因此容易受到攻击。

以下突出显示的代码显示错误:

const client = async (endpoint, customConfig, isStaticContent) => {
     return fetch(fullUrl, config).then((response) => {
          if (typeof response?.setHeader === 'function') {
            response?.setHeader(
                'Strict-Transport-Security',
                'max-age=63072000', //error showing for this line
                'includeSubDomains'
            )
          }
     })
}

我已经检查了 chrome 开发工具上的响应标头。
应用程序具有以下标题:

严格运输安全:最大年龄=31536000; includeSubDomains

如何解决这个 checkmarx 问题?

javascript node.js reactjs security hsts
1个回答
0
投票

根据this answer,您的所有 HSTS 值必须在同一行上,Checkmarx 才能通过。例如:

response?.setHeader(
                'Strict-Transport-Security',
                'max-age=63072000; includeSubDomains'
)

© www.soinside.com 2019 - 2024. All rights reserved.