当前位置:网站首页>Web Security
Web Security
2022-07-05 10:47:00 【Code Bruce Lee】
web Security
Preface
The following is a summary of the common security common sense of the front end , It's also a must ask question in an interview . There is no big technical content , But you need to know . We are in our own application development , We also need to avoid such low-level problems .
sql Inject
describe
That is, the back end relies on the parameters returned by the front end to splice directly sql Query data , Lead to sql Abnormal splicing , Security problems caused by .
Solution
Verify the information transmitted by the front end layer by layer , Don't use .
remarks : From here to , In fact, any front-end data transmission may be risky 、 Not rigorous , Therefore, any interface at the back end must carry out illegal verification for the passed parameters , Business verification , Then you can actually use .
XSS(Cross Site Scripting, Cross-site scripting attacks )
describe
Simply put, it is to inject into your code in some way js Code , The most common is through the submission of forms . Then because these codes have the same permissions as your code , So you can access your data information , You can also report some data . therefore , The harm is great .
Solution
Replace some of the input :
& Replace with :&
< Replace with :<
Replace with :>
” Replace with :"
‘ Replace with :’
/ Replace with :/
In addition, targeted right cookie Strengthen control , Set up http-only, such js You can't get it cookie The content of .
however , For rich text content , Simple text substitution does not solve the problem , Can pass csp How to solve , That is to establish a white list .
Set up HTTP Header Medium Content-Security-Policy
Set up meta How to label
If it is http,header Words , The setting can be like this :Content-Security-Policy: default-src ‘self’, In this way, only the resources of this website are allowed .
CSRF(Cross-site request forgery, Cross-site request forgery )
describe
CSRF It is to use the authority of the current operator to complete an operation secretly , Instead of getting the user's information .
Its principle is :cookie The same origin strategy , Just log in , The request of the same domain name does not need to be verified by the user .
Solution
For the operations that need to be verified , Set up additional validation , For example, verification code 、 password 、 Fingerprints, etc ;
get Request changed to post request , More secure ; Give Way get Request more only for read operations ;
verification document.referer, Determine the source of the previous page of the web page , Wechat payment has this verification mechanism ;
token Timeliness mechanism , When performing an operation , Send a timely token, When performing a subsequent operation , verification token Are they the same? ;
Verify the network ip, Because if the request is initiated by a non local device , that ip It will also be compared with the original ip Is different , adopt ip The comparison of can also remove unsafe factors .
Web nesting attack
describe
adopt iframe Nested web pages , Then design nested transparency , Click through the interface , Trigger your own event .
Solution
The first one is : header Setting does not allow nesting
X-FRAME-OPTIONS It's a HTTP Response head , In modern browsers have a very good support . This HTTP Response head Defense is to use iframe Nested clickjacking attacks .
The three values in response to the first alternative , Namely
DENY, It indicates that the page is not permitted iframe Fashion show
SAMEORIGIN, Indicate that the page can be under the same domain name iframe Fashion show
ALLOW-FROM, Indicate that the page can specify the source of iframe Show in
The second kind : We can do it by simple js This problem can be solved by judging whether the current interface is a top-level window .
if(top.location!=self.location){
top.location.href = window.location.href;
}else{
alert(“ It's the top window ”);
}
Man-in-the-middle attack
describe
That is, the request is blocked , Then it may be rewritten , Or be extracted important information , Continue to request
Solution
Simple and effective : upgrade https programme
边栏推荐
- 双向RNN与堆叠的双向RNN
- Nine degrees 1480: maximum ascending subsequence sum (dynamic programming idea for the maximum value)
- 基于昇腾AI丨爱笔智能推出银行网点数字化解决方案,实现从总部到网点的信息数字化全覆盖
- Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
- SqlServer定时备份数据库和定时杀死数据库死锁解决
- A usage example that can be compatible with various database transactions
- 想请教一下,十大券商有哪些?在线开户是安全么?
- Node の MongoDB Driver
- 埋点111
- web安全
猜你喜欢
DGL中的消息传递相关内容的讲解
[vite] 1371 - develop vite plug-ins by hand
2022年危险化学品经营单位主要负责人特种作业证考试题库及答案
SAP ui5 objectpagelayout control usage sharing
【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
"Everyday Mathematics" serial 58: February 27
基于昇腾AI丨爱笔智能推出银行网点数字化解决方案,实现从总部到网点的信息数字化全覆盖
The first product of Sepp power battery was officially launched
AtCoder Beginner Contest 258「ABCDEFG」
微信核酸检测预约小程序系统毕业设计毕设(6)开题答辩PPT
随机推荐
跨页面通讯
磨礪·聚變|知道創宇移動端官網煥新上線,開啟數字安全之旅!
微信核酸检测预约小程序系统毕业设计毕设(6)开题答辩PPT
脚手架开发基础
Comparative learning in the period of "arms race"
MFC宠物商店信息管理系统
Implementation of wechat applet bottom loading and pull-down refresh
Qt实现json解析
LSTM应用于MNIST数据集分类(与CNN做对比)
SAP UI5 ObjectPageLayout 控件使用方法分享
【观察】跨境电商“独立站”模式崛起,如何抓住下一个红利爆发时代?
Completion report of communication software development and Application
Based on shengteng AI Aibi intelligence, we launched a digital solution for bank outlets to achieve full digital coverage of information from headquarters to outlets
Go语言-1-开发环境配置
GO项目实战 — Gorm格式化时间字段
Go项目实战—参数绑定,类型转换
"Everyday Mathematics" serial 58: February 27
Customize the left sliding button in the line in the applet, which is similar to the QQ and Wx message interface
Use bat command to launch common browsers with one click
【黑马早报】罗永浩回应调侃东方甄选;董卿丈夫密春雷被执行超7亿;吉利正式收购魅族;华为发布问界M7;豆瓣为周杰伦专辑提前开分道歉...