View Issue Details

IDProjectCategoryView StatusLast Update
0020359mantisbtsecuritypublic2026-11-22 16:08
Reporteratrol Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3.0-rc.1 
Target Version2.29.0Fixed in Version2.29.0 
Summary0020359: Running admin/check/index.php is possible without log in
Description

Running admin/index.php is prevented for non administrative users by access_ensure_global_level( config_get_global( 'admin_site_threshold' ) );

However admin/check/index.php can be accessed by everyone without being logged in. and gives some output that just administrators should have access to.

Of course, we recommend to remove the admin folder and there is a warning for it (as long as $g_admin_checks is not set to OFF)

Anyway I think we should add at least access_ensure_global_level( config_get_global( 'admin_site_threshold' )
Our own server is also affected at the moment.

TagsNo tags attached.

Activities

dregad

dregad

2015-12-08 03:33

developer   ~0052070

we should add at least access_ensure_global_level( config_get_global( 'admin_site_threshold' )

I agree.

With regards to our site being affected, @vboctor probably forgot to remove the admin folder after upgrading to rc1. I'll fix it.

dregad

dregad

2015-12-10 18:49

developer   ~0052099

After initial research, we can't simply call access_ensure_global_level() because that requires access to the database (to retrieve the user's cookie in auth_get_current_user_id()).

I can think of 2 ways to fix this

  1. set $g_cache_current_user_id = 0

Since 0 !== null, auth_get_current_user_id() will return the "cached" value without trying to access the DB. The issue with this approach is that it does not display the "Access Denied" message, but redirects directly to the default page instead (because the user '0' is rightly not considered to be authenticated). Maybe not a big issue, but not consistent with the usual behavior of the system.

This is a very small change, affecting only admin/check/index.php, but it's a bit of a hack.

  1. Make auth_get_current_user_id() and access_denied() MANTIS_MAINTENANCE_MODE-aware

This is probably a better implementation, but it requires modifying 2 API functions, one of which is quite central to MantisBT security so careful analysis / testing is required.

Thoughts, comments or suggestions for alternative implementations welcome.

vboctor

vboctor

2015-12-10 23:54

manager   ~0052101

What is the benefit for disabling admin_checks? Specially the one about whether the admin folder exists or not? We do the same check for 10 other files (custom_strings_inc.php, custom_constant_inc, ...etc).

How above, we make this check only control the checks that access the database (e.g. administrator/root check), but not the directory exists check.

dregad

dregad

2015-12-11 05:59

developer   ~0052104

@vboctor I'm confused, not sure what you are referring to. Can you please clarify ?

This issue is not about disabling anything, the purpose is to prevent unauthorized users to access to the admin checks, to avoid disclosing sensitive system information.

I wanted your opinion on the 2 approaches I'm proposing, or if you have a better idea to achieve that.

vboctor

vboctor

2015-12-11 21:09

manager   ~0052108

Let me explain my point. I'm not a big fan of requiring login to access the administrator space. Also note a fan of a fully functioning MantisBT with no persistent warning on the screen when the admin filter exists.

The reason I don't like requiring login is that we can have a cycle if we want to change the login approach / schema. You need to login to get to admin area, and you need the admin area to upgrade to get login to work.

Given that I don't like the whole approach, I would be OK with the 1st approach you suggested, unless we think that forcing the warnings to always be visible when admin folder exists (independent of the admin checks flag) would be good enough. That warning can show on the login page as well as the top of any MantisBT screen as part of the header. That will only cost a check for the admin folder existence. My point was that we do N of such checks anyway for custom_strings_inc, custom_constants_inc, custom_functions_inc, etc.

Hopefully that's clearer.

dregad

dregad

2015-12-20 17:08

developer   ~0052144

we can have a cycle if we want to change the login approach / schema.
You need to login to get to admin area, and you need the admin area
to upgrade to get login to work.

I think this risk only exists for install/upgrade pages.

Considering that the admin checks are only informational, unless I'm missing something it seems highly unlikely that restricting access to them would introduce any risk of a deadlock.

I was not suggesting to block all admin pages, just the admin checks.

unless we think that forcing the warnings to always be visible when admin
folder exists (independent of the admin checks flag) would be good enough

That may indeed be an increase in security, possibly a better approach based on the premise that admin/ remains accessible for the reasons explained before.

@atrol what do you think ?

vboctor

vboctor

2015-12-22 03:31

manager   ~0052163

Pinging @atrol since this is marked as 1.3 blocking.

atrol

atrol

2015-12-22 18:51

developer   ~0052168

Have to check if this is also reproducible in 1.2.x.
If so, this is not blocking for 1.3.x

atrol

atrol

2015-12-27 14:25

developer   ~0052191

Lowered severity, 1.2.x does also allow to run some of the scripts without being logged in, e.g. admin/install.php or admin/check.php

dregad

dregad

2026-09-26 20:04

developer   ~0071469

I believe I found a better way to achieve this compared to what I wrote in 0020359:0052099.

Calling db_connect() early (at the beginning of admin/check/index.php allows a proper access check to be made in most usage scenarios, i.e. except when we cannot connect to the database.

In this case we are not able to identify the user, so we have to assume they're a legit admin and continue executing the admin checks.

Related Changesets

MantisBT: master 0d765207

2026-09-26 19:14

dregad


Details Diff
Prevent Admin Checks execution by non-admin users

Adding an access_ensure_global_level() call at the start of the script,
to deny access to non-admin users.

This requires a valid DB connection to retrieve the user's cookie, so we
call db_connect() first. Since it is possible that the DB is not
available (e.g. running admin check to troubleshoot installation issues)
we could be unable to identify the user, in which case we just continue
assuming they are the admin.

Since we already have a database connection, there is no need to call
db_connect() again in check_database_inc.php, we can just check the
status with db_is_connected().

Fixes 0020359
Affected Issues
0020359
mod - admin/check/check_database_inc.php Diff File
mod - admin/check/index.php Diff File