当前位置:网站首页>XSS attack principle / classification / defense of Web Security
XSS attack principle / classification / defense of Web Security
2022-04-22 04:07:00 【foolBirdd】
What is? XSS attack ?
- Full name Cross-Site Scripting Cross-site scripting attacks , Abbreviation to avoid and CSS Conflict and change to XSS
- principle : By typing in the browser ( Like the comment bar 、 Search bar 、 Address bar, etc ) Inject script (JS、HTML Code block, etc ), Get the user's cookie、sessionID Etc , So as to destroy or steal website data .
Common injection methods
It may be a little hard to understand , No problem , Make an impression first , Just look at the following examples
The injected code is executable , To produce an effect
- stay HTML Embedded text , With script Label form injection
- In-line JS in , The spliced data breaks through the original limit ( character string 、 Variable 、 Method name, etc )
- In tag properties , Maliciously add quotation marks , Inject other attributes or tags
- On the label href、src And so on , add to JS Executable code
- stay onload、onerror、onclick And so on , Inject code
XSS Attack categories
reflective XSS
- Generally, it returns a constructed URL To server , Form an attack
- give an example
For example, the user submission form contains text Field :<script>alert(1)</script>
be URL by www.foolrBird.com?text=<script>alert(1)</script>
Then the browser will output 1
If you replace it with other destructive executable code, you can imagine
such as www.foolBird.com/delete The interface is to delete all data with one click
The user visited a malicious link www.foolBird.com/delete, And the server does not restrict user permissions , It directly causes the data to be deleted ( Is an authenticated user access link , So be trusted )
Storage type XSS( Or persistence XSS)
As soon as you hear the name, you know the harm is great , Stored in a database , Can continue to cause damage
- The attacker submits the malicious code to the database of the target website
- When users access , The server takes out the malicious code and splices it in HTML Return to the browser to execute
- Malicious code steals user data and sends it to the attacker's website ( Or pretend to be a user ), Call the target website interface for operation
- This method is the most harmful . It doesn't need to be triggered by users , Any website that allows users to store data may be attacked
DOM type XSS
- Trick the user into accessing the... Constructed by the attacker URL, Use the script to generate a DOM The node is inserted into the of the current website HTML In file , Form an attack . This is very similar to the reflex type , The only difference is the construction of URL Don't send to the server , You can get around WAF(Web Application Firewall, Website application level intrusion prevention system ) So as to avoid the purpose of server detection
If you want to know more about specific application scenarios, you can refer to [DOM-XSS Attack principle and defense ](DOM-XSS Attack principle and defense - Mysticbinary - Blog Garden (cnblogs.com))
XSS defense
Wherever data can be entered and submitted, there may be XSS dangerous
Commonly used
- HttpOnly: stay cookie After setting this property in ,JS Script ( such as document.cookie) Will not be able to read cookie, Can only be modified on the server side .
- The input filter : For example, ask for email 、 Telephone 、 Enter the user name in a fixed format . The front end and back end of this filter should do , Double insurance
- escape HTML: Pair of quotation marks 、 Angle brackets 、 Slash escape . It's best to choose the right Escape Library , More complete . for example xss library ,
npm i xss -SYou can install
Defensive storage and reflective
- Pure front end rendering , Separation of code and data
defense DOM type
Generally, because the front-end code is not rigorous enough , Treat untrusted data as code execution
-
multi-purpose innerText/textContent、setAtrribute etc.
- take innerHTML、outerHTML Replace with innerText/textContent, It will automatically HTML The tag is parsed into a normal file
-
Vue、React Don't use v-html/dangerouslySetInnerHTML
If it helps you , A great bai ~
Anyway, posting doesn't make money , Make a friend ~
If you want to reprint , Please indicate the source foolBirdd
版权声明
本文为[foolBirdd]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220405298803.html
边栏推荐
- MySQL Download
- 解决Flutter中ThemeData.primaryColor在AppBar等组件中不生效
- The WiFi button of win11 is missing and cannot be connected to the Internet
- RF and microwave design software
- sumo教程——公共交通教程
- Solution to write protection of WinXP U disk that cannot be copied
- 【近日力扣】验证二叉搜索树+将有序数组转换为二叉搜索树
- Exploring Presto SQL Engine (2) - Analysis of join
- Autodesk Genuine Service2020删除
- How do CDN acceleration and CDN defense operate to the server?
猜你喜欢

Nacos 为什么这么强
![[golang] force buckle leetcode - 657 Whether the robot can return to the origin (simulation)](/img/50/7e483e2d2761b60f05c3ae8a928137.png)
[golang] force buckle leetcode - 657 Whether the robot can return to the origin (simulation)

The WiFi button of win11 is missing and cannot be connected to the Internet

English | Day11, 12 x sentence true research daily sentence (meaning group)

机器学习系列(5)_特征工程03碳排放小案例

Go gin framework configuration log output to file

Mongodb - $project operation of aggregation pipeline

sumo-绕圈行驶

动态 | 悬镜安全研发管理体系通过CMMI3国际认证

【机器学习】长短时记忆网络(LSTM)
随机推荐
【近日力扣】重复的子字符串
js动态生成table表格,加滚动条
AI video cloud vs narrowband HD, who is the darling of the video era
网页性能优化
Ronglian Qimo empowers enterprises with intelligent services and redefines the value of customer service
Where is the whole house intelligence that Huawei, Haier Zhijia and Xiaomi are all doing?
Autodesk Genuine Service2020删除
Zhongtian steel holds "golden cup" in 18 products
Machine learning theory (6): from logistic regression (logarithmic probability) method to SVM; Why is SVM the maximum interval classifier
10-personalized top-N sequential recommendation via revolutionary sequence embedding
Mongodb - $project operation of aggregation pipeline
Addition, deletion, modification and query of Oracle connection database
Homogeneous nucleation of ice by lammps
Mysql中的Decimal类型是什么?
Data mining series (2)_ The data mining plug-in of Excel connects to SQL server
PowerDesiPowerDesigner导入sql 不显示表关联关系 怎么解决
如何在官网查看OracleJDK那个版本是否收费
为啥sqlmap能跑出库表跑不出字段
MySQL Download
SR-TE Policy(思科)----补充