View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0019381 | mantisbt | security | public | 2015-02-18 09:26 | 2025-01-29 11:48 |
Reporter | plmaltais | Assigned To | dregad | ||
Priority | high | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.19 | ||||
Target Version | 2.26.1 | Fixed in Version | 2.26.1 | ||
Summary | 0019381: CVE-2024-23830: Host header attack vulnerability | ||||
Description | Advisory: MantisBT 1.2.19 - Host header attack vulnerability Vulnerability Description:MantisBT 1.2.19 is vulnerable to an Host header attack that can Technical Details:This exploit use the Host header attack to poison the link in the
Solution:Use Disclosure Timeline:16/02/2015 - Found the vulnerability References:[1] http://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html | ||||
Additional Information | I would like to be credited for the finding. | ||||
Tags | No tags attached. | ||||
Attached Files | mantis_1.2.19_host_header_attack.txt (2,433 bytes)
Advisory: MantisBT 1.2.19 - Host header attack vulnerability Author: Pier-Luc Maltais Affected Software: MantisBT 1.2.19 Vendor URL: https://www.mantisbt.org/ ========================== Vulnerability Description: ========================== MantisBT 1.2.19 is vulnerable to an Host header attack that can be exploited by an unauthenticated user to hijack another user account. ================== Technical Details: ================== This exploit use the Host header attack to poison the link in the password reset mail. You need to know the victim username and e-mail. You also need a remote host that you control to catch the verification hash needed for password reset. 1. Access the password reset feature and fill the form with the victim username and e-mail. http://{VULNERABLE_MANTIS}/mantisbt/lost_pwd_page.php 2. Using an intercepting proxy like Burp, change the Host header with your evil host. Original request : POST /mantisbt/lost_pwd_page.php HTTP/1.1 Host : {VULNERABLE_MANTIS} [...] Modified request : POST /mantisbt/lost_pwd_page.php HTTP/1.1 Host : evil.com [...] 3. When the user receive the e-mail, the link is poisoned with the evil host. [...] visit the following URL to change your password: http://evil.com/mantisbt/verify.php?id=1&confirm_hash=81ece020dfcd6d53e02c5323583cdead [...] 4. Now, when the victim click on the link to reset his password, his verification hash will be sent to our evil host. All we have to do is access the verify.php page with his hash, so we can change his password and hijack his account. http://{VULNERABLE_MANTIS}/mantisbt/verify.php?id=1&confirm_hash=81ece020dfcd6d53e02c5323583cdead ========= Solution: ========= Use $_SERVER['SERVER_NAME'] (server controlled) instead of $_SERVER['HTTP_HOST'] (client controlled) ==================== Disclosure Timeline: ==================== 16/02/2015 - Found the vulnerability 17/02/2015 - Wrote this advisory 17/02/2015 - Contacted developers on MantisBT forum 18/02/2015 - Opened an issue in the bug tracker =========== References: =========== [1] http://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html [2] http://stackoverflow.com/questions/2297403/http-host-vs-server-name/2297421#2297421 | ||||
has duplicate | 0026434 | closed | dregad | Use of _SERVER['HTTP_HOST'], _SERVER['SERVER_NAME'], and _SERVER['HTTP_X_FORWARDED_HOST'] should be avoided |
related to | 0033791 | closed | dregad | Travis CI builds are timing out |
related to | 0035261 | closed | dregad | Checking URL to installation: BAD Web page at 'https://www.foo.net/bar/mantisbt/' does not appear to be a MantisBT site. |
Hello Many thanks for the detailed bug report. I will look into it and let you know when a fix is available for testing. Have you reserved a CVE for this, or should I do it ? |
|
Hi, No, I didn't reserve a CVE, you can do it. Let me know if you have any questions. Pier-Luc |
|
I just had a quick look at the code, and I reckon this vulnerability would only affect MantisBT instances relying on the default mechanism to determine the server path [1]. I'm not so keen on using SERVER_NAME only as that may not work in all situations since it is dependent on the web server's setup. Maybe a better approach would be to get rid of the unsafe use of HTTP_HOST in the detection mechanism or trigger a warning if it's being used, and let the admin set the (canonical) path in config_inc.php. Another option would be to introduce a new setting to validate the path (similar to what Drupal did), but maybe that's overkill. I need to think some more about this. [1] https://github.com/mantisbt/mantisbt/blob/master/config_defaults_inc.php#L176 |
|
Reminder sent to: atrol, rombert, vboctor Your thoughts on this would be appreciated. |
|
No time for tests, thus just some thoughts. We could completely remove access of $_SERVER['HTTP_HOST'] in master 1.3.x, and wait for
Furthermore we would have to describe the configuration of the web server in this case and Not sure if we could do the same for 1.2.x and risk breaking existing installations. Every kind of potentially breaking change would have to be described in installation/upgrade BTW, I found that the code block in master starting with |
|
If the MantisBT host is compromised, why would the evil code just go change the database rather than this round about way? Am I missing something? |
|
The MantisBT host is not compromised. The issue is that we rely on the client-provided HTTP_HOST to build $g_path, allowing an attacker to initiate a password reset process for any user for which they know the id and password, and by inserting "evil.com" instead of "mantisbt.org", the e-mail we send to the user will point them back to "evil.com" thus letting the attacker retrieve the verification key and using it to hijack the user's account. Obviously this requires the user to actually click the link without verifying it. Thanks for your feedback. Your suggestion goes along the lines of what I was thinking. Good catch also with the dead code block. @Pier-Luc You mentioned a blog in your forum post [1], does that need to be referenced in the CVE ? If so please provide the URL. One more question, about the use of HTTP_X_FORWARDED_HOST - I have not actually tested this, but would assume that this can be spoofed in the same way you described above, right ? [1] https://www.mantisbt.org/forums/viewtopic.php?f=2&t=22938 |
|
I did a quick test on my installation, without actually using a proxy. I added the X-Forwarded-Host header line in the request : POST /mantisbt/lost_pwd.php HTTP/1.1 and the link was poisonned with evil.com. For the blog, you can provide this URL: plmsecurity.net (there is nothing on there yet). |
|
Hi, I just want to remind you that we are two weeks from my 3 months deadline. Did you guys have planned a patch for this issue? |
|
Thanks for the reminder, this kind of fell off the radar... |
|
We reach the deadline. Please tell me if you have something planned. |
|
Well I have a potential patch but did not fully test it yet (sorry, I do this in my spare time, and I unfortunately don't have much of that nowadays). We need to consider backwards compatibility before releasing anything, which makes fixing this not so trivial. If I may make a comment, it would have been nice(r) to announce this deadline of yours up front. That being said, what are your plans moving forward - assuming we're not able to release a fix shortly ? |
|
I was clear with the 90 days deadline on my original post on the forum (https://www.mantisbt.org/forums/viewtopic.php?f=2&t=22938), but maybe I should have stated it here too. I really don't want to go full disclosure. If I give you two more weeks, will you be able to release a patch? If not, I will relase the advisory on my blog, post it on exploit-db, share it on twitter, etc. This vulnerability put your users informations at risk and it is your responsability to mitigate that risk, even if it's done in your spare time. |
|
Indeed.
I know damn well what my responsibilities are. For the record, it is also my responsibility to take care of my family, and do the job my employer pays me for. It's all a question of priorities... Using open-source software implies accepting some risks, and an unpatched vulnerability is one of them. That being said and despite appearances, I do take security issues very seriously, and will do my best to get this patch out within 2 weeks. Will let you know when the patch is ready so you can confirm whether it actually fixes the issue or not before I release it to the general public. |
|
GitHub security advisory: https://github.com/mantisbt/mantisbt/security/advisories/GHSA-mcqj-7p29-9528 CVE-2024-23830 assigned on 29-Jan-2024. |
|
Patch is available for review at https://github.com/mantisbt/mantisbt-ghsa-mcqj-7p29-9528/pull/1 Feedback welcome. Please get in touch with me if you have problems accessing. |
|
@dregad as an additional enhancement (must not be part of this fix), should we write $g_path and $g_short_path to config_inc.php when running a new installation? |
|
That's an idea. I suppose you mean to achieve that by requesting the path to use at install time, with a proposed default value based on the logic I moved from config_defaults_inc.php to set_default_path() function in core.php ? |
|
Exactly like that. |
|
@atrol please review https://github.com/mantisbt/mantisbt-ghsa-mcqj-7p29-9528/pull/2 which implements your suggestion 0019381:0068521 |
|
Pull requests from temporary fork have been merged, and the advisory published |
|
MantisBT: master-2.26 7055731d 2024-02-20 16:10 Committer: community Details Diff |
Merge pull request from GHSA-mcqj-7p29-9528 * Address host header injection vulnerability $g_path is empty by default, and should be defined in config_inc.php. Not doing so is a security risk, as the path will then be set based on headers from the HTTP request, exposing the system to Host Header injection attacks. Document the risk in PHPDoc and Admin Guide. Move the code that initializes $g_path's default value from config_defaults_inc.php to a function in core.php. Detect if $g_path was defaulted, and if yes alert the user in: - Login Page (if $g_admin_checks == ON) - Admin Checks Fixes 0019381, CVE-2024-23830, GHSA-mcqj-7p29-9528 * Remove dead code * Use OWASP as reference for host header injection * Link to OWASP reference page from admin guide * Invalid $g_path at install time is a hard fail Empty $g_path remains just a warning about the security risk. Request and set $g_path at install time This is an improvement on the original patch for CVE-2024-23830. The admin is now able to set $g_path when installing MantisBT. A default value is provided, based on the URL used to perform the installation (using the same logic that is applied when $g_path is empty). A check of the provided URL is performed during install stage 2, and an error is reported if it is invalid. If an empty $g_path is given, then we only display a warning about the security risk. The URL is then stored as $g_path in the generated config_inc.php file at stage 5. This greatly reduces the risk of the admin forgetting to set $g_path manually, while still allowing them to set it to empty should they want to. Fixes 0019381 * Add Reset button to path input Reuse the existing functionality implemented for database prefix/suffix, with the following changes - Rename `reset-prefix` selector class to `reset` to be more generic - Add Reset functionality markup to path input including default value - Add title attribute to Reset buttons - Adapt initialization logic to only set the default value for the table-prefix fields |
Affected Issues 0019381 |
|
mod - admin/check/check_paths_inc.php | Diff File | ||
mod - admin/install.php | Diff File | ||
mod - config_defaults_inc.php | Diff File | ||
mod - core.php | Diff File | ||
mod - docbook/Admin_Guide/en-US/config/path.xml | Diff File | ||
mod - js/install.js | Diff File | ||
mod - lang/strings_english.txt | Diff File | ||
mod - login_page.php | Diff File |