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

边栏推荐
- MindFusion.Virtual Keyboard for WPF
- How to realize real-time audio and video chat function
- [wp][introduction] brush weak type questions
- 【看完就懂系列】一文6000字教你从0到1实现接口自动化
- lds链接的 顺序问题
- Differences among 10 addressing modes
- Interview summary: This is a comprehensive & detailed Android interview guide
- Clickpaas low code platform
- Is "golden nine and silver ten" the best time to find a job? Not necessarily
- Special Edition: spreadjs v15.1 vs spreadjs v15.0
猜你喜欢

error Couldn‘t find a package. JSON file in "your path“

About the recent experience of writing questions

Threejs rendering obj+mtl model source code, 3D factory model

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

MindFusion.Virtual Keyboard for WPF
![[wp][introduction] brush weak type questions](/img/d0/9eb3ade701057837d98e4a20082a10.png)
[wp][introduction] brush weak type questions

Wechat applet development process (with mind map)

Behavior perception system

Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery

The development of mobile IM based on TCP still needs to keep the heartbeat alive
随机推荐
Wechat applet development process (with mind map)
Rust区块琏开发——签名加密与私钥公钥
在线文本行固定长度填充工具
As soon as I write the code, President Wang talks with me about the pattern all day
Containerd series - detailed explanation of plugins
Enterprise level: spire Office for . NET:Platinum|7.7. x
A应用唤醒B应该快速方法
provide/inject
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
根据入栈顺序判断出栈顺序是否合理
The development of mobile IM based on TCP still needs to keep the heartbeat alive
About the recent experience of writing questions
lds链接的 顺序问题
[an Xun cup 2019] not file upload
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
Clickpaas low code platform
English essential vocabulary 3400
技术教程:如何利用EasyDSS将直播流推到七牛云?
UI automation test farewell to manual download of browser driver
Threejs rendering obj+mtl model source code, 3D factory model