当前位置:网站首页>网络安全-记录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;

边栏推荐
- Use threejs to create geometry, dynamically add geometry, delete geometry, and add coordinate axes
- Is "golden nine and silver ten" the best time to find a job? Not necessarily
- Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
- 反絮凝剂-氨碘肽滴眼液
- Why is there a reincarnation of 60 years instead of 120 years in the tiangan dizhi chronology
- kubernetes集群之调度系统
- Longyuan war "epidemic" 2021 network security competition web easyjaba
- IronXL for . NET 2022.6
- The development of mobile IM based on TCP still needs to keep the heartbeat alive
- C # use awaiter
猜你喜欢

Is "golden nine and silver ten" the best time to find a job? Not necessarily

An elegant program for Euclid‘s algorithm

Redis之Jedis如何使用

How to realize real-time audio and video chat function

Threejs realizes the drawing of the earth, geographical location annotation, longitude and latitude conversion of world coordinates threejs coordinates
![[wp]bmzclub writeup of several questions](/img/15/2838b93a605b09d3e2996f6067775c.png)
[wp]bmzclub writeup of several questions

线上故障突突突?如何紧急诊断、排查与恢复

It took two nights to get Wu Enda's machine learning course certificate from Stanford University

How is the entered query SQL statement executed?

kubernetes集群之调度系统
随机推荐
[数组]566. 重塑矩阵-简单
阿里云ECS使用cloudfs4oss挂载OSS
Interview byte, pass the exam and directly work on three sides. As a result, I found an architect to hang me?
长度为n的入栈顺序的可能出栈顺序种数
kubernetes集群之调度系统
Alibaba cloud ECS uses cloudfs4oss to mount OSS
[punch in questions] integrated daily 5-question sharing (phase III)
[PHP features - variable coverage] improper use, improper configuration and code logic vulnerability of the function
Operation flow of UE4 DMX and grandma2 onpc 3.1.2.5
北京程序员的真实一天!!!!!
面试汇总:这是一份全面&详细的Android面试指南
面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?
What is test development? Why do so many companies hire test developers now?
How to solve the problem that easycvr changes the recording storage path and does not generate recording files?
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
NEW:Devart dotConnect ADO.NET
Online text line fixed length fill tool
A real day for Beijing programmers!!!!!
The new project Galaxy token just announced by coinlist is gal
特殊版:SpreadJS v15.1 VS SpreadJS v15.0