News for hackers. Stuff that matters.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by metadat on Wednesday October 25, 2023 @10:28PM (#38020992)
Re:'Log in with ' Feature Allows Full Online Account Takeove... by Spivak on Thursday October 26, 2023 @12:33AM (#38021626)
What am I missing here? How do you mess this up? Like you redirect to the OAuth provider with a url that has your client_id and ask for a postback and you get it with a code, you use that code plus your app's client_id/secret to get user-creds and then query some API to figure out who just authed. The code is tied to your client_id/secret. You have to implicitly verify the code you got just to figure out who logged in.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by michaeljx on Thursday October 26, 2023 @03:02AM (#38022592)
An attacker could call the post back with a code generated for another client_id. When you use the code to query who logged in, Facebook will still respond, even if the code was not generated for your client_id
Re:'Log in with ' Feature Allows Full Online Account Takeove... by rosswilson on Thursday October 26, 2023 @05:33AM (#38023529)
This shouldn't be possible as the server-to-server request to Facebook to exchange the Authorization Code for an Access Token requires the client_id and client_secret to be provided. Facebook should (though I haven't actually confirmed this) verify that the code was issued to the given client_id. If the code was issued for client 123, when client 456 tries to exchange it for an Access Token Facebook should throw an error.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by michaeljx on Friday November 03, 2023 @07:54AM (#38127371)
Yup that's the thing, Facebook doesn't do that. The token is the only thing needed, no validation on their half if it matches a client id
Re:'Log in with ' Feature Allows Full Online Account Takeove... by jorams on Thursday October 26, 2023 @04:06AM (#38023009)
What you describe is the explicit grant flow and the exchange of the code for an access token automatically protects against this vulnerability. The bugs here are in the implicit grant flow where the redirect doesn't include an opaque code but an actual access token. There the application is responsible for validating that the token is for that application, but there's nothing that requires it to do that.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by dboreham on Thursday October 26, 2023 @09:09AM (#38025019)
I'm a little confused about this. The article seems to say that the application (the server that is the target of the attack) makes a call to FB where the application believes that a successful response indicates that the user's credentials are valid. It says that FB responds with success (and the user's email). But in fact FB would respond with success regardless of whether the supplied token was valid (for that application). This seems like either a serious bug in FB's implementation, or very bad API design. Presumably it's the latter because FB is responding correctly to a request that has nothing to do with auth -- application (server) asked for the email for one of its users, providing its (the server's) credentials for that request. The problem is that the API doc/design has fooled the application developer into believing that that call was an auth check. But it wasn't.

Is that it?

Also...why is this not wrapped in a library such that it wouldn't be possible to make such a mistake?

Re:'Log in with ' Feature Allows Full Online Account Takeove... by locallost on Thursday October 26, 2023 @10:19AM (#38025930)
"Facebook" (or whoever) just sends a token that says the user authorized the use of its account for the application. What happens in this 'hack' is that the token is valid, but was not actually intended for that application, but for another one (e.g. a malicious one, that is now trying to reuse the token to access other services of the same Facebook user). I don't know how Facebook tokens look like, but JWTs have a property called aud/audience indicating who the token was intended for. The application developer must verify that the token was actually intended for their application. That is my understanding, sorry if I got it wrong.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by dboreham on Thursday October 26, 2023 @01:29PM (#38028858)
I get that. You're not wrong. I'm asking why Facebook tells the application anything other than "nope, that's not valid for you"? It doesn't seem to be a case of the application will accept random noise as a valid token. It does send the token to Facebook and Facebook responds with something that looks like "OK". But when they said "OK" they really meant "we gave you some valid information about the target user, but forgot to mention that the token you provided was not valid".

I'm saying that Facebook should in all cases respond with "Nope, that's not a valid token". Their API just shouldn't have a way to get data on a user without providing a valid token (by valid, we mean valid for that purpose, not stolen from somewhere).

Re:'Log in with ' Feature Allows Full Online Account Takeove... by locallost on Thursday October 26, 2023 @03:40PM (#38030743)
Because I guess in this "flow", you do not actually supply the information to Facebook for them to verify that claim. From the article:

> In steps 6-7: > randomsite.com reads the token from the URL and uses it to talk directly with Facebook using the following API:

> https://graph.facebook.com/me?fields=id,name,email&access_to....

> The response is [email protected].

So you send the token only and the token is valid, and there's no way for Facebook to check if it was meant for you or not. As mentioned in other posts, this would not happen in other flows because you would send e.g. your client secret along with the code.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by fulafel on Friday October 27, 2023 @01:05AM (#38034901)
The question still is, are Facebook failing to associate the token with the application context that requested it?
Re:'Log in with ' Feature Allows Full Online Account Takeove... by locallost on Friday October 27, 2023 @03:38AM (#38035750)
Failing sounds like its a requirement for them to do it, but this is not true. If you send them just a token, then how would they associate it with the application? Like I said, in another flow where you send your client secret and a code to exchange for the token, they need to verify it and it would be a failure on their part if they didn't.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by fulafel on Sunday October 29, 2023 @03:18AM (#38056451)
They have the client id when the token is requested, so they can associate the generated token with it by either keeping some state or encoding it in the token, no?
Re:'Log in with ' Feature Allows Full Online Account Takeove... by TazeTSchnitzel on Thursday October 26, 2023 @02:09AM (#38022233)
> Vidio, an online streaming platform with 100 million monthly active users, the researchers found that when logging into the site through Facebook, the site did not verify the token — which the website developers and not OAuth must do. Because of this, an attacker could manipulate the API calls to insert an access token generated for a different application, the researchers found.

How does this work? I thought the token was an opaque hex string and only had meaning when sent back to the original server?

Re:'Log in with ' Feature Allows Full Online Account Takeove... by vladvasiliu on Thursday October 26, 2023 @02:31AM (#38022387)
IIRC, the user woud get an access token from Facebook for the target site, e.g. Vidio. Vidio then has to make sure that not only is the token actually signed by Facebook, but also that Vidio is the token's audience. The token shouldn't be opaque to Vidio.

I'm in no way an authority on OAuth, but I think the "opaque token" you're talking about is in the situation when Vidio would want to access Facebook on the user's behalf: they would get an access token for Facebook. The token can be opaque to Vidio.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by Incipient on Thursday October 26, 2023 @02:39AM (#38022443)
Not being a full expert on it either, that flow is roughly right. Vidio does have to validate it. The entire pkce flow is bloody painful to implement, and it's actually quite hard to do it perfectly, and easy to accidentally skip a part of it and have it seemingly work ok.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by tommiegannert on Thursday October 26, 2023 @02:46AM (#38022493)
The original article [1] explains it much further:

> As you read previously, according to the Facebook documentation, when Vidio.com receives the access token from the user, Vidio should verify that the access token was generated to its App ID (92356) by calling the https://graph.facebook.com/debug_token API.

Confirming what vladvasiliu said.

1. https://salt.security/blog/oh-auth-abusing-oauth-to-take-ove...

Re:'Log in with ' Feature Allows Full Online Account Takeove... by arcastroe on Thursday October 26, 2023 @03:43AM (#38022867)
Gitea serves as an OIDC provider:

* https://docs.gitea.com/next/development/oauth2-provider

However, I don't see an equivalent API in gitea to the "debug_token" api.

If I'm developing an application that allows "Login with Gitea", how do I make sure my application is not vulnerable?

Re:'Log in with ' Feature Allows Full Online Account Takeove... by vladvasiliu on Thursday October 26, 2023 @03:54AM (#38022934)
See caseysoftware's reply: https://news.ycombinator.com/item?id=38022536

The access token usually has an `aud` field that says for whom it is.

I'm not familiar with Gitea's implementation, but reading your link, it would seem that it acts as an oauth2 provider so that 3rd parties can access Gitea, not some other random app.

> Gitea supports acting as an OAuth2 provider to allow third party applications to access its resources with the user's consent.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by caseysoftware on Thursday October 26, 2023 @02:54AM (#38022536)
The token can be a opaque string but doesn't have to be. Often, it's a JWT which can be decoded, validated, and used locally without a trip to the auth server.

It looks like Vidio, etc validated the signature of the JWT properly but didn't check the "aud" or audience claim, which defines who should use it. Therefore, it was a valid token, it was for the target user, but the token itself wasn't for Vidio.

It's the equivalent of buying a ticket for a United Airlines flight, going to the airport, and United letting you get on ANY flight because you have a valid ticket.

Background: I helped build the Okta OAuth product (not related to the breaches) and I'm the author of the top OAuth/OIDC course on linkedIn.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by withinboredom on Thursday October 26, 2023 @03:15AM (#38022672)
Heh, this is exactly how I got on the wrong flight once (the gate changed and I didn’t realize it), the machine didn’t tell the person I was getting on the wrong flight and the attendant didn’t notice.

The only reason I discovered I was on the flight is because someone else had a ticket for my seat. The security people were very curious how I did it. But now you can’t do that any more.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by magicalhippo on Thursday October 26, 2023 @03:51AM (#38022923)
Not just aud, but also issuer and you should check it was signed by a proper certificate no?

https://learn.microsoft.com/en-us/entra/identity-platform/ac...

Re:'Log in with ' Feature Allows Full Online Account Takeove... by vladvasiliu on Thursday October 26, 2023 @03:59AM (#38022966)
Indeed.

In my case, I was initially confused by the fact that in most examples (specifically for Azure AD, which is what I've used), they give you an access token for another app, here MS Graph API. It specifically says you're not supposed to read that access token, so you can't validate it. You should use the ID token instead (which can be validated), but in the default configuration, the ID token doesn't carry much information, so you need to call the `userinfo` endpoint with said opaque access token.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by PeeMcGee on Thursday October 26, 2023 @08:16AM (#38024523)
For Microsoft it's another case of them going out of their way to exercise every possible inch of lee-way permitted by the specifications. No one in their right mind should expect a userinfo endpoint to only be accessible at an entirely different host. It's doubly stupid that Azure AD provides no other options for remote token validation, conveniently skipping the token introspection extension that _every other IdP supports._

People writing OAuth2 clients reasonably assume that trustworthy IdP's will behave normally and predictably, which means Azure AD/Graph(/Entra ID?) is probably not compatible with the libraries you're using. Fortunately Microsoft provides their own perplexing, over-engineered SDK for a handful of languages. All you have to do is rip apart your existing OAuth2 plumbing and carve another Microsoft-sized hole into your otherwise nice and standardized application.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by vladvasiliu on Thursday October 26, 2023 @09:05AM (#38024973)
In my case, for apps that only need to authenticate users with AzureAD, I've added the required information to the tokens and called it a day.

I wouldn't bet the farm on it, but I seem to remember that by default, the mozilla-oidc implementation for Django was expecting an userinfo-like endpoint. And I remember wasting an unbelievable amount of time trying to figure how to add information to that endpoint. I've never found anything, I just patched the lib to retrieve the relevant fields from the tokens.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by jillesvangurp on Thursday October 26, 2023 @05:11AM (#38023403)
Depends. The core issue is that a lot of developers confuse authentication and authorization. And oauth kind of muddles the water on that front by vaguely doing both but not really. All it does really is exchange tokens (assertions).

Anything JWT related is orthogonal to oauth. Oauth does not actually provide any semantics for the tokens you exchange. They might be JWTs and you might be able to verify them. Or they might just be some random number, a hash, or some kind of database id. But you would have to know in advance what it is exactly and what the proper process for verifying the token is.

In the case of a random number or some kind of session id, the process of verifying that token would involve looking it up from some kind of database or via some kind of API.

Alternatively, with a JWT, it might be a signed one (hopefully) and you'd be able to check the signature if you have the public key. All you have at this point is a blob that was signed by someone that you might or might not trust. The claims and other meta data in the token would tell you hopefully who the person is (authentication) and the level of access they might be given (authorization). The JWT spec defines some fields that you might use for that. But it's up to you to check all those things and verify them.

The point is, that a lot of this stuff is simply implementation/vendor specific and you just need to know what to check and how and why. And it's on you to do all those things.

This is not an issue with oauth, or JWTs, but with incompetent developers doing things wrong or being lazy/negligent/indifferent. Which sadly is very common. Lots of people that get busy implementing all sorts of stuff without any formal training. And a lot of this stuff isn't even taught properly in schools/universities.

This falls in the same category as putting passwords plain text in a database, not setting up ssl certificates, running your database on an open port on the internet, and similar things that developers do wrong all the time. Because they don't even know the basics of how to do things right. A lot of these things would be caught during any half decent audit. And quite a few of those things could expose the companies involved to some expensive law suits. Which is why lots of companies spend money on audits because they don't like expensive law suits.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by arka2147483647 on Thursday October 26, 2023 @06:22AM (#38023773)
Nope.

The thing about cryptography you always hear being said is "don't roll your own crypto", because you don't know all the complexities and failure modes that experts have researched.

In o-auth, just you comment mentions multiple ways of doing things, and different responsibilities the developers have in different circumstances. Essentially the developer is forced roll some of their own auth.

Compare that, for example, to say how you use TLS. You just use the standard libs bundled everywhere, and open connection, and the the system does all the validation for you. The complexity is there, but average developer is not expected to understand it.

O-auth simply exposes too many details to the average developer, and too many options to use them differently, for it to ever be secure.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by robertlagrant on Thursday October 26, 2023 @07:43AM (#38024281)
While what you say is true about OAuth2, this isn't what "don't roll your own crypto" refers to, I think. It's more like "don't start implementing crypto routines yourself".
Re:'Log in with ' Feature Allows Full Online Account Takeove... by jillesvangurp on Thursday October 26, 2023 @07:46AM (#38024303)
That's just the way oauth works. I agree it's a messy protocol. Classic design by committee stuff. Exactly what you get when mutually incompatible security product vendors try to create a standard that covers what all of them do.

Unfortunately, there are no good alternatives that don't have this problem. Basically people use all sorts of commercial products in the hopes that it will act like magic security pixie dust. Most of them are super complicated to work with. Or expensive. Or both.

There's just no way around the fact that you need to know what you are doing and how stuff sticks together.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by withinboredom on Thursday October 26, 2023 @07:55AM (#38024366)
> incompetent developers doing things wrong or being lazy/negligent/indifferent. Which sadly is very common.

I was code reviewing a dev who was implementing some auth and I mentioned they should log something for audit purposes. They said 'auditing isn't one of the requirements of this ticket' ... at which point, I knew it was time to leave. Like do you need someone to write a ticket to do your job? When people come ask "who logged in and deleted my org's content" ... you better have an answer. This is software engineering 201: logging.

It's like an electrical engineer wiring a house not up to code and saying 'I don't care because the customer didn't ask for it to be up to code.'

Re:'Log in with ' Feature Allows Full Online Account Takeove... by namtab00 on Thursday October 26, 2023 @09:27AM (#38025221)
I get what you're saying, but... Logging is not auditing, AFAIK.

Also, and I may be very wrong based on the way that org prepared tasks, he may have been signaling scope creep... If it's not in the task, you don't do it. If you think it should be done, you backlog it...

Re:'Log in with ' Feature Allows Full Online Account Takeove... by AckRite on Thursday October 26, 2023 @10:19AM (#38025937)
I agree with the comment above yours but also feel that this is... different style of work? Or attitude? Not sure how to name it but feels like I also brushed up against this numerous times.

I assume that line of "what is scope creep and what is assumed to be in scope even if not written down" has to be blurry but I tend to judge people on which side they end up on, because I feel it correlates to indifference etc.

Ultimately, it feels like a bad approach to work relationships - you actually have to do personal groundwork in your team to unblur the line to where you and your team agrees. And if that doesn't work out - leaving is a valid, if sad, option.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by withinboredom on Thursday October 26, 2023 @11:13AM (#38026658)
Not to be pedantic, but it's called an "Audit Log", usually. So, it is logging, though if you don't keep your logs forever, it is usually logged to a db or something (but that isn't necessary -- depends on the industry, privacy policy, etc.).

> If it's not in the task, you don't do it. If you think it should be done, you backlog it...

You shouldn't have to be told to do your job. One day, someone is going to ask why X wasn't done (when it clearly should have been, by all industry standards, and especially when it is exactly one line of code) and "I was just following orders" doesn't work in any court, including the ones that get you fired.

When implementing auth, almost no PM is going to write down "mitigates timing attacks" as part of the acceptance criteria, but you do it anyway because it is the right way to do it.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by pixl97 on Thursday October 26, 2023 @03:29PM (#38030603)
And none of those things come down to the individual dev in any sizable organization I've ever seen. Suddenly you've started adding a db schema new db schema to the requirements and are likely blowing up the sprint.

You push the ticker back up and fire off a few email to PM and ask what the hell they are doing with the requirements

Re:'Log in with ' Feature Allows Full Online Account Takeove... by withinboredom on Thursday October 26, 2023 @05:56PM (#38032218)
Who said anything about db schemas? WTF are you talking about?
Re:'Log in with ' Feature Allows Full Online Account Takeove... by pixl97 on Thursday October 26, 2023 @08:29PM (#38033341)
Where you throwing your audit data? Kibana?
Re:'Log in with ' Feature Allows Full Online Account Takeove... by withinboredom on Friday October 27, 2023 @03:12AM (#38035595)
That's an implementation detail so far from what we're talking about that its almost nonsense. Even if you don't have any infrastructure at all, simply injecting a NullLogger and audit logging to it is better than nothing at all (and filing a ticket to address that ASAP). That's two lines of code, but what I was talking about was exactly one line of code because the infrastructure already existed.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by phatskat on Thursday October 26, 2023 @02:14PM (#38029565)
> he may have been signaling scope creep... If it's not in the task, you don't do it. If you think it should be done, you backlog it...

Correct. Especially if you’re working for a client that’s billing by hour. Regardless, new work changes scope and blah blah agile. Yes it’s overhead, and it also creates a chain of who did what, and when.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by withinboredom on Friday October 27, 2023 @07:53AM (#38037320)
I fail to see how adding "$this->auditLog->info('user logged in', $details)" is scope creep. Maybe you can help me out?

This is no different than suggesting a change in the code (in PHP) from:

    $password === $expectedPassword;
to

    hash_equals($expectedPassword, $password);
where the hash_equals function is a timing-attack resistant comparison.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by caseysoftware on Thursday October 26, 2023 @09:27AM (#38025225)
While what you're saying applies to OAuth in general, there are a lot less variables in this situation.

This was specifically "Sign in with.." so we know it was OpenID Connect which mandates signed JWTs for ID tokens. Those JWTs would have an issuer (the social provider) to determine their source and the client id (to determine the intended app) so those aren't in question here.

Further, since these are ID tokens, they WOULD provide authentication information (technically identity info) and minimal authorization info.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by caseysoftware on Thursday October 26, 2023 @09:21AM (#38025151)
The articles say these sites were validating the tokens - as in checking signatures - so they were doing that properly.

The issuer is another matter. Facebook or any other social provider is different than using AD. With AD, every customer would have a separate and distinct issuer related to their specific org and config. For social auth, there would be ONE issuer that everyone shares.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by duttonw on Thursday October 26, 2023 @02:11AM (#38022259)
something something jwt token for implicit flow OAuth I'd guess.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by Incipient on Thursday October 26, 2023 @02:39AM (#38022449)
Should be pkce now. I think implicit flow is entirely dead? But could be wrong.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by duttonw on Thursday October 26, 2023 @02:43AM (#38022468)
it should be but auth0 was not forcing it to be off, just highly suggesting to turn off that 'feature' unsure now.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by duttonw on Thursday October 26, 2023 @02:45AM (#38022485)
Another option is pkce spa, if they did not do 'auth' checks that the jwt token was indeed signed by auth0 or similar, a carefully crafted js alteration would let you take control of the front end. Then you could give it a incorrectly signed token with all the correct details for another user. Usually they would only use the email for matching which makes things even more trivial.

You would hope they verified the signing of the jwt token on the backend, but seems thats too difficult for many dev's.

Re:'Log in with ' Feature Allows Full Online Account Takeove... by tansan on Thursday October 26, 2023 @04:51AM (#38023286)
PKCE should only be necessary if you're using app linking or have some client app in-between. If you completely trust the server than implicit is fine.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by krooj on Thursday October 26, 2023 @11:58AM (#38027412)
No. This is wrong. Implicit is deprecated in favor of authorization_code + PKCE
Re:'Log in with ' Feature Allows Full Online Account Takeove... by krooj on Thursday October 26, 2023 @12:01PM (#38027464)
The important thing with PKCE is that it's not completely secure, either. A malicious actor can create an app that uses your client_id and its own code_challenge and verifier. In the event that there are any issues with redirect jacking, such as may be the case with custom schemes on mobile, you're hosed. The only way around this is to use intents (on Android) and OS pinning in the client configuration of your authorization server.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by victor106 on Friday October 27, 2023 @03:58PM (#38043176)
> redirect jacking, such as may be the case with custom schemes on mobile, you're hosed.

How is this possible, any examples?

> intents (on Android) and OS pinning in the client configuration of your authorization server.

Can you please elaborate?

Re:'Log in with ' Feature Allows Full Online Account Takeove... by tommiegannert on Thursday October 26, 2023 @02:43AM (#38022469)
Original: https://salt.security/blog/oh-auth-abusing-oauth-to-take-ove...

Oh-Auth - Abusing OAuth to take over millions of accounts

Re:'Log in with ' Feature Allows Full Online Account Takeove... by dang on Thursday October 26, 2023 @03:35AM (#38022815)
Thanks! We've moved the comments to https://news.ycombinator.com/item?id=38009291, which submitted that link.
Re:'Log in with ' Feature Allows Full Online Account Takeove... by moribvndvs on Thursday October 26, 2023 @09:11AM (#38025044)
Who knew that putting all your authentication eggs in one basket was a bad thing?