在运行角13项目的checkmarx报告时,报告了潜在的点击问题。即使我尝试使用app.component.html文件中的框架破坏脚本修复此问题,也会报告index.html的问题。有什么解决这个问题的建议吗?
中的框架破坏脚本
<style> html {display : none; } </style>
<script>
if ( self === top )
{ document.documentElement.style.display = 'block'; }
else
{ top.location = encodeURI(self.location); }
</script>
Result: One more high priority issue was raised: Client DOM open redirect
中向元标记添加框架祖先和CSP标记
{{ <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' *.tech.orange; upgrade-insecure-requests;frame-ancestors 'none'; ">}}
{{}结果:问题持续存在
设置x帧选项
内部认证服务:
const myheader = new HttpHeaders().set('Content-Type',CONTENT_TYPE ).set('Authorization', AUTH_AUTHENTICATION).set('Content-Security-Policy',CSP_TYPE); AUTH_AUTHENTICATION).set('Content-Security-Policy',CSP_TYPE).set('X-Frame-Options', 'SAMEORIGIN');;
Inside auth-http interceptor:
intercept(req: HttpRequest<any>, next: HttpHandler) { const token = this.tokenService.getToken(); if (token != null) { req = req.clone(
{ headers: req.headers.set('Authorization', 'Bearer ' + token) }
); req = req.clone(
{ headers: req.headers.set('Authorization', 'Bearer ' + token).set('X-Frame-Options', 'sameorigin') }
); }
结果:问题依然存在
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' *.tech.orange; upgrade-insecure-requests;"> <meta http-equiv="X-Frame-Options" content="deny">
结果:问题依然存在
5)方法::按照下面的堆栈溢出建议,对早期方法中使用的框架破坏脚本进行修正:
top.location = encodeURI(self.location);
结果:问题依然存在
6)方法:配置Nginx
若要配置Nginx以发送X框架选项头,请将其添加到您的http、服务器或位置配置中:
add_header X-Frame-Options SAMEORIGIN always;
结果:问题依然存在
X-frame-options
对角度的用法解释不充分
结果:无法核实
发布于 2022-11-29 03:36:38
// Won't render the application if WebApp is under a Clickjacking attack
if(window. self === window.top) { //main File
} else{
<div>
If you see this page,is under Clickjacking security attack.
</div>
}
Also tested the above code with the below HTML in WebPage (test.html)
<html>
<head>
<title>Clickjack vulnerability test page</title>
</head>
<body>
<iframe src="http://localhost:3000/" width="900" height="300"></iframe>
</body>
</html>
https://stackoverflow.com/questions/71734022
复制相似问题