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

边栏推荐
- 基于TCP的移动端IM即时通讯开发仍然需要心跳保活
- JWT vulnerability recurrence
- [untitled]
- ClickPaaS低代码平台
- Web components series (VII) -- life cycle of custom components
- Containerd series - detailed explanation of plugins
- 陇原战“疫“2021网络安全大赛 Web EasyJaba
- Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
- [software reverse - basic knowledge] analysis method, assembly instruction architecture
- WGS84 coordinate system, web Mercator, gcj02 coordinate system, bd09 coordinate system - brief introduction to common coordinate systems
猜你喜欢
随机推荐
[charging station]_ Secular wisdom_ Philosophical wisdom _
优先使用对象组合,而不是类继承
How to realize real-time audio and video chat function
[wp]bmzclub writeup of several questions
阿里云ECS使用cloudfs4oss挂载OSS
Uni app change the default component style
Use object composition in preference to class inheritance
What is test development? Why do so many companies hire test developers now?
Threejs Internet of things, 3D visualization of factory
【看完就懂系列】一文6000字教你从0到1实现接口自动化
DFS and BFS concepts of trees and graphs
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
反絮凝剂-氨碘肽滴眼液
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
Phpmailer reported an error: SMTP error: failed to connect to server: (0)
Nmap user manual learning records
Pyqt pyside custom telescopic menu bar sharing (including tutorial)
ClickPaaS低代码平台
MindFusion.Virtual Keyboard for WPF
As soon as I write the code, President Wang talks with me about the pattern all day



![[untitled]](/img/e0/52467a7d7604c1ab77038c25608811.png)





