1 00:00:00,000 --> 00:00:01,120 Welcome. 2 00:00:02,000 --> 00:00:04,140 Yeah, still waking up? 3 00:00:05,660 --> 00:00:08,840 Alright, there's a guy that's awake, right? 4 00:00:08,920 --> 00:00:10,260 Anybody else? 5 00:00:11,020 --> 00:00:13,680 Oh yeah, woo, I'm awake. 6 00:00:13,920 --> 00:00:15,500 Have a nice day. 7 00:00:16,220 --> 00:00:21,260 Alright, anyways, we've got, I'm going to try and say these names right. 8 00:00:21,260 --> 00:00:23,980 Narayan, Lakshmi and Divya. 9 00:00:24,480 --> 00:00:28,400 They are from a large application security team. 10 00:00:28,520 --> 00:00:34,200 Uh, they're going to be talking about, um, authentication, doing it right, doing it wrong, right? 11 00:00:34,200 --> 00:00:36,980 The name, the title of the talk is, Who Dis? 12 00:00:36,980 --> 00:00:37,620 Who Dis? 13 00:00:37,780 --> 00:00:39,520 The Right Way to Authenticate. 14 00:00:39,720 --> 00:00:42,160 And, uh, without further ado, here you go. 15 00:00:49,030 --> 00:00:53,430 Hey, good morning everybody and thank you for making it on a Sunday morning. 16 00:00:53,430 --> 00:00:55,410 So, welcome to our talk, Who Dis? 17 00:00:55,410 --> 00:00:56,990 The Right Way to Authenticate. 18 00:00:57,470 --> 00:00:58,610 Who are we? 19 00:00:58,610 --> 00:01:00,310 Thank you for the introduction, David. 20 00:01:00,350 --> 00:01:05,070 Uh, I'm Lakshmi Sudhir, she is Divya, and he's Narayan. 21 00:01:05,170 --> 00:01:12,810 We do all things application security, we try to be involved in the whole, all stages of, uh, SDLC to make sure it's secure. 22 00:01:12,870 --> 00:01:18,390 And we work with, and for developers and security engineers, we consider that our primary responsibility. 23 00:01:18,430 --> 00:01:26,710 So we work with them to make sure we have, uh, secure products that are being shipped out there and we help them with all the security guidelines around whatever they're building. 24 00:01:27,810 --> 00:01:37,110 So, before we go into the talk itself, just to note that everything we've used for our research is all publicly available data. 25 00:01:37,110 --> 00:01:41,850 We haven't used anything that's for a company or anything else as such. 26 00:01:41,850 --> 00:01:51,970 Also, one more thing is, we want to make this clear out there that we are not encouraging the use of anything that is inherently secure, uh, sorry, insecure. 27 00:01:52,090 --> 00:02:06,610 And, uh, this is just an attempt that, be it that, if you, uh, have to use, based on the business case, uh, relatively insecure part of, uh, protocol itself, then how do you go about making it secure? 28 00:02:06,710 --> 00:02:09,970 So, that is what we are trying to address in this talk. 29 00:02:09,970 --> 00:02:16,130 It's not to encourage any inherent insecure, uh, component of any technology or protocol. 30 00:02:16,250 --> 00:02:18,350 Let's dive right into the talk now. 31 00:02:21,000 --> 00:02:21,960 Okay. 32 00:02:22,180 --> 00:02:31,460 So, the agenda for today is, we're going to go with the background of, like, what is authentication, and then address, like, why is this a problem? 33 00:02:31,460 --> 00:02:33,780 Of course, that's what leads us to the problem statement. 34 00:02:33,780 --> 00:02:38,260 We're going to get more in details about a bunch of protocols and schemes with authentication. 35 00:02:38,440 --> 00:02:48,740 Then, we're going to drive out a conclusion around, hey, why is this still a problem, and what are the patterns we observed across different authorization schemes. 36 00:02:48,800 --> 00:02:52,900 Then, we want to have some time for, like, Q&A towards the end as well. 37 00:02:53,240 --> 00:02:55,760 So, what is authentication? 38 00:02:55,760 --> 00:02:58,840 What comes into mind as soon as I say authentication? 39 00:02:59,000 --> 00:03:06,500 It could be Kerberos, I think passwords might be the top one, API keys, OAuth, SAML, and a million of them. 40 00:03:06,600 --> 00:03:11,660 Also, something that is closely coupled with authentication is identity. 41 00:03:11,680 --> 00:03:13,100 What is identity? 42 00:03:13,100 --> 00:03:15,520 Identity is who you are. 43 00:03:15,680 --> 00:03:20,080 And authentication is what verifies your identity. 44 00:03:20,100 --> 00:03:24,360 So, authentication is what verifies who you are. 45 00:03:24,760 --> 00:03:29,060 Authentication is what actually verifies that I'm Lakshmi, she's Divya, and he's Narayan. 46 00:03:29,500 --> 00:03:31,980 Now, how do you authenticate? 47 00:03:31,980 --> 00:03:37,080 In general, we use passwords, which is pretty common when we log into any application. 48 00:03:37,080 --> 00:03:42,600 Or you might have used your pin to go draw some money to gamble a little bit when you're in the conference. 49 00:03:42,600 --> 00:03:44,060 Who doesn't want some fun? 50 00:03:44,260 --> 00:03:53,660 And that could be something that you know, a secret that you know that you use to identify yourself to an application saying, hey, it's me who's logging in. 51 00:03:53,800 --> 00:04:00,680 Then, something else could be YubiKeys or some device that you own, which is the possession aspect of it. 52 00:04:00,700 --> 00:04:10,080 And the other part is where you might have woken up and be like, hey, let me look at my phone, and that's your face ID, you might be using a touch ID, and that is what you inherently are. 53 00:04:10,080 --> 00:04:13,060 So, authentication boils down to three things. 54 00:04:13,060 --> 00:04:14,860 Something you know, that's knowledge. 55 00:04:14,860 --> 00:04:16,860 Something you have, that's possession. 56 00:04:16,860 --> 00:04:21,120 And something you inherently are, that's inheritance. 57 00:04:21,660 --> 00:04:24,360 Now, where does authentication come into play? 58 00:04:24,640 --> 00:04:28,540 It might be user authentication broadly and service authentication. 59 00:04:28,880 --> 00:04:37,200 With user authentication, I was talking about you logging into an application, drawing out some money, and other things that you interact with the system. 60 00:04:37,200 --> 00:04:47,120 For example, when we were trying to do this research, we wanted to pull up some of the CVs or some of the bugs that were associated to a bunch of authentication protocols. 61 00:04:47,120 --> 00:04:48,100 How did we do that? 62 00:04:48,100 --> 00:05:03,860 We logged into an application, and this application spoke to multiple applications in the background, and those applications reached out to their own data repositories, be it a database, be it an S3 bucket, and they pulled out all that information, brought it together, 63 00:05:03,860 --> 00:05:10,740 provided it to the requesting service, and this service fed it to a BI tool to make sure we get this readable and ingestible data. 64 00:05:10,880 --> 00:05:24,620 And in each of these interactions, the- each of the service, uh, talking to another entity, each of these entities had to authenticate saying, hey, this is me who's requesting, and I do have access to this. 65 00:05:24,620 --> 00:05:29,440 So, when each of these entities were interacting, they had to verify their identity. 66 00:05:29,620 --> 00:05:36,360 So, in this ecosystem, authentication is mostly a backbone to everything we do today. 67 00:05:36,600 --> 00:05:41,160 Now, in this complex ecosystem, we are using authentication. 68 00:05:41,160 --> 00:05:42,600 Do you think there's a problem? 69 00:05:42,900 --> 00:05:49,220 Of course, yes, and that is why we are on a Sunday morning talking about authentication right here. 70 00:05:49,620 --> 00:05:52,600 Now, why is there a problem? 71 00:05:52,720 --> 00:05:56,700 That's- let's look into that more, but if you're a skeptic, we have some data for you. 72 00:05:57,100 --> 00:06:03,800 In OS.M, the latest revision also puts broken authentication in the second place right after code injection. 73 00:06:04,180 --> 00:06:07,780 This shouldn't be the case in 2019, is what we thought. 74 00:06:07,920 --> 00:06:19,560 Then we pulled up more data, and we got this HackerOne report of how much companies are spending on bounties based on the classification of the kind of bugs that are being submitted. 75 00:06:19,780 --> 00:06:22,400 And this was surprising to us. 76 00:06:22,400 --> 00:06:35,180 I mean, cross-site scripting is expected, unfortunately we have that, that's probably for another talk, but broken authentication was still the second most common thing that companies spent a lot of their money on by giving out bounties. 77 00:06:35,540 --> 00:06:46,680 And this is where we thought, we have OAuth, we- we didn't want to remember passwords, we wanted to keep it complex, we didn't want one pass- I mean, we didn't want to remember passwords for each application, which would make it harder to make it complex, 78 00:06:46,680 --> 00:06:48,580 that's how we came up with single sign-on. 79 00:06:48,660 --> 00:06:55,680 So, there are solutions based on issues we have faced before, but why is this still the second most paid out bounty? 80 00:06:55,920 --> 00:07:02,700 So, that's- this was mostly the inception for our talk, we were like, this requires some research, what are we doing wrong, what is going wrong with this? 81 00:07:02,700 --> 00:07:08,720 So, this was mostly where we were like, hey, let's go dig into some of the protocols and see how we can go about this. 82 00:07:09,100 --> 00:07:21,460 Now, of course, we looked in deeper, there's been some leakage of tokens, there have been tokens that have been, uh, leaked because of, uh, uh, some redirect URIs and a bunch of other reports that we actually dived into. 83 00:07:21,460 --> 00:07:24,080 There were tokens which weren't expiring at all as well. 84 00:07:24,080 --> 00:07:30,140 So, we thought, we'll come up with an approach and figure out how do we approach this as a holistic problem. 85 00:07:30,600 --> 00:07:40,700 So, we identified how we went about our approaches, initially we identified , we went through like, uh, the top 200 applications and we were like, hey, let's identify the most commonly used authentication protocols. 86 00:07:40,740 --> 00:07:43,880 Then we identified the high-risk issues and we thought, let's attack them. 87 00:07:43,880 --> 00:07:50,480 Of course, after the research, our idea was to come up with like a remediation or like something that could be pragmatic and useful. 88 00:07:50,660 --> 00:07:57,940 And the end goal always, like I said, as security engineers, I feel we hold our responsibility towards helping developers build things securely. 89 00:07:57,940 --> 00:08:00,600 Implement all those existing protocols securely. 90 00:08:00,600 --> 00:08:03,040 So, that's how we approach the problem. 91 00:08:03,120 --> 00:08:15,820 For today's focus, we're gonna talk about, we're gonna start off with, uh, JSON web tokens, then we're gonna dig a little deeper into OAuth, then of course the passwordless solutions, that's MagicLinks, and then we're gonna talk a little bit about SAML as well. 92 00:08:15,820 --> 00:08:19,980 These are the four things we chose to go a little more in-depth for this talk. 93 00:08:20,140 --> 00:08:24,680 Let's start with JSON web tokens, JWTs, or JWTs. 94 00:08:25,380 --> 00:08:27,380 What is a JSON web token? 95 00:08:27,380 --> 00:08:29,940 A token is nothing but an identifier. 96 00:08:30,100 --> 00:08:40,620 With J- JSON web tokens, it is an encoded JSON blob that has some key value pairs, which is being digitally signed, and provided as a token by an authorization server. 97 00:08:40,620 --> 00:08:42,280 I know I said a lot of words. 98 00:08:42,360 --> 00:08:45,380 So, this is where it could be applicable. 99 00:08:45,440 --> 00:08:52,840 Let's say, as a user, I log into, uh, I log into an application using Facebook, Google, or any of the social auth. 100 00:08:52,840 --> 00:09:01,360 There is an authentication server which validates that, hey, this is a username, password, and then it provides a token, a JWT in this case, a JWT. 101 00:09:01,460 --> 00:09:08,040 Now, as a user, uh, my identity was verified, and this token is given to me as a unique identifier. 102 00:09:08,180 --> 00:09:12,860 And now when I want to log into, say, Quora search, uh, I pass this, uh, token itself. 103 00:09:12,860 --> 00:09:17,340 It validates, based on the signature, you could use both symmetric and asymmetric algorithms. 104 00:09:17,340 --> 00:09:21,420 So, let's say my application has a public key of the authentication server. 105 00:09:21,420 --> 00:09:37,480 It validates this token, and then if it's validated , saying it wasn't tampered, uh, over, uh, transit, it actually services this user, uh , to, like, uh, probably they're requesting to access data, so they just, this, uh, the user is serviced. 106 00:09:38,000 --> 00:09:50,300 Now, why do people, why do developers use JWTs in comparison to the session, uh, tokens itself, the session IDs, which have, like, a unique, uh, a random number that was being used? 107 00:09:50,360 --> 00:10:01,940 So, with JWTs, you achieve authentication because we are relying on the integrity of the token itself, and also you could achieve authorization by adding some of the scopes. 108 00:10:01,980 --> 00:10:14,900 One more most important key difference is that with a session identifier, you'd have to store these unique random strings, along with the user ID, or maintain some kind of state every time a request is made. 109 00:10:14,960 --> 00:10:25,580 So, with JWTs, it's out there, you just service the token, only when the token comes in, you validate it based on the, uh, you validate the digital signature, and you go about servicing it, which makes it stateless. 110 00:10:25,580 --> 00:10:30,100 So, this is one of the key reasons that most, uh, implementations have chosen JWT. 111 00:10:30,160 --> 00:10:32,180 Again, it's compact and lightweight. 112 00:10:32,180 --> 00:10:36,460 This is a little debatable because it depends on how much information you're putting into the JSON body. 113 00:10:36,680 --> 00:10:45,720 And other one is, uh, it's scalable compared to session tokens because you're not maintaining, like, all of these unique session IDs, and going about, like, servicing as and when they come. 114 00:10:45,720 --> 00:10:46,880 So, it's pretty scalable. 115 00:10:46,880 --> 00:10:56,780 Again, coming back to the point of this is a JSON body, you have key and values, so in, uh, in situations like OAuth and stuff, you could use this to even exchange information across third parties. 116 00:10:57,340 --> 00:11:00,020 So, yes, where is it popularly being used? 117 00:11:00,020 --> 00:11:03,020 It's being used in OpenID Connect as identity token. 118 00:11:03,020 --> 00:11:07,240 It's also being used in OAuth as access tokens and refresh tokens. 119 00:11:07,260 --> 00:11:16,780 And JWTs are also being a session, uh, user session object, so we are going to talk about this, uh, being a tricky place to be in a couple of slides. 120 00:11:17,400 --> 00:11:23,900 Now, now that we spoke about JWTs itself, let's look into structure of this JWT. 121 00:11:23,940 --> 00:11:29,360 You have, uh, on the left, uh, side of this is where you see the header, payload, and signature. 122 00:11:29,360 --> 00:11:34,440 This is nothing but an encoded, uh, Base64 URL encoded block. 123 00:11:34,440 --> 00:11:37,000 This is what is being passed on to the server. 124 00:11:37,000 --> 00:11:43,780 And in the header, when you decode this, so remember that there's no confidentiality since anyone can decode who gets this token. 125 00:11:43,780 --> 00:11:47,700 It's just based off integrity, that is validating the digital signature. 126 00:11:47,700 --> 00:11:55,640 Now, in the header, you see that there is the type of algorithm that was used to create this, uh, digital signature, and then you have the type. 127 00:11:55,640 --> 00:11:59,140 We are talking about JWT, so, uh, that's probably, it's just going to be JWT. 128 00:11:59,140 --> 00:12:03,380 In the payload is where you can have, uh, all these key value pairs. 129 00:12:03,480 --> 00:12:09,440 So, uh, that could be, like, the name of the user, what does the user have access to, or any kind of data. 130 00:12:09,440 --> 00:12:16,280 This is a section you mostly use to, uh, exchange information between third parties, or also add, like, assertions and stuff. 131 00:12:16,280 --> 00:12:18,600 So these are called claims, for the most part. 132 00:12:18,600 --> 00:12:28,220 And then you have the signature, which is basically hashed and digitally signed, such that when, uh, an application gets this token, it can validate and make sure that this wasn't tampered with. 133 00:12:28,340 --> 00:12:33,440 So, we have the header, we have the payload, and we have the signature for a chart. 134 00:12:34,340 --> 00:12:35,880 Let's move on. 135 00:12:35,960 --> 00:12:39,640 How many of you here, show of hands, think this is a valid chart? 136 00:12:41,040 --> 00:12:42,000 Okay. 137 00:12:42,200 --> 00:12:44,020 Okay, you guys are right. 138 00:12:44,020 --> 00:12:47,500 This is, uh, unfortunately a valid chart. 139 00:12:47,800 --> 00:12:54,300 One of the things I think you notice is, we have the header, we have the payload, but the algorithm says none. 140 00:12:54,360 --> 00:13:01,720 This is, uh, being used in some edge use cases, and allowed by the GWT RFC itself. 141 00:13:01,720 --> 00:13:17,540 So, when the algorithm is none, if you do not validate or handle the library that is actually validating this token, it looks at this algorithm, the algorithm says none, it's supported by the RFC itself, and then it just disregards the signature, and goes ahead and services this, 142 00:13:17,540 --> 00:13:22,240 uh, validates the token, says it's valid, and goes ahead with, uh, servicing the request. 143 00:13:22,360 --> 00:13:28,200 Now, with this, as an attacker, I can go ahead create any token, and every token would be valid. 144 00:13:28,200 --> 00:13:33,540 So, I can get any actions, I can make any request, and get all the information out there. 145 00:13:33,540 --> 00:13:44,400 This has been there since 2015, and unfortunately, I mean, uh, again, the GWT RFC has been there from about 2014, I guess, but this has been a problem that is known and still prevalent out there. 146 00:13:44,560 --> 00:13:48,400 Now, how do you go about, like, uh, remediating this problem? 147 00:13:48,460 --> 00:13:59,300 One of the things, of course, the best-case scenario with programmatic control could be that you might be using a particular algorithm, you could hard-code it while validating, saying, hey, this is algorithm that you need to validate every token against. 148 00:13:59,360 --> 00:14:02,960 Now, this is the best-case scenario, may not apply in most business cases. 149 00:14:03,000 --> 00:14:12,260 That's where it comes up, the second one, where you could whitelist the bunch of algorithms you're using, and validate against it, saying, hey, the algorithm should match one of these strings, and this is how we service it. 150 00:14:12,380 --> 00:14:15,040 So, uh, that, this is how we validate it. 151 00:14:15,040 --> 00:14:16,800 So this is one of the approaches you could take. 152 00:14:16,800 --> 00:14:21,900 And of course, verifying that the algorithm, uh, fails on none is also a reasonable solution here. 153 00:14:22,260 --> 00:14:30,300 What something else you could do is, I think with any software component, anything you're building, choosing the right library holds a huge lot of prominence. 154 00:14:30,360 --> 00:14:45,060 GWT.io has more detailed information, so based on your tech stack and what you're using to validate, uh, your JWTs itself, you could go ahead, make a choice, understand what are the inherent risks, and if it's supposed to none algorithm, you would want to implement that branch where you're like, 155 00:14:45,060 --> 00:14:46,880 hey, this is something I need to validate. 156 00:14:47,960 --> 00:14:56,900 Now, we are doing this well, we are validating all our, uh, uh, all our tokens for none, and then we are also making sure we're using the right library. 157 00:14:56,900 --> 00:14:58,500 What else could go wrong? 158 00:14:58,800 --> 00:15:04,640 Let's say we have a user , Joe, here, and he has access to a mail server. 159 00:15:04,640 --> 00:15:05,520 It's valid. 160 00:15:05,520 --> 00:15:07,200 He uses an authentication server. 161 00:15:07,200 --> 00:15:10,420 He gives his, uh, username, password, and it validates. 162 00:15:10,420 --> 00:15:11,560 It presents back the token. 163 00:15:11,560 --> 00:15:12,700 The token is valid. 164 00:15:12,760 --> 00:15:17,620 Joe puts, uh, sends this token to, uh, mail server, which is the client application. 165 00:15:17,620 --> 00:15:18,880 It validates the signature. 166 00:15:18,880 --> 00:15:21,460 It's perfect because Joe hasn't done anything malicious so far. 167 00:15:21,460 --> 00:15:22,940 It's, it's the right token. 168 00:15:23,080 --> 00:15:27,300 Now, what if Joe presents this to another service, which is a finance service? 169 00:15:27,300 --> 00:15:30,400 Maybe he wants to increase his payroll, get more money. 170 00:15:30,400 --> 00:15:37,960 So, even this finance service uses the same authentication server, but Joe doesn't have access to go to this finance ops. 171 00:15:37,960 --> 00:15:55,780 So, in this case, if the client application actually doesn't verify that Joe should not have access, just validating the token was not good enough, but the client application should also make sure that the user who is actually requesting access, uh, does have, 172 00:15:55,780 --> 00:15:59,320 like, uh, access to, uh, finance ops in this case. 173 00:15:59,320 --> 00:16:01,660 What is the mitigation for this? 174 00:16:01,660 --> 00:16:12,440 One of the things you could use alongside JWT itself is a predefined claim called audience, where you could put it in the JSON body and say that, like, you can see here, uh, this was a cool company. 175 00:16:12,440 --> 00:16:16,420 So, you can say that this user has access only to the user database. 176 00:16:16,500 --> 00:16:24,600 That way, when you are a client application that is servicing , uh, that is validating a JWT, you could look for this parameter and be like, hey, this was the issuer. 177 00:16:24,600 --> 00:16:27,000 I trust the issuer, but this is the audience. 178 00:16:27,000 --> 00:16:32,980 So, I am not the audience and I cannot really, uh, I shouldn't be providing access to Joe in this case. 179 00:16:33,800 --> 00:16:38,000 Now, we validated, we made sure that the algorithm is right. 180 00:16:38,000 --> 00:16:39,360 We made sure we chose the right library. 181 00:16:39,360 --> 00:16:43,440 We are also taking care of that user substitution or replay attacks as well. 182 00:16:43,440 --> 00:16:46,600 What else is something we should be worried about? 183 00:16:46,620 --> 00:16:54,520 If JWTs are being used as session objects, you remember I mentioned a couple of slides earlier, then how do you go about logging out? 184 00:16:56,140 --> 00:17:05,760 Now, to log out itself, it's a harder problem because just, even though they may have a shorter TTL, I mean, again, shorter TTL is debatable, but let's say you have it for two hours. 185 00:17:05,760 --> 00:17:10,000 And as a user , I log in, I log out, the token is right out there being valid. 186 00:17:10,020 --> 00:17:16,600 Because we don't have a back -end part of it, we just have its expiry on it, but logging out scenarios need to be handled very carefully. 187 00:17:16,900 --> 00:17:34,740 Something you could use, you do for this is have a JTI claim, which is the JWT token identifier itself, which is a unique number, and maintain this unique number with, on your back-end, and have like, hey, this is a user, that way once a user logs out, 188 00:17:34,740 --> 00:17:36,080 you could revoke it. 189 00:17:36,760 --> 00:17:44,320 The choice is made that it was stateless, but it's no longer stateless anymore because you need to have this revocation list. 190 00:17:44,320 --> 00:18:01,180 It's not enough if just your authorization server, authentication server has this revocation list, but in case of like asymmetric encryption or actually anything you use for digitally signing it, each of these client applications need to also maintain or subscribe to this revocation list itself. 191 00:18:01,180 --> 00:18:06,500 Otherwise, while validating the token, I mean, the token would still be valid because it hasn't expired. 192 00:18:06,500 --> 00:18:17,520 So revocation has to be handled while it maintains a list, looks for the JTI that is a unique identifier, goes through the list and makes sure that that wasn't revoked, and then goes about, like, servicing the request. 193 00:18:18,020 --> 00:18:21,040 So, putting all of this together. 194 00:18:21,040 --> 00:18:28,980 Some of the key takeaways could be that verify, I couldn't say this enough, validate your algorithm claim, make sure to verify that this is exactly what you use. 195 00:18:28,980 --> 00:18:33,280 The second one is, of course, use cryptographically strong algorithms. 196 00:18:33,480 --> 00:18:41,080 The third one is around, like, hey, utilize all the applicable claims that are already provided in the JWT RFC itself, because why not? 197 00:18:41,080 --> 00:18:45,540 Why, when the protocol does the heavy lifting for you, why not let it do its job? 198 00:18:45,540 --> 00:18:47,220 So make sure to validate that. 199 00:18:47,220 --> 00:18:48,180 Use those. 200 00:18:48,180 --> 00:18:54,400 And I couldn't say this enough that, unfortunately, even today, revocation is a very common problem we see. 201 00:18:54,400 --> 00:18:56,820 So please handle revocation carefully. 202 00:18:56,820 --> 00:19:00,860 Make sure that any time this is used as a session object, think of revocation automatically. 203 00:19:00,860 --> 00:19:03,580 So this is about JSON Web Tokens. 204 00:19:03,620 --> 00:19:06,800 Now, Divya is going to take up OAuth and talk more about that. 205 00:19:06,800 --> 00:19:07,720 Thank you. 206 00:19:09,480 --> 00:19:10,600 Okay. 207 00:19:10,780 --> 00:19:12,400 Still with us? 208 00:19:13,100 --> 00:19:13,860 All right. 209 00:19:13,860 --> 00:19:19,700 The next topic is open authentication or open authorization, however you want to call it. 210 00:19:19,920 --> 00:19:30,300 So in case you are unfamiliar or if you want a quick primer, OAuth deals with mainly three entities, where you have the client, the resource owner, and the authorization server. 211 00:19:30,300 --> 00:19:35,400 The client now wants to access some resource, and that is provided by the resource owner. 212 00:19:35,400 --> 00:19:40,860 And the resource owner needs to authenticate that it's the right client that is accessing the resource. 213 00:19:40,860 --> 00:19:53,020 So you have another party, which is the authorization server, which, like, before this traffic flow happens, knows who the client is and can provide that verification information to the resource owner. 214 00:19:53,060 --> 00:20:01,100 And the way all these happen is through a bunch of calls, but the main thing that gets exchanged between all these three entities is a bunch of tokens. 215 00:20:01,280 --> 00:20:02,880 And there are three kinds of tokens. 216 00:20:02,880 --> 00:20:08,340 There is access tokens, refresh tokens, and authorization code, which I'm still going to group it under the token. 217 00:20:09,020 --> 00:20:10,580 So what happens? 218 00:20:10,580 --> 00:20:26,160 If any of them, and especially a client, or a web browser on behalf of a client, or even a separate service who is acting on behalf of a client, is going to be in position of a token, that means they have access to a particular resource that they are trying to access. 219 00:20:26,560 --> 00:20:33,980 And this particularly works perfectly when every system follows the best practice possible. 220 00:20:33,980 --> 00:20:37,940 And I'm pretty sure all of us are familiar on how likely that is. 221 00:20:37,940 --> 00:20:42,320 So I was pretty surprised to see so many words. 222 00:20:42,320 --> 00:20:47,360 Maybe lost, stolen, intercepted, proxied, replayed, and altered. 223 00:20:47,360 --> 00:20:59,020 I thought this was excessive, but then I was able to find multiple cases of the tokens being, like, lost or stolen or intercepted, and this has still not been corrected. 224 00:20:59,360 --> 00:21:07,160 And one mitigation that is provided for this, for handling tokens properly, is to pass it over TLS and have a shorter TTL. 225 00:21:07,600 --> 00:21:16,540 And I distinctly remember one person saying to me that the TTL cannot be forever, so anything shorter than that is going to be a shorter TTL, right? 226 00:21:16,540 --> 00:21:17,940 So it should be okay. 227 00:21:18,080 --> 00:21:22,540 And I've had one person tell me, I'm going to keep it at five minutes, so it should be okay. 228 00:21:22,620 --> 00:21:24,960 For another person, short is half an hour. 229 00:21:24,960 --> 00:21:26,680 For another person, it's six months. 230 00:21:26,680 --> 00:21:29,260 For another service, it's going to be one year. 231 00:21:29,260 --> 00:21:31,080 So all of this is contextual. 232 00:21:31,420 --> 00:21:36,860 And even if it is the shortest case possible, like, are we okay with that open attack window? 233 00:21:36,860 --> 00:21:38,080 Not really, right? 234 00:21:38,080 --> 00:21:40,260 So what if that's not enough? 235 00:21:40,260 --> 00:21:44,060 What if we want to protect the tokens in all situations? 236 00:21:45,240 --> 00:21:46,420 Token binding. 237 00:21:46,600 --> 00:21:52,360 This is a new concept, and there have been varying opinions on that. 238 00:21:52,360 --> 00:22:05,840 So in this presentation, I'm just going to open up, like, there is a concept of token binding that is available, and also a kind of stopgap measure that could be applicable in case the full-fledged token binding is not available. 239 00:22:05,860 --> 00:22:08,160 So what exactly is token binding? 240 00:22:08,460 --> 00:22:13,520 So in a normal OAuth workflow, you have just a token that is being passed between all the entities. 241 00:22:13,880 --> 00:22:18,940 In case of token binding, there is some contextual metadata that is attached to it. 242 00:22:18,940 --> 00:22:32,060 So in this case, there is a pre-negotiation workflow that happens between the client and the authorization server, where the client registers a key pair with the authorization server. 243 00:22:32,080 --> 00:22:40,540 So with every subsequent call, the authorization server knows the payload that is coming in, and that's going to contain both the token as well as something attached to it. 244 00:22:40,840 --> 00:22:48,680 And the way this happens is during client and server negotiation, there is a payload that is being agreed upon between the client and the server. 245 00:22:48,680 --> 00:22:57,100 And this consists of a token binding ID, which could be anything, but the recommendation is that it be between 0 to 255 characters. 246 00:22:57,360 --> 00:23:02,860 And the other thing that they negotiate is what signature scheme is going to be used for digitally signing the payload. 247 00:23:02,860 --> 00:23:14,440 And this could be the algorithm specified on the slide, and this makes sure that the authorization properly rejects an incorrectly signed payload, because anybody could fake a signature and send it across. 248 00:23:15,060 --> 00:23:16,280 More on that later. 249 00:23:16,540 --> 00:23:31,800 But there are other metadata that is also available that the client can negotiate with the authorization server, and this could be extensions, binding type, or any other custom payload that you want to add, like a token binding message that only the client and the authorization are wary of. 250 00:23:32,120 --> 00:23:39,220 For the purposes of this presentation and tie-ups with other protocols, I am choosing to focus on the token binding ID and the signature schemes. 251 00:23:39,220 --> 00:23:41,900 So, what exactly happens? 252 00:23:41,900 --> 00:23:47,860 During negotiation, now the client has passed on the key pair and the authorization server has registered it. 253 00:23:47,860 --> 00:23:54,480 So, in subsequent calls, what happens is the, as usual, the TLS handshake happens between the client and the server. 254 00:23:54,480 --> 00:24:01,300 There is one additional call that happens, which contains the SEC token binding header that is provided by the client. 255 00:24:01,300 --> 00:24:11,420 Now, what this contains is the EKMI, which is the exporting key material, and this contains the payload and the message that was agreed upon between the client and the authorization server. 256 00:24:11,980 --> 00:24:14,640 Right now, there is API support. 257 00:24:14,640 --> 00:24:17,960 Like, if you're using NGINX or Apache, you do have this available. 258 00:24:17,960 --> 00:24:19,220 You could extend it. 259 00:24:19,340 --> 00:24:21,560 There is for Java 8 and 10 as well. 260 00:24:21,560 --> 00:24:27,120 I have seen rudimentary applications for Django, but wait until it becomes official. 261 00:24:27,680 --> 00:24:43,780 And as you can see in the workflow, you have the SEC token binding header, and then once the authorization server is ready to communicate or provide or provision the client with the tokens, then it basically attaches or connotates the token binding ID to the refresh token. 262 00:24:43,780 --> 00:24:59,380 So, for every subsequent message that comes from the client, you not just authenticate or verify the identity of the client just based on the token that was provided, which could be hijacked, but you also depend on another secret that was shared between the authorization server. 263 00:25:00,440 --> 00:25:06,480 So, some of you may be aware there is no browser support or there's dwindling browser support. 264 00:25:06,480 --> 00:25:08,080 So, what happens in that case? 265 00:25:08,260 --> 00:25:25,100 The developer could still go ahead and do a mutual TLS transaction, and this is expected in the format of JSON web keys, and it happens on a very similar note, except instead of passing you the header, you basically just send across the client certificate, 266 00:25:25,100 --> 00:25:41,020 and then the authorization still has to register it, still has to maintain a separate data store to have this context binding ID, and then with every subsequent call that goes on, you expect, instead of expecting a header or like a connotated, like a token, 267 00:25:41,020 --> 00:25:45,680 you would be expecting a token plus the certificate that was already registered. 268 00:25:47,520 --> 00:26:00,980 Now, if both the, if you're not taken with token binding, and you feel like, Pixie, raise of hands, how many of you are familiar with Pixie? 269 00:26:00,980 --> 00:26:02,420 Or heard of it? 270 00:26:03,180 --> 00:26:04,040 Awesome. 271 00:26:04,040 --> 00:26:07,540 So, Pixie is proof of key code exchange. 272 00:26:07,540 --> 00:26:11,240 This is available as one of the types of OAuth. 273 00:26:11,240 --> 00:26:26,740 This is mainly aimed at mobile and basically workflows where the client secret storage becomes cumbersome, but if you are looking for a context binding solution, then you could look to Pixie as an alternative. 274 00:26:26,780 --> 00:26:32,480 The only way this differs is the initial negotiation call that goes out. 275 00:26:32,480 --> 00:26:39,660 The client provides a code verifier, which is a code challenge, and also provides TM, which is a transformation method. 276 00:26:39,660 --> 00:26:48,980 So, the authorization server knows a code challenge and how it was derived, and that sets up the platform to expect any code challenge that comes with the subsequent workflows. 277 00:26:48,980 --> 00:27:00,900 So, as you can see, the client then provides, or even subsequently uses the access token, then all it needs to do is send a code verifier along with it. 278 00:27:00,900 --> 00:27:09,340 So, again, the assumption here is that you have the code verifier, you don't have the access token, or you have the access token, you don't have the code verifier. 279 00:27:09,420 --> 00:27:13,820 If you manage to sniff both of them, then the situation is FUBA. 280 00:27:16,220 --> 00:27:22,900 So, you saw a couple of screenshots before, and we saw a couple of open redirect CVEs there. 281 00:27:23,000 --> 00:27:27,220 This kind of stood out to me, because how simply it was achieved. 282 00:27:27,500 --> 00:27:38,320 The way this happened was, it was a manipulated redirection URI, and the only unexpected parameter that was passed here was a percentage symbol. 283 00:27:38,740 --> 00:27:45,640 The server side wasn't expecting an extra character, so the validation completely failed, but it didn't fail properly. 284 00:27:45,640 --> 00:27:49,360 So, it still managed to pass on the token to the manipulated redirect URI. 285 00:27:49,440 --> 00:27:54,220 And the other thing which went wrong here is passing the redirect URI in the header. 286 00:27:55,100 --> 00:27:58,600 So, how do you exactly mitigate against this? 287 00:27:59,380 --> 00:28:07,160 Now, the minimal viable solution here is that you extend your trust boundary to include your client. 288 00:28:07,260 --> 00:28:16,580 You are choosing to trust your client that it's going to pass the correct redirect URI in the header, and then the server is going to interpret it and pass the token along. 289 00:28:16,580 --> 00:28:32,680 Now, that is the minimum viable solution here, but if you want to increase your security, but you also want to support providing the access tokens to dynamic URLs, then the other option that is available is to maintain a whitelist of URLs at the server side, 290 00:28:32,680 --> 00:28:39,780 and you expect the client to pass the fully formed URIs, and then you do an exact string matching on a list of URIs rather than one of them. 291 00:28:40,240 --> 00:28:46,780 But then the burdens on the developer, like they have to go and maintain the whitelist, it has to be robust, and all the other things that comes along with that. 292 00:28:47,000 --> 00:28:55,700 The best possible solution, which I'm pretty sure will have some pushbacks, is to maintain exactly one URI which is statically registered with the server. 293 00:28:55,700 --> 00:29:06,740 You do not pass anything in the header, and any time the particular client interacts with the authorization server, because of the registration that happened, the server automatically knows where to send it. 294 00:29:06,740 --> 00:29:12,640 So, there is a one-time compromise that can happen, and subsequent workflows, you're preventing that from being leaked. 295 00:29:14,260 --> 00:29:19,040 So, that was OAuth, and the two issues were token binding and redirect URI. 296 00:29:19,120 --> 00:29:21,660 Moving on for MagicLinks. 297 00:29:21,900 --> 00:29:23,900 So, what exactly is MagicLinks? 298 00:29:23,900 --> 00:29:29,400 You are removing the burden of client secrets, and you expect no passwords. 299 00:29:29,720 --> 00:29:42,040 The only secret that you are generating is a short-lived, hopefully good entropy secret that you are passing along either to the network provider or the email service, who have the burden of storing it. 300 00:29:42,360 --> 00:29:53,500 And here, you depend on, again, short-lived secrets, and you also depend on secure transport for the secret to go from your server to whoever is handling it. 301 00:29:54,300 --> 00:30:06,200 So, in case you know somebody who is going to be implementing passwordless or is taken by it, make sure that they follow the best practices here, or at least these are based on what I have seen so far. 302 00:30:06,200 --> 00:30:16,920 First one is make sure that wherever the secret is being sent, or whichever entity it's being sent to, make sure that the mobile number is verified, and make sure that the email is verified. 303 00:30:16,940 --> 00:30:22,300 It's laughable how many times that the secret is shared for unverified email or mobile numbers. 304 00:30:22,640 --> 00:30:35,920 And the second part is when you're generating a token, make sure that it has sufficient entropy, and like Lakshmi mentioned before, use a good token-generating protocol here, and for example, that is JWT. 305 00:30:35,980 --> 00:30:42,560 And even in that, make sure that you specify who it is issued for, and also make sure that you use the right algorithm. 306 00:30:42,560 --> 00:30:46,080 Even though MD5 is available as an option, please don't head there. 307 00:30:46,780 --> 00:30:49,300 The third point is binding the tokens. 308 00:30:49,300 --> 00:30:59,620 Again, extending the context binding from JWT or OAuth, make sure that you keep track of where the request to generate a secret is coming from. 309 00:30:59,620 --> 00:31:12,100 Make sure that you have a store of whatever secrets you're generating, either in full form or truncated, just make sure you're able to identify it and track it, and also make sure that you're tracking where the responses are coming from. 310 00:31:12,100 --> 00:31:22,460 One of the rudimentary checks you could do is that it's coming from two separate devices, or if you don't want to do that, just keep a track of the source where it's coming from, or how many times it's coming from. 311 00:31:22,840 --> 00:31:27,420 And speaking of how many, make sure that you rate limit the requests that are coming in. 312 00:31:27,940 --> 00:31:44,480 Make sure that the secret generation, it's a finite number, if possible make it singleton, but I know the usability cases where you have to allow it at least like three times or five times, so make sure that you have a rate limit on that, because it's super easy to enumerate and just generate the secret and do a phishing attempt yourself. 313 00:31:45,080 --> 00:31:48,100 So that's on magic links, on to the next topic. 314 00:31:53,240 --> 00:31:54,620 Thank you Divya. 315 00:31:54,780 --> 00:32:13,860 The last part of the presentation today would be about SAML, Secure Assertion Markup Language, and before we talk about the security issues, the remediations, the mitigations that we can have for developers, I would take this opportunity to set some context on why we decided to talk about SAML, 316 00:32:13,860 --> 00:32:15,180 and what is SAML. 317 00:32:16,020 --> 00:32:32,020 So as you guys are aware, people are moving towards the cloud, and according to recent independent research, application developers on an average use around like eight different applications to do the day-to-day activities, to support ID, HR, payroll, 318 00:32:32,020 --> 00:32:34,900 payroll systems, and different internal operations as well. 319 00:32:34,900 --> 00:32:56,260 So we definitely need an enterprise setup, and that's where a single sign-on comes into play, and what we have seen is that the underlying protocol which powers single sign-on is SAML, and when you use a single sign-on, obviously you are not worried about password reuse or multiple password stores, 320 00:32:56,260 --> 00:33:11,100 because attackers always try to hit the weakest link in the chain, and you don't have to have multiple password stores, and talk about password hashing, and how we want to secure those password stores with network isolations as well. 321 00:33:11,480 --> 00:33:28,640 And as you guys are aware, IAM is definitely a challenge, having good authentication and authorization across the board is a challenge for organizations to come up with, and I have also seen that the vendor support is more like a marketing factor or a marketing metric for single sign-on vendors like Okta, 322 00:33:28,640 --> 00:33:37,780 OneLogin, where they try to support, or this is more like a marketing thing that they have, where it's easy single sign-on integrations for organizations. 323 00:33:38,420 --> 00:33:40,360 And what is SAML? 324 00:33:40,640 --> 00:33:57,240 SAML is nothing but an XML data, but with multiple distal signatures and assertions to it, and distal signatures are used to verify the authenticity of the service provider, and also the authenticity of the identity provider, which could be the underlying single sign-on. 325 00:33:57,380 --> 00:34:01,120 And SAML also provides authorization on top of authentication. 326 00:34:01,480 --> 00:34:14,600 They provide user IDs and metadata, which could be like user attributes, which can be used by your portal to do like authentication, and also like make it as granular as possible based on your context. 327 00:34:14,860 --> 00:34:31,240 And if you look at SAML, SAML, a SAML assertion is usually signed, a signed SAML assertion is usually around 7 to 9 kilobytes of data, which is pretty verbose for you or for a library to validate and like provide like the right authenticity and provide the right authorization. 328 00:34:31,980 --> 00:34:36,740 So let's, let's dive into the security issues that we have seen, uh, with SAML. 329 00:34:36,800 --> 00:34:45,460 And as Divya and Lakshmi already mentioned about having like short TTL, having like an expiration, SAML does have something similar to that. 330 00:34:45,460 --> 00:35:03,040 It has something called as not before or not on or after, which is basically the timestamp that your portal needs to like validate or like trust or honor a particular SAML assertion, which could be, which could be infused, infused into the SAML assertion that is signed by the identity provider. 331 00:35:03,380 --> 00:35:29,040 And one of the other things is using like a nonce, which can prevent replay-based attacks where your portal needs to cache the in-response to ID that is part of the SAML request, which is again sent back in the SAML response, which needs to be checked so that we have more like a nonce that would prevent a replay -based attacks where you should not have multiple SAML assertions create or a single SAML assertion create multiple sessions. 332 00:35:29,040 --> 00:35:33,200 It should be like one SAML assertion creating one, one particular user session. 333 00:35:33,520 --> 00:35:47,520 And SAML is, it's, it's, it's nothing but an XML file or just a signature , so we are also applicable to some XML-based issues, which could be external references that could be part of your XML file. 334 00:35:48,400 --> 00:36:05,540 Uh, which could lead to like a DDoS attack on your SAML endpoint, which for example, if you look at this particular diagram where you define an entity, and you recursively call this entity multiple times, which could like exponentially call it and that could lead to like a billion loss attack on your SAML endpoint, 335 00:36:05,540 --> 00:36:11,400 which could like bring down your SAML systems, uh, in, in such a way that it would not be available for alleged users. 336 00:36:11,400 --> 00:36:26,320 And also this could lead to ex, ex, external XML entity attacks where you can have like an XML file or you can have like an internal file like EDC host name sent to a remote server if you don't have the right mitigations for XSEs, which I will be talking in the, 337 00:36:26,320 --> 00:36:27,500 in the future slides. 338 00:36:27,780 --> 00:36:35,540 Um, and SAML has a lot of distal signatures, so I've seen SAML assertions with single distal signatures and multiple distal signatures. 339 00:36:35,740 --> 00:36:49,600 So missing signatures is an attack that, that it's more like a fuzzing attack on your SAML endpoint where you remove the distal signatures and see what your, uh, what your portal is, uh, how your portal is handling those kind of SAML responses or SAML messages. 340 00:36:49,600 --> 00:37:04,420 And signature wrapping attacks is where you kind of like either clone or move your distal signatures around so that to, to, to see if your SAML library or if you're, if you're going to do it manually, if you have like those code to kind of like catch those exceptions when, 341 00:37:04,420 --> 00:37:09,440 when like you clone signatures with your own public key certificate or you move signatures and assertions around. 342 00:37:10,060 --> 00:37:15,280 And one of the recent issues that we saw was about how we parse XML. 343 00:37:15,380 --> 00:37:26,740 Um, like under the word if you, let's say if you're using like a SAML library, like PySAML or PasswordSAML, uh, it uses like an XML tree to parse the entities, the values, the field values of our XML. 344 00:37:26,740 --> 00:37:38,300 And, and this is where like the canonicalization algorithm comes into play where you can introduce like a comment and the way the XML tree parses it could lead to authorization bypass. 345 00:37:38,380 --> 00:37:44,720 So as you see, as you can see, like the left side is where there's an account where it's a fake admin at example.com. 346 00:37:44,720 --> 00:37:59,320 But let's say if you can introduce a comment and if the XML tree parser breaks it down into like text and comments, then you can have like an account or like valid credentials for fake admin at example.com, but you can log in as admin at example.com. 347 00:37:59,320 --> 00:38:08,480 So this is where like you have to make sure the underlying XML tree parser makes, takes into account of like comments with like canonicalization algorithms. 348 00:38:08,920 --> 00:38:14,120 And now let's, let's talk about the mitigations that we have for, um, XML-based security issues. 349 00:38:15,060 --> 00:38:22,520 Definitely I've seen that we, uh, application developers use a lot of XML validation libraries, like as I already mentioned, PyXML, PassportXML. 350 00:38:22,520 --> 00:38:36,700 So using the right validation library, uh, which are, which can catch these exceptions that we spoke about or the security issues and which, which has been like patched for all the security issues is one of the mitigations that you can have to, uh, to come up with a good SAML, 351 00:38:36,700 --> 00:38:38,440 um, uh, implementation. 352 00:38:38,680 --> 00:38:56,120 And also disabling external entity is very important, uh, because when you have like a SAML endpoint, you don't have, I mean in most of the cases you don't need to like have external references, uh, because SAML is more like an encapsulated file which has everything to verify the authenticity of a particular, 353 00:38:56,120 --> 00:38:58,280 uh, particular, uh, identity provider. 354 00:38:58,280 --> 00:39:05,660 So you can disable the external entities to be false so now we are not vulnerable to excesses on our SAML endpoint. 355 00:39:06,000 --> 00:39:13,880 And the other thing is to prevent like a DDoS attack, like a billion laughs attack, you need to have some kind of a memory constraints, memory restrictions. 356 00:39:13,960 --> 00:39:22,360 That's where you can have like a, you can configure a security manager, uh, at your, in your endpoint that will either turn off or limit the entity expansion. 357 00:39:22,360 --> 00:39:35,460 So now you have some memory restrictions so that you hit, when you hit a particular memory computation power, then the, the SAML particular, the particular function is going to like break so that we don't have like a DDoS attack on our SAML endpoints. 358 00:39:35,460 --> 00:39:39,960 And it's configuring a security manager is very, is very important to prevent billion laughs attack. 359 00:39:40,500 --> 00:39:42,860 And also look at other alternatives. 360 00:39:42,860 --> 00:40:00,540 I think the industry is also moving towards open ID connect where it's trying to, it's trying to come up with more like a jot after your single sign on where it's less verbose, it's easy to, uh, interpret and correlate what the metadata of that particular token is rather than looking at a file which is around like 7 to 9 kilobytes. 361 00:40:00,540 --> 00:40:03,620 So look at alternatives for, um, for a single sign on. 362 00:40:04,120 --> 00:40:17,740 So now I, I think we have covered different authentication patterns and we just wanted to kind of brief on like the common, commonalities that we have seen across different authentication patterns, let it be JWT, OAuth, or SAML or Passwordless. 363 00:40:17,740 --> 00:40:24,100 So some of, these are some of the things that we would want to brief about which is, which are token metadata. 364 00:40:24,100 --> 00:40:33,380 So look at token metadata and token metadata can be used to provide very granular access controls and also like granular authorization for your, uh, portal. 365 00:40:33,400 --> 00:40:35,640 And the choice of algorithm is very important. 366 00:40:35,640 --> 00:40:42,180 Like based on the use case, if secret sharing is easier then you can like look into a symmetric encryption, if not then you can look at public encryption. 367 00:40:42,180 --> 00:40:44,700 So algorithmic choice is very important as well. 368 00:40:44,700 --> 00:40:46,260 And insufficient validation. 369 00:40:46,260 --> 00:40:53,780 So any kind of authentication pattern comes with, comes with multiple layers of defense where like there are multiple validations in place. 370 00:40:53,780 --> 00:41:07,540 So look into like combining validations, not just like rank or just one validation because that could like be programmed incorrectly where we could like lead to like bypass issues or author, authentication and authorization bypass issues. 371 00:41:07,560 --> 00:41:13,200 And missing context is also very important because we have seen that in JWTs and as well as in Passwordless. 372 00:41:13,200 --> 00:41:22,180 So you do need to understand the context of your application so that you can decide which authentication approach would be the best for your application. 373 00:41:22,300 --> 00:41:29,660 And also, um, understand which, like which kind of encryptions or which kind of algorithms you can use for your, for your applications. 374 00:41:30,040 --> 00:41:43,800 Um, and yeah, I mean like just to conclude, I think there are multiple ways to authenticate and we have not touched on like all the different authentication patterns but we, uh, did pick on a few and we wanted to talk about them, talk about the bad practices, 375 00:41:43,800 --> 00:41:45,960 talk about the mitigations which we, which we have done. 376 00:41:45,960 --> 00:42:01,200 And also we have seen that being application security engineers, uh, we also work very closely with developers, uh, educate them, empower them so that they can like securely, um, have like the most secure authentication, uh, in place. 377 00:42:01,260 --> 00:42:07,080 Um, so yeah, um, this was our talk and we are now open for any Q&A's. 378 00:42:28,260 --> 00:42:35,300 Uh, is, is, is the question about, uh, like digital signature bypass or authorization bypass? 379 00:42:37,800 --> 00:42:59,540 Uh, for only for .NET, uh, I think we, we have come, we have come across like, uh, very common use cases where there was a signature bypass that was reported by Duo Security where like most of the SAML libraries , whether it's Okta or OneLogin, where you can like include like a common and like do like a signature bypass. 380 00:42:59,600 --> 00:43:02,940 But I don't have any specifics for just for .NET. 381 00:43:02,940 --> 00:43:05,320 I, I can definitely , uh, look into that. 382 00:43:05,320 --> 00:43:08,280 Okay, so, uh, the presenter was Alvaro Nunes. 383 00:43:08,280 --> 00:43:08,480 Okay. 384 00:43:08,480 --> 00:43:10,420 The talk was SSO works. 385 00:43:10,420 --> 00:43:11,740 It was a brilliant issue. 386 00:43:11,740 --> 00:43:12,380 Cool, okay. 387 00:43:12,380 --> 00:43:12,980 I'll do that. 388 00:43:12,980 --> 00:43:13,700 Thank you. 389 00:43:14,620 --> 00:43:15,500 Yes. 390 00:43:15,840 --> 00:43:16,140 Uh 391 00:43:27,970 --> 00:43:30,510 , the token stealing in JWT. 392 00:43:31,130 --> 00:43:34,790 Okay, uh , the question was about how do you prevent token stealing? 393 00:43:34,790 --> 00:43:37,350 So I think, uh, uh, come . 394 00:43:37,350 --> 00:43:38,610 In JSON Web Tokens. 395 00:43:38,870 --> 00:43:40,150 In JSON Web Tokens. 396 00:43:40,150 --> 00:43:40,710 Okay. 397 00:43:40,710 --> 00:43:42,750 So, token could be stolen. 398 00:43:42,750 --> 00:43:48,650 I mean, sending over HTTPS is of course, uh, sending over TLS is a pretty good, uh, prevention as such. 399 00:43:48,710 --> 00:43:52,530 But even if tokens, uh, so I think that's where the other parts of the defense come in. 400 00:43:52,530 --> 00:43:59,830 Even if tokens are stolen, uh, you still like, uh, can have like some of the things in place where, oh, okay. 401 00:43:59,830 --> 00:44:08,310 The problem is with respect to like, uh, that's where I think what she spoke about came into picture, like avoid like leaking tokens through referers or like any of the other headers. 402 00:44:08,310 --> 00:44:15,510 So other compensation controls come into place as such, because we cannot prevent like, I mean, any kind of token, right? 403 00:44:15,510 --> 00:44:17,110 Even whether JWT or not. 404 00:44:17,110 --> 00:44:26,370 But one of the things you could do is also not have too much sensitive information inside your JSON key value pair, because anyone who sees, uh, gets a token can actually view all of the details. 405 00:44:26,370 --> 00:44:31,390 So it's mostly compensation controls around any kind of token and that applies to JWTs as well. 406 00:44:42,740 --> 00:44:43,280 Yeah. 407 00:44:43,280 --> 00:44:45,180 You can use... 408 00:44:45,720 --> 00:44:47,320 Using custom parameters? 409 00:44:50,260 --> 00:44:50,840 Yeah. 410 00:44:50,840 --> 00:44:52,680 I mean, I, we can definitely do that. 411 00:44:52,780 --> 00:45:03,580 Um, but since, I mean, as you're aware, uh, since the payload is base 64, base 64 encoded, like anybody can decode it, so we don't want to put anything that is very sensitive. 412 00:45:03,660 --> 00:45:06,560 So one of the things that I've seen is using the JIT. 413 00:45:06,800 --> 00:45:20,860 So what we have seen is like, let's say if the JIT, if this particular JIT and if that particular, if there are like a lot of requests with this particular JSON web token, but it has like mul- like mul- there are multiple times the signature was invalid, 414 00:45:20,860 --> 00:45:31,540 then we have some kind of like IP tracking system to kind of like detect those in places where this particular JWT with this particular JIT is kind of like fuzzing on the digital signature and we want to like identify those. 415 00:45:31,540 --> 00:45:41,680 And that's the thing where we kind of like have a pipeline of like identifying those and put it into a central system so that we, we would say that, okay, these are the bad JITs that are out there, so don't trust them. 416 00:45:41,680 --> 00:45:44,820 And like probably like work on like global lockout for that. 417 00:45:44,820 --> 00:45:50,920 But yeah, I mean, to answer your question, we can definitely put like a source IP, like how AWS does for its IAM roles. 418 00:45:50,920 --> 00:46:04,420 We can definitely do that, but we, it's just that we don't want to put a lot of data, like a lot of PII or sensitive data into, into like a JSON web tokens because we don't encrypt it, we just send it over TLS, so any service can base 64 decode it and like look at that. 419 00:46:04,420 --> 00:46:09,740 But yeah, that, I, I think we can definitely look into putting in like a source IP, doing some IP whitelisting as well. 420 00:46:21,600 --> 00:46:27,000 So if I understood correctly, you wanted recommendations on token binding for mobile apps. 421 00:46:31,600 --> 00:46:34,900 So, okay, he did bring it up. 422 00:46:34,900 --> 00:46:37,820 So I wanted to include it in the presentation, but good that you brought it anyway. 423 00:46:37,900 --> 00:46:42,100 So the way it happens is on mobiles, there is like two agents working on it. 424 00:46:42,100 --> 00:46:50,080 So if you follow the best practices and keep them separated, the code verifier and the token as they are meant to be, the event of compromises lessens. 425 00:46:50,400 --> 00:46:54,540 So I wouldn't, how do you store secrets right now? 426 00:46:54,540 --> 00:46:59,100 Like if you're using general OAuth for mobile devices, like where do you store them? 427 00:47:05,250 --> 00:47:07,070 Yeah, that is correct. 428 00:47:07,070 --> 00:47:11,430 Yeah, you could always reverse engineer and get all the secrets that are baked in. 429 00:47:11,670 --> 00:47:19,090 But the, but the security that Pixie brings in is that it's two agents kind of communicating and doing the traffic workflow. 430 00:47:19,090 --> 00:47:23,510 So even in the event of one compromise, the entire system doesn't get compromised. 431 00:47:23,510 --> 00:47:33,570 So I would say just storing both of them in separate apps or separate agents would still give you that security, but eventually all of them would get reversible. 432 00:47:33,570 --> 00:47:38,370 Unless you want to invest on another server where the mobile actually communicates with that. 433 00:47:38,370 --> 00:47:41,670 And then the secret is basically removed from the mobile device entirely. 434 00:47:42,050 --> 00:47:43,890 That would be an overkill. 435 00:47:49,740 --> 00:47:50,040 Yeah. 436 00:47:54,030 --> 00:47:58,330 The, the dynamic use case with OAuth is always a little bit iffy. 437 00:47:58,430 --> 00:48:07,750 So pre-registering always removes that attack vector in case if it is dynamic, then you could definitely do composition controls on the server end. 438 00:48:08,290 --> 00:48:08,750 Yeah. 439 00:48:11,150 --> 00:48:16,690 If you have other questions, you can definitely reach out to us, but we are out of time. 440 00:48:16,690 --> 00:48:18,430 So thank you for being a great audience.