当前位置:网站首页>网络安全-记录web漏洞修复
网络安全-记录web漏洞修复
2022-07-05 04:05:00 【孙霸天】
网络安全-记录web漏洞修复
背景介绍
最近政府部门都在组织网络系统安全检测,我们公司开发的某一个系统前端也被检出了漏洞,需要解决一下
前端使用vue框架开发,使用nginx进行部署
漏洞
如图所示总共被扫描出了八个漏洞,其中两个中度危险

解决问题
CORS信任任意来源漏洞
危害
可能造成用户信息被窃取,攻击者可以构造其他站点,通过跨域资源访问的形式,读取用户在本站点上的任意信息;
攻击者可以通过一连串的跨域资源访问请求,伪造用户的身份私自操作本站点的内容。
修复
漏洞未修复前,请求响应如下

这里是由于我nginx配置了允许跨域请求,默认nginx是不允许
错误配置如下
server {
listen 8071 ;
listen [::]:8071 ;
server_name test; # 这里是网站的域名
location / {
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
root E:/data/vue/zrzy; # /vue/dist/ 打包后的dist目录
try_files $uri $uri/ @router; # 指向下面的 @router否则会出现 404
index index.html index.htm;
}
# 对应上面的 @router,主要Vue请求并不是真实路径,无法找到文件,需要重定向到 index.html 中,然后交给路由处理
location @router {
rewrite ^.*$ /index.html last;
}
}
修改配置如下
server {
listen 8071 ;
listen [::]:8071 ;
server_name zrzyweb; # 这里是网站的域名
location / {
root E:/data/vue/zrzy; # /vue/dist/ 打包后的dist目录
try_files $uri $uri/ @router; # 指向下面的 @router否则会出现 404
index index.html index.htm;
}
# 对应上面的 @router,主要Vue请求并不是真实路径,无法找到文件,需要重定向到 index.html 中,然后交给路由处理
location @router {
rewrite ^.*$ /index.html last;
}
}
修改后如下

SourceMap文件泄露漏洞
危害
- 可能导致网站源代码泄露
- 可能导致敏感信息泄露
- 可能导致攻击者得到更多信息,扩大攻击者的攻击面

解决
这是因为我们在vue打包的时候,没有关闭SourceMap,一般SourceMap是在开发的时候方便程序员调试。
这里我们修改一下项目中的vue.config.js配置即可,添加 productionSourceMap: false。
module.exports = {
productionSourceMap: false,
}
修改后如下,我们打包部署就看不见源码了,都是混淆过的

Host头注入漏洞
危害
Host 头指的是 HTTP Header 中的 Host 项,在开发 WEB 应用时,为了方便的获得网站域名,开发人员可能会直接使用该值带入到应用上下文中,如果该值可以被攻击者控制,且 web server 没有对 host header 进行校验,则在部分攻击场景下可能导致用户信息泄露、XSS 等。

解决
在nginx的server中配置拦截策略,指定只有特定host才能访问
set $flag 0;
if ( $host = "192.168.1.249"){
set $flag 1;
}
if ( $flag = 0){
return 403;
}
HTTP响应头Server 泄露框架信息漏洞

危害
HTTP头部信息泄露,通常会导致网站的框架信息、编程语言、Web 容器等信息泄露
攻击者可以根据敏感信息对网站或服务器发起进一步攻击
解决
nginx的http中添加如下配置
server_tokens off;
响应头漏洞
危害
Web 服务器对于 HTTP 请求的响应头中缺少 { { detail.header_name }},这将导致浏览器提供的安全特性失效,更容易遭受 Web 前端黑客攻击的影响。

解决
server中添加
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection 1;

边栏推荐
- ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
- The new project Galaxy token just announced by coinlist is gal
- 10种寻址方式之间的区别
- 在线文本行固定长度填充工具
- On the day 25K joined Tencent, I cried
- 测试开发是什么?为什么现在那么多公司都要招聘测试开发?
- [C language] address book - dynamic and static implementation
- Use threejs to create geometry, dynamically add geometry, delete geometry, and add coordinate axes
- Redis之Jedis如何使用
- open graph协议
猜你喜欢

Containerization Foundation

Use of vscode software

面试汇总:这是一份全面&详细的Android面试指南

Threejs Internet of things, 3D visualization of farms (II)
![[wp][introduction] brush weak type questions](/img/d0/9eb3ade701057837d98e4a20082a10.png)
[wp][introduction] brush weak type questions

Ctfshow web entry code audit

【看完就懂系列】一文6000字教你从0到1实现接口自动化

Timing manager based on C #

Threejs factory model 3DMAX model obj+mtl format, source file download

Special Edition: spreadjs v15.1 vs spreadjs v15.0
随机推荐
Official announcement! The third cloud native programming challenge is officially launched!
It took two nights to get Wu Enda's machine learning course certificate from Stanford University
Redis source code analysis: redis cluster
Ctfshow web entry code audit
Operation flow of UE4 DMX and grandma2 onpc 3.1.2.5
Timing manager based on C #
IronXL for .NET 2022.6
Alibaba cloud ECS uses cloudfs4oss to mount OSS
Deflocculant aminoiodotide eye drops
基于TCP的移动端IM即时通讯开发仍然需要心跳保活
How to solve the problem that easycvr changes the recording storage path and does not generate recording files?
A应用唤醒B应该快速方法
Assembly - getting started
Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
How about programmers' eyesight| Daily anecdotes
[software reverse analysis tool] disassembly and decompilation tool
Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
Containerd series - what is containerd?
kubernetes集群之调度系统
English essential vocabulary 3400