当前位置:网站首页>An example of CSRF attack defense in web application scenarios
An example of CSRF attack defense in web application scenarios
2022-06-13 07:08:00 【guangsu.】
Cross-site request forgery
CSRF(Cross-site request forgery)
The attacker stole your identity , Send malicious requests in your name
Attack mode : To complete once CSRF attack , The victim must complete two steps in turn
- Log in to trusted sites A, And build locally Cookie.
- At no logout site A Under the circumstances , Visit the danger website B. Site B It contains fake sites that can be requested A Malicious request , You can use A Cached in the browser
cookie
.
Attack instance
Attack scenario
In the original Alice It's the victim , She uses a bank website http://unsafe/
There is session fixation
Loophole ,Mallory
It's the attacker , He wants to steal Alice
A deposit in a bank , and Alice
Will click Mallory
Send her a web link ( The reason might be Alice know Mallory, Or her own safety awareness is not strong ).
Attack steps :
Hacker:Mallory
visithttp://unsafe/
And get a sessionID(session_id)
, For example, the form returned by the server is :Set-Cookie: session_id=0D6441FEA4496C2
Hacker:Mallory
touser:Alice
Sent an email :“ We have launched a new service , For the first experience, please click :http://unsafe/?SID=0D6441FEA4496C2
”user:Alice
Click and log in .- Because the server's session ID Don't change , Now?
Hacker:Mallory
Click onhttp://unsafe/?session_id= I_WILL_KNOW_THE_SID
after , He hasuser:Alice
The identity of the . You can do whatever you want .
defense :
The application automatically generates a for each active user's session CSRF「 token 」
. This token is used to verify Authenticated users
Whether it is The user who made the request to the application
.
No matter when , When you define HTML
On form , Should include a hidden... In the form CSRF
Tag field , So that the server CSRF Filters can validate the form CSRF Whether the token is connected to the session session_id
Same token stored in , Even if the form is forged in advance in the email and your identity certificate is stolen session_id
. But he can't forge a random CSRF token
. So it can effectively prevent the above situation . Unless your terminal is completely hijacked .
According to the above example , There are two key considerations in the development process :
- After successful login, you need to update session_id, verification session_id Whether the format is legal or not .
- When receiving sensitive operation , You don't just have to verify your credentials , Also verify
Authenticated users
Whether it isThe user who made the request to the application
. otherwisesession_id
Exposure means that the login permission is completely exposed .
Other scenes
Attack scenario 1: The most simple : The server receives any session ID. The process is as follows :
Hacker:Mallory
Find outhttp://unsafe/
Receive any session ID, And conversation ID adopt URL The query parameters of the address are carried to the server , The server does not checkHacker:Mallory
toUser:Alice
Send an email , He may pretend that the bank is promoting his new business , for example ,“ We have launched a new service , For the first experience, please click :http://unsafe/?SID= I_WILL_KNOW_THE_SID, I_WILL_KNOW_THE_SID
yesHacker:Mallory
A selected session ID.User:Alice
Attracted to , Click.http://unsafe/?SID= I_WILL_KNOW_THE_SID
, As usual , Enter your account number and password to log in to the bank website .- Because the server's session ID Don't change , Now?
Hacker:Mallory
Click onhttp://unsafe/?SID= I_WILL_KNOW_THE_SID
after , He hasUser:Alice
The identity of the . You can do whatever you want .
Attack scenarios 2: cross-site cookie(cross-site cooking). Exploit browser vulnerabilities , Even if http://good
Very safe , however , Due to browser Management cookie
A loophole in the ,
Make malicious websites http://evil/
Be able to send... To the browser http://good
Of cookie`. The process is as follows :
Hacker:Mallory
toUser:Alice
Send an email " There is an interesting website :http://evil
It's fun , Might as well try. "User:Alice
Visited this link , This site will have a conversation ID The value isI_WILL_KNOW_THE_SID
Ofhttp://good/
Domaincookie
Set to browser .Hacker:Mallory
Give againUser:Alice
Sent an email :“ We have launched a new service , For the first experience, please click :http://good/
”- If
User:Alice
Log on to the ,Hacker:Mallory
You can use this ID 了
边栏推荐
- 微隔离(MSG)
- Introduction and use of dumping
- The innovative public platoon mode team invites users to split, beautiful every second, and links the 2+1 new business model
- [cloud native | kubernetes] kubernetes configuration
- 【RS-422与RS-485】RS-422与RS-485串行接口标准
- Soup side (8)
- Database connection under WinForm
- Tidb implementation plan -- I
- [weak transient signal detection] matlab simulation of SVM detection method for weak transient signal under chaotic background
- How to make a development board from scratch? Illustrated and illustrated, step by step operation for you to see.
猜你喜欢
RT-Thread 模拟器 simulator LVGL控件:slider 控件
Why is the new e-commerce outlet mode so popular? What is the specific mode?
RT thread simulator lvgl control: button button style
June 12, 2022: if there are n*n pieces in an n*n square chessboard, each grid can have exactly one piece. But now some pieces are gathered on a grid, such as 2030100300. The above two-dimensional arra
Why is the blind box e-commerce mode so popular?
基于SSM实现水果商城批发平台
What is online blind box e-commerce? Can blind box e-commerce become a new bonus market for the Internet?
RT thread simulator lvgl control: switch switch button control
数字时代进化论
RT thread simulator lvgl control: slider control
随机推荐
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
C drawing table and sending mail function
Why is the blind box e-commerce mode so popular?
Raspberry school advanced development - "writing of IO port driver code" includes bus address, physical \u virtual address and bcm2835 chip manual knowledge
Detailed Mr Atlas of hip joint (Reprinted)
Tidb data migration (DM) Introduction
Implementation of fruit mall wholesale platform based on SSM
Tidb implementation plan -- I
Make cer/pfx public and private key certificates and export CFCA application certificates
杭州网上开户是安全的吗?
Tikv key performance parameters and optimization
10 Honest Facts I Want To Share With All Junior Developers
Project analysis of Taishan crowdfunding mode: why is Taishan crowdfunding mode so popular?
尝试使用RenderDoc查看UE的Shader代码
Periodontitis investigation (ongoing)
Upper computer development (code debugging of firmware download software)
WWDC2022最大的亮点: MetalFX
Eureka server multi node deployment
FSM state machine
RT thread simulator lvgl control: button button style