Three related security vulnerabilities were identified in the Roundcube twofactor_gauthenticator plugin that allowed unauthorized access to sensitive information and potential modification of 2FA settings. These vulnerabilities have been successfully addressed with comprehensive fixes.
Severity: Medium Component: Roundcube twofactor_gauthenticator plugin File: twofactor_gauthenticator.php Reported: Yes. Package maintainer was very accomodating and applied our patches.
Description: The plugin was leaking configuration information and localization strings to completely unauthenticated users through AJAX requests. When an unauthenticated user made an AJAX request to the Roundcube server, the plugin would still load and set environment variables, which would then be included in the JSON response.
Information Leaked:
allow_save_device
, days_to_remember_device
)How to Reproduce:
?_task=mail&_action=list&_refresh=1&_layout=widescreen&_mbox=INBOX&_page=1&_remote=1
Severity: Critical Component: Roundcube twofactor_gauthenticator plugin File: twofactor_gauthenticator.php
Description: A more serious vulnerability was discovered where users who had entered valid username/password credentials but had not completed 2FA verification could access mailbox data through AJAX requests. This represents a critical security bypass of the 2FA protection mechanism.
Information Leaked:
How to Reproduce:
?_task=mail&_action=list&_refresh=1&_layout=widescreen&_mbox=INBOX&_page=1&_remote=1
Severity: High Component: Roundcube twofactor_gauthenticator plugin File: twofactor_gauthenticator.php, function: twofactor_gauthenticator_save()
Description: The plugin's save functionality had insufficient authentication checks, potentially allowing unauthenticated users to modify 2FA settings. The existing security check only verified a specific session variable and only if 2FA was already active.
The init()
function was modified to directly block and send an error response for AJAX requests from completely unauthenticated users:
function init()
{
$rcmail = rcube::get_instance();
// Completely block AJAX requests for unauthenticated users
if (!$rcmail->user->ID && !isset($_SESSION['twofactor_gauthenticator_login']) &&
isset($_REQUEST['_remote'])) {
// Direct JSON response to prevent leakage
header('Content-Type: application/json');
echo json_encode(array(
'error' => 'Session expired or invalid',
'redirect' => '?_task=login&_err=session'
));
exit;
}
// Rest of the function...
}
An additional check was added to the init()
function to block data access through AJAX requests for users who have entered username/password but not completed 2FA verification, but only if they have 2FA enabled:
// Block data access via AJAX for partially authenticated users who have 2FA enabled
if (isset($_SESSION['twofactor_gauthenticator_login']) &&
(!isset($_SESSION['twofactor_gauthenticator_2FA_login']) ||
$_SESSION['twofactor_gauthenticator_2FA_login'] < $_SESSION['twofactor_gauthenticator_login']) &&
isset($_REQUEST['_remote']) &&
$rcmail->action !== 'plugin.twofactor_gauthenticator-checkcode' &&
$rcmail->task !== 'login') {
// Get user's 2FA config
$user_prefs = $rcmail->user->get_prefs();
$tfa_config = isset($user_prefs['twofactor_gauthenticator']) ? $user_prefs['twofactor_gauthenticator'] : null;
// Only block if 2FA is enabled for this user
if ($tfa_config && isset($tfa_config['activate']) && $tfa_config['activate']) {
// Direct JSON response to prevent leakage
header('Content-Type: application/json');
echo json_encode(array(
'error' => '2FA authentication required',
'redirect' => '?_task=login&_err=session'
));
exit;
}
}
This ensures that only legitimate 2FA verification requests are allowed during the partial authentication state for users with 2FA enabled, while allowing normal login flow for users without 2FA enabled.
The twofactor_gauthenticator_save()
function was enhanced with a stronger authentication check:
function twofactor_gauthenticator_save()
{
$rcmail = rcmail::get_instance();
// Verify user is authenticated before allowing changes
if (!$rcmail->user->ID) {
header('Location: ?_task=login');
exit;
}
// Rest of the function...
}
This change ensures that only authenticated users can save 2FA settings, preventing potential security bypasses.
The fixes were thoroughly tested and confirmed to:
The vulnerabilities could have allowed attackers to:
The implemented fixes mitigate these risks by ensuring proper authentication checks are in place before exposing sensitive information or allowing configuration changes, while maintaining full functionality for both users with and without 2FA enabled.
security@codamail.com