View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0035967 | mantisbt | authentication | public | 2025-05-13 21:18 | 2025-11-01 07:49 |
| Reporter | harry.sintonen | Assigned To | dregad | ||
| Priority | urgent | Severity | major | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Target Version | 2.27.2 | Fixed in Version | 2.27.2 | ||
| Summary | 0035967: CVE-2025-47776: Authentication bypass for some passwords due to PHP type juggling | ||||
| Description | Due to incorrect use of "==" comparison in the authentication code [1], certain passwords will match others, and allow logging in without knowledge of the user's actual password. This is due to the PHP "type juggling", that is in effect when "==" is used instead of "===" for comparison. "If both operands are numeric strings, or one operand is a number and the other one is a numeric string, then the comparison is done numerically. These rules also apply to the switch statement. The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value." [2] Since == is incorrectly used in the authentication, certain MD5 hashes are actually interpreted as numbers. For this comparison to occur in a meaningful way for the attacker, a certain passwords would need to be used that evaluate to 0. For this to happen the MD5 hash must match scientific notation, in specific "<zerodigits>e<decimaldigits>". Here are some example passwords that evaluate to 0: 0e579603064547166083907005281618 - comito5 Note that there are zero digits, then 'e', followed by more decimal digits. When interpreted this always leads to value 0. Notably 0 == 0 comparison is true. Now, to be actually exploitable the victim user needs to use one of the passwords that evaluate to 0 when interpreted in scientific notation. To exploit these vulnerable passwords, the attacker needs to only know the usernames of the victims (which they can try to guess). The attacker can use any of the passwords that evaluate to 0, for example "comito5" (0). If the victim user has a password that is vulnerable the login succeeds. No password bruteforcing for individual users is needed, and thus g_max_failed_login_count does not protect against the attack. I have not calculated how many percent of passwords will hit these special values. The number is not very high, but isn't insignificant either. Whether individual password is affected or not can be checked by inspecting the MD5 hash it results to. If it matches the pattern described above, the password is vulnerable. Fixing this vulnerability is easy: use "===" in the comparison. [1] https://github.com/mantisbt/mantisbt/blob/0fb502dd613991e892ed2224ac5ea3e40ba632bc/core/authentication_api.php#L782 | ||||
| Steps To Reproduce |
| ||||
| Additional Information | This vulnerability is present since the introduction of MD5 login method in MantisBT 0.15.8 (October 2001). | ||||
| Tags | No tags attached. | ||||
|
Many thanks @harry.sintonen for the detailed report. I confirm the vulnerability, and opened Security Advisory GHSA-4v8w-gg5j-ph37. A CVE has been requested. Please let me know your GitHub user ID, and tell me how you would like to be credited you for the finding. |
|
|
Github: https://github.com/piru |
|
|
CVE-2025-47776 assigned. |
|
|
MantisBT: master-2.27 966554a1 2025-05-14 12:39 Details Diff |
Check password with strict string comparison Due to an incorrect use of loose instead of strict comparison in the authentication code, PHP type juggling will cause interpretation of certain MD5 hashes as numbers, specifically those matching scientific notation. On MantisBT instances configured to use the MD5 login method, user accounts having a password hash evaluating to zero (i.e. matching regex `^0+[Ee][0-9]+$`) are vulnerable, allowing an attacker knowing the victim's username to login without knowledge of their actual password, using any other password having a hash evaluating to zero, for example comito5 (0e579603064547166083907005281618). Fixes 0035967, CVE-2025-47776, GHSA-4v8w-gg5j-ph37 |
Affected Issues 0035967 |
|
| mod - core/authentication_api.php | Diff File | ||