Skip to content

Latest commit

 

History

History

lab07

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

跨站点请求伪造(CSRF)安全实验

操作方式

1. 安装Firefox浏览器和NoRedirect Add on for Firefox

http://localhost:8080加入NoRedirect设置的规则列表,选中来源,并将该规则置顶。

2. 启动授权服务器state-oauth2server,端口8080

3. 启动Web客户端应用state-client,端口9000

4. 使用Firefox浏览器获取授权码

使用黑客账号attacker/xyz进行登录认证,注意请求不带state

http://localhost:8080/oauth/authorize?client_id=clientapp&redirect_uri=http
://localhost:9000/resource&response_type=code&scope=read+write

获取授权码返回链接被NoRedirect截获,复制该链接

http://localhost:9000/resource?code=So3A96

5. 使用Chrome浏览器登录http://loalhost:9000

使用正常用户账号bobo/xyz进行登录认证

在浏览器地址栏粘贴上面复制的授权码返回链接,并请求,Spring Security OAuth2 client会进行state校验并报错:

Possible CSRF detected - state parameter was required but no state could be found