Security Login Bypass Vulnerability
-
Description: Using third-party social login services allows bypassing two-factor authentication directly.
-
This topic was modified 1 year, 5 months ago by
Leo.Lin.
-
This topic was modified 1 year, 5 months ago by
-
Hi,
WordPress plugins can do whatever their coders want them to do. If someone wants to code a plugin that logs you in via some other method, then they can. If you don’t want that, then don’t install a plugin that does it. If you want a third-party login plugin to also respect this or some other plugin, then its author has to code it with that in mind.
David
@davidanderson Okay, I understand. I am using the Super Socializer plugin, which supports social logins like Google and Meta. However, I noticed that when a user has two-factor authentication enabled, they can still log in directly after linking their account without being blocked. This essentially renders the plugin’s functionality ineffective, which could potentially lead to security issues.
Super Socializer and other social login plugins tend to provide their own login system outside of WordPress’s core system (which is what this plugin hooks into), so if they want to incorporate this plugin, they would have to do that themselves.
If you’re concerned about security issues with these social login plugins, then I recommend that you simply avoid using them.
Claiming this plugin has a security vulnerability simply because another plugin isn’t coded to even know it exists isn’t really fair.
Also, you were warned 2 days ago about how to properly report plugin security issues at https://developer.ww.wp.xz.cn/plugins/wordpress-org/plugin-security/reporting-plugin-security-issues/ and told not to use the forums, but you went ahead and just re-posted, so consider this your final warning.
@moderator I’m sorry to hear your response. Although it’s not a security issue in the code, it is a security concern related to user behavior. Most WordPress sites now use social login software, and I chose the Two Factor Authentication plugin. Intuitively, when I enable it, I expect that regardless of the login method, users will need to enter the second factor if it’s enabled. This is also the primary reason why the code needs to be updated and continually improved. We cannot wait until a bypass is discovered, causing significant problems, and then fix the judgment that was not made initially. If other software still requires users to manually add two-factor authentication, then what is the point of using this plugin? I will address this issue myself. Thank you for your guidance!
I only received prompts such as 『Your post is being held for moderation by our automated system and will be manually reviewed by a volunteer as soon as possible.』.I did not mention that it is a security issue in the code. The oversight in user operation judgment is also an area for future optimization by the plugin author, and it does not affect other plugin users.-
This reply was modified 1 year, 5 months ago by
Leo.Lin.
Most WordPress sites now use social login software
Quite the opposite, most don’t.
The latest version of WordPress has been downloaded, at this moment, 29,305,379 times: https://ww.wp.xz.cn/download/counter/
To add to that number, not every site is on the latest version, so there are many more WordPress sites out there: https://ww.wp.xz.cn/about/stats/
In comparison, the most popular social login plugin has around 300,000 active installs: https://ww.wp.xz.cn/plugins/nextend-facebook-connect/ and the next most popular has around 20,000 active installs: https://ww.wp.xz.cn/plugins/miniorange-login-openid/
Those are indeed some big numbers, but they also represent only 1.1% of WordPress 6.7.1 installations.
Intuitively, when I enable it, I expect that regardless of the login method, users will need to enter the second factor if it’s enabled.
I agree with you there, but the plugins providing these social login systems need to either use core’s login system instead of building their own or specially integrate this plugin into theirs, and none of that is under the control of this plugin or its developer.
We cannot wait until a bypass is discovered
Except that it’s not a bypass. You installed a really great lock on your front door, but you also installed a new side door with nowhere near the locking capabilities of your front door.
You do have to take some responsibility for the plugins that you choose to install on your site.
If other software still requires users to manually add two-factor authentication, then what is the point of using this plugin?
This plugin is for WordPress site owners who want to increase their site’s security and aren’t running conflicting plugins.
@moderator It’s an honor to hear your insights. Although the download count for third-party social logins is still lower than the WP download count, I believe quick login is the trend of the future. Just now, I also completed the functionality I wanted on the test site by integrating it with a two-factor authentication plugin. Below are the results I have modified, and I’ll also share a screen recording of the third-party social login combined with two-factor authentication!
Standard version:https://imgur.com/a/RwvKMXO
Third-party login version:https://imgur.com/a/4znQB7C
Constructive discussion is also a form of growth. I do not have any ill intentions. Let’s consider this discussion concluded, and I will mark this issue as resolved.I have also modified your plugin. The adjustment logic does not interfere with other third-party social login plugins since the core functionality primarily shares the
wp_loginhook. Enhancing the desired aspects of this hook can make your plugin even better. If you plan to add new features in the future, you can prioritize them as optimization goals.Implementation Method:
Detect thewp_loginhook after login, retrieve user information, clear the login status, generate a valid login password, and require users to enter a two-factor authentication code on the login page to complete the login process.Demo Video:https://imgur.com/a/fE65Xob
add_action('wp_login', 'handle_social_login_and_trigger_2fa', 10, 2);
function handle_social_login_and_trigger_2fa($user_login,$user) {
if Check if the member has enabled two-factor authentication and if wp-login.php is accessed without any parameters:
//If there are other parameters, it indicates a third-party social wp-login, e.g.?mail=...&...
=>get user_login...
=>get user_pass... //Password encryption and decryption processing is required.
=>wp_clear_auth_cookie()
=>wp_redirect login page
=>call admin-ajax.php send { action: 'simbatfa-init-otp',user: user_login}
=>Skip...
}-
This reply was modified 1 year, 5 months ago by
Leo.Lin.
The idea in the immediately preceding post is wrong at a technical level and would be likely to introduce security holes. As documented in WordPress core, the
wp_loginhook fires after a login has already taken place. At that point, login cookies have already been set. To try to restrict user behaviour at that point would be a completely wrong approach, because you’d have to make sure you cover all other entry points into WordPress code (AJAX, REST, custom entry points added by any random plugin), etc., otherwise you’ll have a TFA bypass.As previously alluded to by myself and the moderator, if a plugin that currently bypasses the WordPress core login code wishes to hook in so that other plugins can filter results, then it should be using the
authenticatefilter. If it avoids that filter, it’s because *it doesn’t want other plugins to be able to modify what it’s doing*. As I say, WordPress plugins are a co-operative system. We’re not going to add code to try to hack our way around plugins that are coded to bypass the core WordPress authentication hooks. Hacks layered upon hacks are not a recipe for security. It’s better than each plugins clearly define and accomplish achievable goals, rather than trying to piece together compatibility with a plugin that isn’t interested in compatibility.@davidanderson I disagree with this perspective. When users agree to enable two-factor authentication (2FA), logging in must involve completing the 2FA process to be considered legitimate. It cannot be viewed as us altering user behavior. The cookie obtained during the first login is merely for retrieving user data. Users must still complete the 2FA process and click the login button to finalize a legitimate login; otherwise, the login attempt should be blocked.
The two-factor authentication plugin I referred to is: Two-Factor.
This plugin adopts this process without requiring any modifications and checks all login attempts. Although our perspectives differ, I sincerely appreciate your willingness to engage in this discussion with me,thanks!
Your current functionality is already very comprehensive, and there’s no need to make specific changes just for this issue. I’m simply offering you a well-intentioned suggestion, because other plugins have also taken this point into consideration!Security note: As mentioned in the comment, instead of logging in with the user’s password, a one-time password is generated. Additionally, if two-factor authentication is enabled or the user logs in using third-party social media authentication, WordPress functions will be used to clear the cookies.
//Password encryption and decryption processing is required.
wp_clear_auth_cookie(); //Clear all login data for this user
$one_time_password = hash('sha256',wp_generate_password(16, true, true)); //Use a hash to transmit a one-time password; it becomes invalid after a single failed verification.
update_user_meta($user->ID, '2fa_otp', md5($one_time_password)); //md5 or other encryption methods
//and then
$one_time_password = get_user_meta($user->ID, '2fa_otp', true); //get user_meta 2fa_otp
if(md5($password)==$one_time_password){
delete_user_meta($user->ID, '2fa_otp');
return $users;
}else{
delete_user_meta($user->ID, '2fa_otp');
return new WP_Error(
'incorrect_password',
......
);
}All the added code must, of course, check if two-factor authentication is enabled and if third-party login is used before execution. This also includes using cryptography for encryption and decryption to implement the required functionality. The code I provided above is for your reference, and the main goal from the beginning is to address security issues. Naturally, I will consider the security of cookie transmission and password encryption!
Hm, I think you’re trying to make this plugin something it’s not.
Looking over all of this, it’s pretty clear the plugin is doing as much as it possibly can within WordPress best coding practices and plugin directory requirements.
The problem seems to be instead with whatever plugin you’re using for social media authentication.
If they wanted to allow any two-factor authentication plugin to work, all they’d have to do is implement the authenticate filter, as the developer already detailed: https://ww.wp.xz.cn/support/topic/security-login-bypass-vulnerability/#post-18216591
It’s a much simpler fix for your social media authentication plugin, and it would be more inline with best practices. Have you contacted them?
If they don’t want to, I suppose that another matter, but I still don’t think mutating this plugin into something else is the right solution.
Also, when it comes to social logins, consider that anyone who would have wanted two-factor authentication has already set it up on the social platform they’d be using to login.
@macmanx If I were trying to make this plugin something it’s not, I wouldn’t have reached out to the author in the first place.My intention is to help make this plugin better. I kindly ask you to read through all the replies before commenting! I’ve been a long-term user of this plugin, and only after discovering this issue did I start trying other similar plugins. I wanted to inform the author that another plugin called “Two-Factor” has already addressed this issue.
This Plugin Video
Standard version:https://imgur.com/a/5TP9fgH
Third-party login version(Skip verification):https://imgur.com/a/M6TfTn3Another Two-Factor Video
Standard version:https://imgur.com/a/RwvKMXO
Third-party login version(Verification required):https://imgur.com/a/4znQB7COf course, I’ve also consulted third-party communities regarding the usage of their hooks. The modified version of this plugin that I worked on uses their hooks. I mentioned the wp_login hook to the author because, upon reviewing the code of “Two-Factor,” I noticed they start their verification process from there, avoiding concerns about other login methods. As you suggested, modifying third-party plugin code isn’t ideal. However, I’ve successfully integrated two plugins, and I truly appreciate your advice.
Contact link:https://ww.wp.xz.cn/support/topic/which-hook-should-be-used-before-adding-two-factor-authentication/#post-18217027
Final video:https://imgur.com/a/fE65Xob
Below is the core of the code I modified. I am also happy to share the logic behind the changes, so others who need it in the future can modify it in this direction. I still like the author’s plugin, which is why I made this constructive suggestion!add_action('wp_login', 'handle_social_login_and_trigger_2fa', 10, 2); //wp_login
Change into
add_action('the_champ_login_user', 'handle_social_login_and_trigger_2fa', 10, 4);//Behavior of the super-socializer after logging in
function handle_social_login_and_trigger_2fa($var...){
=>get user_id
$tfa_enabled = get_user_meta($user_id, 'tfa_enable_tfa', true);
if ($tfa_enabled === '1') {
=>Clear all login data for this user //wp_clear_auth_cookie();
=>get user_login...
=>make one time password... //$one_time_password = hash('sha256',wp_generate_password(16, true, true));
=>save one time password(md5) to user_meta //update_user_meta($user->ID, '2fa_otp', md5($one_time_password))
=>wp_redirect login page // use username and one time password login
=>call admin-ajax.php send { action: 'simbatfa-init-otp',user: user_login}
=>start 2fa check
=>remove one time password //delete_user_meta($user->ID, '2fa_otp');
=>Skip...
}
}I looked at the semi-official “Two Factor Auth” plugin out of interest. As you say, it uses the
wp_loginhook, and what it does is to then immediately invalidate the auth cookies that have just been set. Then they put up a screen for the TFA, which has a nonce in it that allows re-creating the login session.Evidently it’s an approach that works; and I found it interesting to see. However:
- I’d have to do a major re-factor on our plugin to do that; we don’t create our own screen, we add forms to existing login forms; we don’t destroy and recreate a login session, but block it being authorised. So that’s a big structural change.
- I have a very small interest in social networks, and a positive dislike for the concept of giving those companies even more user data (allowing them to know more of what websites you’re visiting and logging on on and when/where), and a long to-do list, so, motivation is lacking.
If you’re a coder and can make the approach work with this plugin then, all the best to you; feel free to share your solution with others. I’m happy to add new hooks or filters to this plugin if you need them, since doing so is harmless.
@davidanderson
Details: https://short.lugeshop.com/8TPJB
Case – Cloudflare:https://imgur.com/a/G0tqcqp
The final video:https://www.youtube.com/watch?v=NeQ9BtCApvw
I have successfully completed the integration and informed the users of my platform. Thank you very much for taking the time to understand my requirements. Currently, the main challenge I am facing is the data transmission after redirecting to the login page following third-party social login. Using the standardinput.valueto assign a value to the account field fails to successfully trigger theadmin-ajax.phprequest for thesimbatfa-init-otpaction. As a result, using JavaScript to submit the form directly shows a validation error. To address this issue, I have switched to manually sending an AJAX request to resolve the problem with the verification box.<script>
document.addEventListener("DOMContentLoaded", function() {
var usernameField = document.getElementById('username');
var passwordField = document.getElementById('password');
if (usernameField && passwordField) {
// set username and otp
usernameField.value = '<?php echo $username; ?>';
passwordField.value = '<?php echo $otp; ?>';
jQuery.ajax({
url: '/wp-admin/admin-ajax.php', // WordPress AJAX URL
type: 'POST',
data: {
action: 'simbatfa-init-otp',
user: '<?php echo $username; ?>'
},
dataType: 'text',
success: function(response) {
console.log('AJAX request succeeded, response:', response);
var form = document.querySelector('form.woocommerce-form-login');
if (form) {
//form.submit();
const submitEvent = new Event('submit', { bubbles: true, cancelable: true });
form.dispatchEvent(submitEvent);
console.log('Login form submitted!');
}
}
});
}
}, { once: true });
</script>The reason I came up with this idea is that I recently used a login feature provided by Cloudflare, a domain service provider. They implemented this functionality, which gave me great peace of mind.
Our platform not only stores users’ virtual assets but also has a shopping cart for purchasing virtual goods, so we take login security very seriously. For members who have enabled 2FA, if their third-party accounts are unfortunately compromised, at least our website can provide an extra layer of protection. I fully agree that members should protect their third-party social accounts, but members who have enabled 2FA and encounter situations where they can log in without entering a verification code may suffer financial losses and blame us, the website administrators. This issue has been a long-standing struggle for us.
For example, a member once complained that despite enabling 2FA, someone was able to log into his account, place orders, or view their virtual assets without passing the 2FA process. We were quite surprised and later realized that his Meta account had been compromised, allowing access to our website. It was then that we started to recognize how important this issue is.
It has been an honor to exchange ideas with you, and I’ve learned a lot about important considerations when developing plugins. Wishing you a wonderful day!-
This reply was modified 1 year, 5 months ago by
Leo.Lin.
Thanks again for the info. I have put something in our task tracker to think more about it. No promises. But there’s more to the idea than I realised at first.
-
This reply was modified 1 year, 5 months ago by
The topic ‘Security Login Bypass Vulnerability’ is closed to new replies.