首页 > 解决方案 > 如何解决 Checkmarx 漏洞 - Angular 代码中的“Client Insufficient ClickJacking Protection”,在某些组件 HTML 页面上报告?

问题描述

Checkmarx 扫描报告 Angular 组件 HTML 页面上的“Client Insufficient ClickJacking Protection”漏洞。

这是一页:
文件名 src/app/app.component.html

<div class="home-page-container">

这是另一个:
文件名 src/app/create.component.html

<div class="control-bar">

Checkmarx 建议:
该应用程序不会通过使用 framebusting 脚本来保护网页 src/app/app.component.html 免受旧版浏览器中的点击劫持攻击。

我已经在index.html页面中为旧版浏览器实现了 Frame busting 代码,因为 Angular 代码是一个单页应用程序。
并且X-Frame-Options响应标头在托管服务器上设置为SAMEORIGIN 。

但 Checkmarx 仍然在组件特定的 HTML 页面中报告此漏洞。
如何修复此漏洞?

这是添加到Angular 代码的index.html的 framebusting 代码 -

<style> html {display : none; } </style>
<script>
    if ( self === top ) {
    document.documentElement.style.display = 'block';
    }
    else {
    top.location = encodeURI(self.location);
    }
</script>

标签: angularcheckmarx

解决方案


推荐阅读