当前位置:网站首页>网络安全-记录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;
边栏推荐
- 优先使用对象组合,而不是类继承
- provide/inject
- NEW:Devart dotConnect ADO. NET
- 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?
- Rust blockchain development - signature encryption and private key public key
- Deep learning - LSTM Foundation
- 在线文本行固定长度填充工具
- Deflocculant aminoiodotide eye drops
- Containerd series - detailed explanation of plugins
- 线上故障突突突?如何紧急诊断、排查与恢复
猜你喜欢
How is the entered query SQL statement executed?
Use threejs to create geometry, dynamically add geometry, delete geometry, and add coordinate axes
Pyqt5 displays file names and pictures
测试开发是什么?为什么现在那么多公司都要招聘测试开发?
Uni app change the default component style
Threejs factory model 3DMAX model obj+mtl format, source file download
ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 2)
NEW:Devart dotConnect ADO.NET
How about programmers' eyesight| Daily anecdotes
An elegant program for Euclid‘s algorithm
随机推荐
[software reverse - basic knowledge] analysis method, assembly instruction architecture
[an Xun cup 2019] not file upload
Use threejs to create geometry, dynamically add geometry, delete geometry, and add coordinate axes
UI automation test farewell to manual download of browser driver
Use object composition in preference to class inheritance
Longyuan war "epidemic" 2021 network security competition web easyjaba
Interview byte, pass the exam and directly work on three sides. As a result, I found an architect to hang me?
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
Uni app common functions /api
Containerization Foundation
陇原战“疫“2021网络安全大赛 Web EasyJaba
How to solve the problem that easycvr changes the recording storage path and does not generate recording files?
反絮凝剂-氨碘肽滴眼液
On the day 25K joined Tencent, I cried
[understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
NEW:Devart dotConnect ADO.NET
Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
长度为n的入栈顺序的可能出栈顺序
The development of mobile IM based on TCP still needs to keep the heartbeat alive
laravel8 导出Excle文件