当前位置:网站首页>Network security - record web vulnerability fixes
Network security - record web vulnerability fixes
2022-07-05 04:09:00 【Sun batian】
Network security - Record web Bug repair
Background introduction
Recently, government departments are organizing network system security testing , Vulnerabilities have also been detected in the front end of a system developed by our company , It needs to be solved
Front end use vue Framework development , Use nginx Deployment
Loophole
As shown in the figure, a total of eight vulnerabilities have been scanned , Two of them are moderately dangerous

solve the problem
CORS Trust any source vulnerability
harm
It may cause user information to be stolen , Attackers can construct other sites , Through the form of cross domain resource access , Read any information of users on this site ;
Attackers can access requests through a series of cross domain resources , Forge the user's identity and privately operate the content of this site .
Repair
Before the vulnerability is fixed , The request response is as follows

This is because of me nginx It is configured to allow cross domain requests , Default nginx It's not allowed
The error configuration is as follows
server {
listen 8071 ;
listen [::]:8071 ;
server_name test; # Here is the domain name of the website
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/ After packaging dist Catalog
try_files $uri $uri/ @router; # Point below @router Otherwise 404
index index.html index.htm;
}
# Corresponding to the above @router, The main Vue The request is not a real path , Can't find file , Need to redirect to index.html in , Then it is handed over to the routing processing
location @router {
rewrite ^.*$ /index.html last;
}
}
Modify the configuration as follows
server {
listen 8071 ;
listen [::]:8071 ;
server_name zrzyweb; # Here is the domain name of the website
location / {
root E:/data/vue/zrzy; # /vue/dist/ After packaging dist Catalog
try_files $uri $uri/ @router; # Point below @router Otherwise 404
index index.html index.htm;
}
# Corresponding to the above @router, The main Vue The request is not a real path , Can't find file , Need to redirect to index.html in , Then it is handed over to the routing processing
location @router {
rewrite ^.*$ /index.html last;
}
}
Revised as follows

SourceMap File leaks
harm
- It may cause the source code of the website to be leaked
- Could lead to the disclosure of sensitive information
- It may cause the attacker to get more information , Expand the attacker's attack surface

solve
This is because we are vue When packing , Not closing SourceMap, commonly SourceMap It is convenient for programmers to debug when developing .
Here we modify the vue.config.js The configuration can be , add to productionSourceMap: false.
module.exports = {
productionSourceMap: false,
}
Revised as follows , We can't see the source code when we pack and deploy , Are confused

Host Head injection vulnerability
harm
Host The head refers to HTTP Header Medium Host term , Developing WEB When applied , In order to get the website domain name conveniently , Developers may directly use this value to bring it into the application context , If this value can be controlled by an attacker , And web server No, right host header check , In some attack scenarios, user information may be leaked 、XSS etc. .

solve
stay nginx Of server Configure the interception policy , Specify only specific host Ability to visit
set $flag 0;
if ( $host = "192.168.1.249"){
set $flag 1;
}
if ( $flag = 0){
return 403;
}
HTTP Response head Server Leak frame information

harm
HTTP Header information disclosure , It usually leads to the frame information of the website 、 programing language 、Web Containers and other information leaked
Attackers can launch further attacks on websites or servers based on sensitive information
solve
nginx Of http Add the following configuration
server_tokens off;
Response header vulnerability
harm
Web Server for HTTP Missing... In the response header of the request { { detail.header_name }}, This will invalidate the security features provided by the browser , More vulnerable to Web The impact of front-end hacker attacks .

solve
server Add
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection 1;

边栏推荐
- 【刷题】BFS题目精选
- Possible stack order of stack order with length n
- EasyCVR更改录像存储路径,不生成录像文件如何解决?
- MacBook安装postgreSQL+postgis
- [phantom engine UE] realize the animation production of mapping tripod deployment
- MySQL: view with subquery in the from clause limit
- 25K 入职腾讯的那天,我特么哭了
- Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
- 【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
- [untitled]
猜你喜欢

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

Realize the attention function of the article in the applet

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

阿里云ECS使用cloudfs4oss挂载OSS

Uni app common functions /api

Official announcement! The third cloud native programming challenge is officially launched!

北京程序员的真实一天!!!!!

MindFusion. Virtual Keyboard for WPF

Pyqt pyside custom telescopic menu bar sharing (including tutorial)

“金九银十”是找工作的最佳时期吗?那倒未必
随机推荐
Scheduling system of kubernetes cluster
Open graph protocol
The new project Galaxy token just announced by coinlist is gal
Use object composition in preference to class inheritance
NEW:Devart dotConnect ADO. NET
Use threejs to create geometry and add materials, lights, shadows, animations, and axes
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
北京程序员的真实一天!!!!!
【虚幻引擎UE】实现测绘三脚架展开动画制作
Containerd series - what is containerd?
Phpmailer reported an error: SMTP error: failed to connect to server: (0)
[array]566 Reshape the matrix - simple
[wp][introduction] brush weak type questions
Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
[数组]566. 重塑矩阵-简单
长度为n的入栈顺序的可能出栈顺序
线上故障突突突?如何紧急诊断、排查与恢复
快手、抖音、视频号交战内容付费
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
Bit operation skills