My topic for today is authentication bypass and account takeovers. So this talk is for people who are in pen testing, who are doing red teaming activities and who are in bug bounty hunting. Other than that, if you are a student or new to this field, this is for you as well. So I hope you will enjoy it. So the agenda for today's talk is, I have divided it in three different phases. First is introduction, I will discuss about what authentication is, why it's so crucial and what are the different modules where you can look for such bugs. The phase two is techniques and vulnerabilities, which I personally use to take over the accounts and bypass the authentications during my entire career. I mean, I have eight years of experience and I have used these techniques during the pen testing activities, red teaming activities and bug bounty hunting. The third phase is, I identified account takeover or authentication bypass in Apple. I will disclose that. Little bit about myself, my name is Vikas Khanna, I am technical specialist at Privasec. My key focus is on AppSec, web applications, API security, whenever I'm not working on my professional stuff, I am bit active on bug bounty hunting. I got acknowledgements from companies like Google, Microsoft, Apple and many more. Other than that, I have contributed to the community. I have contributed to OWASP, WSTG and OWASP www community. Other than that, I have a few CVs from Oracle and IBM for reporting them issues in their enterprise products. All right. So what is authentication? Basically authentication is a process to verify a user or a system that they are what they are claiming to be. By verifying their credentials in terms of their user names, password, digital signatures and many more things. Authentication is very crucial, for example, there are post login modules which are having sensitive information, your PIIs and information which not everybody should be able to see without logging into the application. So that is why authentication is very crucial. So whenever we are hunting for authentication bypass and account takeovers, these are the abusable vectors or functionalities where you can focus on. Basically I have identified issues in these features, these functionalities, but this bug is not limited to these features only. I mean you can explore. But this is based on my experience. Okay, real time abuse vectors, like vulnerabilities and techniques which you can use basically to take over the accounts and bypass the authentications. All right, first vulnerability is session puzzling. What is session puzzling? Session puzzling is like whenever you have extra permissions on your session ID, for example, you are in pre-login stage and for some modules or some activities you got a session ID and that session ID is misconfigured and having a permission, over permission which you can use to access the post login modules as well. Basically it's in pre-login stage, but you can access post-login modules as well. All right, so the example for this is forgot password functionality. How forgot password functionality works, like there is a forgot password module, you can enter your email ID, application will redirect you to another page where application will ask you for OTPs or maybe security questions and if you provide OTP, correct OTP or correct security questions answer, application will redirect you to another page where you can enter the new password and change the password. But for the second page, where application is asking for security questions answer or OTP, application have created a session which is linked with your email ID, which you provided on the first page. But if the application is misconfigured and that session variable, session ID is having over permissions, you can, without entering the security answer or OTP, you can access the post-login modules by just using that particular session ID, because it is activated globally. So this issue I have identified in Apple and I will show in the later slides. All right, other vulnerabilities, session fixation. So , as name suggests that in this vulnerability, you can fix the session in pre-login stage. Basically, the pre-login and post-login session variables value will remain same. It will be just the state of the session token which will become active or deactive. All right? So there are two ways we can use this vulnerability. One is whenever your victim is in the remote location. So how you can leverage that? So if you are able to get the session ID in URL in pre-login stage, what you can do, you can copy that and send it to your victims. All right? Whenever your victim will click on that link, since the link belongs to the legitimate application, victim will click on that and will enter the credentials. When victim will enter the credentials, the session ID will become in an active state. Since you are the one, you are the attacker, you have that session ID, you can use it on your machine and you can log in into the victim's account directly. You don't have to enter the passwords. So that's how you can bypass the authentication and take over the accounts. This is when your victim is remote. The other thing is whenever, let's say, you are working on a shared machine, there is a machine which is shared by multiple users. So what you can do, you can go to that machine, you can copy the cookies. Since pre-login and post-login cookie will be the same, you can just copy that and whenever your victim will log in to that particular application, you can use that cookie and you can bypass the authentication by using victim's account. All right. The other is access control checks. IDRs, IDRs are best friends, we can use that to perform a number of activities and one of them is account takeovers and authentication bypasses. So how you can take over the accounts? For example, application performing some sort of sensitive activities like change password, update profiles by just checking the user's ID. Sometimes it's in even hidden parameters. You can use tools like client-side proxy tool like Burpsuit and you can just modify the user ID and if the application is vulnerable, you will be able to take over the accounts of your victims. The other is privilege escalations. Let's say if you are performing gray box assessments as a pen tester. So you will be aware with admin level modules as well and non-privileged user or non-admin users modules as well. So you can log in into the least privileged user account and you can try to access the admin account. And if the application is vulnerable to access controls and privilege escalations, you can access the admin level modules. Depending on the application's functionality, let's say there could be a number of sensitive modules where you can play with maybe let's say there is an admin module where you can see the number of users. You can deactivate their accounts. You can change their passwords. You can block them. You know , you can, depending on the application's functionality, you can do a number of things. Other thing is forced browsing. Forced browsing is something when you are forcefully trying to access post authentication modules by just hitting them without providing any credentials. If there is access control bug, you will be able to access the post login modules as well. And let's say there are configuration files which are not linked with the application but are still present in the server. So you can access those configuration files and, you know, it will share, it will disclose a lot of sensitive information depending on what kind of configuration file is there. All right. Next is password reset link hijacking or poisoning by using post header injection. So let me explain what is post header injection and how it works first. Then we will dig into how we can abuse it. So whenever you are hitting an application, application verify, okay, what's the value of post header, its origin, and accordingly application will fetch the responses from that particular application server and assign to you the resources. So whenever you are having redirection, 301, 302, you can use post header vulnerability. You can change the host header's value and you can check the location header if your host header's value is getting reflected into the location header in the response itself. How you can use it to take over the accounts. So for example, there's a password functionality, you can go there, you can enter your victim's email ID, you can capture the request by using Bobsuit, and you can change the host value to the domain which you can control. So here, 0xnoob is, for example, my domain, I'm an attacker. So I can enter my victim's email ID, I can capture the request, and I can change the host header value to 0xnoob. So what application will do, how password functionality works. Application will send you a reset token link to your email ID, you can click on that and update the password. But here, since you have updated the host header value, application server will send a password reset link to your email ID, with the password reset token, but the URL which will be embedded will be 0xnoob, or the domain which you will provide. All right, so since it is coming from the legitimate application server, victim will click on the link, you can use it in red teaming activities, you can try it on pentesting, bug bounty hunting. Victim will click on that particular link, and you can go to your server logs, and you can capture the, you can grab the reset token. Since it's still in the active state, because victim haven't used it on legitimate application yet. So you can go to the legitimate application and embed that particular token, and that's how you can take over the accounts, because a token is still in active state. You can enter the credentials, and you can change the credentials of your victim. That's how you can take over the accounts. JS files. A lot of people usually don't get into the JS files, they don't bother about it. But JS files are something which are very crucial, and sometimes it's having some sort of sensitive stuff, funny stuff, I mean, depending on, you know, what sort of stuff is there. So you can find API keys, you can find credentials, you can even find the sensitive API endpoints. PHP type juggling, give me a moment. So type juggling is a feature of PHP. What does it mean? So it's a functionality of PHP where you don't have to define the data types, PHP will do it for you. PHP will, whenever PHP will perform any operations or comparisons on the variables or parameters, PHP will convert the data type accordingly and perform the action. For example, the first parameter is number 1, which is a string, 10 is in double quotes. The second parameter is number 2, which is 5, which is integer. And in third parameter we are performing operation, additional operation. So whenever we are performing addition, PHP will convert string, which is 10, to an integer and will perform the addition operation. So the result will be 15, 10 plus 5 is 15. So the other thing is comparison. Whenever PHP will perform a comparison by using 2 times equals 2. So what PHP will do, first parameter here is integer, second is string. So the second parameter's value is 10 abc, which is a string. Whenever you will perform a comparison operation here, PHP will convert that string, 10 abc, to 10, which will become integer. And then PHP will perform the action accordingly. So 10 is equal to 10, so the result will be equals. How we can leverage it to take over the accounts. All right, so let's say there is a value of parameter which don't have the integer. So if you will convert that string with the integer, PHP will convert that string to zero and then it will compare with the user's provided input. So for example, the admin's password is not having an integer value, having a string only. So as an attacker, you can mention zero in the password. PHP will compare it with admin password. Admin password is a string. PHP will convert admin's password to zero and zero is equal to zero will become a true statement. That's how you can bypass the authentication. But there is prerequisites. It should be JSON or serialized object. Then only you will be able to perform this attack. CSRF. Let's say in the application CSRF tokens are missing and there is no CSRF protection. And there is a module where you can update the mobile number, email ID. You can craft an HTML page and send it to your victim. If that victim is logged in into their account, you can literally update their mobile numbers and email address. Once you will be able to do that, you can request for a password by entering the email or password, email or mobile number which you have mentioned during the HTML page creation. Then you can take over their accounts. Because application will send the OTPs or password reset links to their phone number and email ID, which belongs to the victim's account. Let's say if there is a password functionality where application is not asking for old passwords and application is vulnerable to CSRF, you can just craft a request and send to your victim and you will be able to change the password. From there you can take over their accounts. HTTP parameter pollution. It's a vulnerability where you can mention multiple parameters with the same name. But the values will be different. And the application will perform the action on the basis of that. So let's say there is a password functionality, all right? And you can mention maybe, you can use that one parameter for twice, for two times. And mention the victim's email ID plus your own email ID. So if the application is vulnerable, application will send password reset token to both the email IDs. But it will be activated for one account only. Depending on how application is doing that. Maybe it is validating the first parameter or second parameter. That you have to figure out. It depends on different applications. So accordingly, let's say whenever you receive that link, you can just go to application and you can just change the password of your victim and you can take over the account. You can try this on reset password, update password, wherever you are receiving OTPs, you can try that vulnerability. Authentication bypasses by using response manipulation. So a few applications are validating the previous response and then perform the next action. So let's say the response is on the basis of true or false. If you have provided the right credentials, application is throwing you the true response. And if you have provided the wrong credentials, application will throw the false response. So you can change that to true and you can perform the next action. You can bypass. Accordingly, you can manipulate the status codes. If application is throwing 400 or something for wrong credentials and throwing 200 OK for right credentials, you can try to manipulate that. Two-factor authentication or OTP, you can break that. How? So whenever you are performing pentesting specially, you can use these things. You can check for the integrity validation of OTPs. For example, I can send OTP to my mobile number and send OTP to my victim's mobile number. Sometimes, so these two OTPs are in active state now. Because neither I used nor my victim used it for now. So what can I do? Since both the OTPs are in active state, I can check the integrity. I can try my OTP on my victim's account. I can try my OTP on my victim's account . Just to validate that application is checking the integrity of the OTP or not. And trust me, it's still working. Reusability of OTPs, you can try to reuse the OTPs. And the third one is, I found it in one of the most popular banks. So they were disclosing the OTPs in the responses. So, I mean, go for it, check for responses as well. Master OTPs, I found it in one of the net banking applications. The master OTP was six times zeros. So you can log into any account by using six times zero. I mean, you can try for other stuff also, so go for it. All right, brute force. So whenever we are thinking about brute force, we are trying to brute force the passwords. We can try another way as well by using password spraying attack. We can brute force the emails by using one password. We have one password and we can try that on multiple users. We can try to brute force in that way as well. So whenever you are performing red teaming activities or bug hunting or something, you just need one account to perform your actions. So this will be very handy. Try to check if there are rate limiting controls are enabled or not. Other than that, sometimes application is blocking your IP address whenever you are performing brute force attacks. So you can hop on different IP addresses. You can change your IP addresses depending on how application is blocking it. Maybe after 15 requests or 50 requests. And just before, let's say application is blocking IP after every 50 requests, you know, within maybe some sort of time foundation. So you can change your IP on 49th attempt. Accordingly, you can try that. You can send multiple credentials in request to validate that, I mean, it is working or not. There is a very, very good lab of web security academy, please check that. Default credentials. This is very, very handy in rate limiting activities. So , I mean, almost every organisation is using enterprise products. Go for it, check for the default credentials. I mean, it's still working, I usually find that. WordPress, it is one of the most popular CMS. So there is a so-called feature in WordPress where you can use author parameter just to verify that what's the username of one. I mean, let's say if you will enter the author's value one, it will show you the first user of that particular application. If you will change it to two, it will show you the second user of that particular application. It will show you the username, it will show you the posts which are done by that user. It might show you the comments as well. So accordingly you can enumerate user's information. And whenever you are performing WP scan, don't perform directly without using API keys. Please use API key, you can go to WP scan website, you can get API key, it's free of cost. And by using that particular API key, if you will perform the WP scan, the results will be definitely different. In secure logout management, whenever you are working on pen testing, check for these things, especially for banking applications. For example, reuse of session, check if you can reuse that particular session. Login to the application, logout from the application, check if you can still use the old sessions. Close the browser for the sensitive applications. Whenever you are closing the browser, it should dissolve the entire session at the server side. Let's say if there is a net banking application and you are closing the browser, whenever you are again accessing the application by using new tab, it shouldn't work. Application should ask you for the login. Session should bound to IP address for sensitive applications. For example, as an attacker, if I am able to get the session of my victim, but if let's say that is bound to their IP address only, I won't be able to use that. Check for it. Tips for red teamers and pen testers. Go to pastebin whenever you are performing red teaming activities. Go to pastebin, pastebin have a lot of sensitive stuff. DHash, go for DHash, you can find the passwords of your victims. Open bug bounty, this website is very handy. I used it multiple times and it helped me a lot. You can find a lot of vulnerabilities which are identified by other attackers. And they have disclosed those vulnerabilities publicly because the vendor is not entertaining them. So you can use those vulnerabilities. My first bug, I found it in Apple, I found account takeover or authentication bypass basically, I will call it as authentication bypass. So that was my first bug in Apple. So this was session puzzling, which I explained in the earlier stage. So I was able to get the session variable, which was active for post-login modules as well. In the pre-login stage. Here I am on login page, I'm trying application is redirecting me to the login page only. There is a story behind that. The domain name is instafusion.apple.com. If I will go to that domain directly, it will redirect me to the SSO of Apple. Based on my understanding, it is bit secure. I haven't tested that, to be honest. But yeah, based on my understanding, it is secure. Then I did some sort of Google docking and I got to know that there is a subdirectory with a random string folder name and there is a login module there. So I tried to hunt here. I removed the login page, application is redirecting me to login again. Here it is. So application is asking me for a username and email address. I provided a fake username and fake email ID. I got an error that please try again. But for this particular thing, when application was throwing me an error, application created a session which belongs to my email ID and they have activated it for the entire application and which was linked to the admin module. Now I tried to remove the login and tried to access the subdirectory. Boom. Thank you. So here I was able to download the confidential details. I have blurred a few contents because of sensitive information. So yeah, I was able to download as well.