News for hackers. Stuff that matters.
Re:Zero-day in Sign in with Apple by phamilton on Saturday May 30, 2020 @12:44PM (#23362419)
> The Sign in with Apple works similarly to OAuth 2.0.

> similarly

I understand why they wanted to modify OAuth 2.0, but departing from a spec is a very risky move.

> $100,000

That was a good bounty. Appropriate given scope and impact. But it would have been a lot cheaper to offer a pre-release bounty program. We (Remind) occasionally add unreleased features to our bounty program with some extra incentive to explore (e.g. "Any submissions related to new feature X will automatically be considered High severity for the next two weeks"). Getting some eyeballs on it while we're wrapping up QA means we're better prepared for public launch.

This particular bug is fairly run-of-the-mill for an experienced researcher to find. The vast majority of bug bounty submissions I see are simple "replay requests but change IDs/emails/etc". This absolutely would have been caught in a pre-release bounty program.

Re:Zero-day in Sign in with Apple by zemnmez on Saturday May 30, 2020 @12:58PM (#23362579)
> I understand why they wanted to modify OAuth 2.0, but departing from a spec is a very risky move.

The token described in this disclosure is an OpenID Connect 1.0 Token. OIDC is a state of the art AuthN protocol that supersets OAuth with additional security controls. It's used by Google, Facebook and Twitch amongst others.

I'd do more analysis, but the author leaves off the most important part here (not sure why)

https://openid.net/specs/openid-connect-core-1_0.html#IDToke...

Re:Zero-day in Sign in with Apple by thephyber on Saturday May 30, 2020 @01:43PM (#23363012)
The important part is in the author’s article. The POST to the opened endpoint generates a valid JWT token for the email address in the payload, not for the one in the logged-in session. Everything else is extraneous.
Re:Zero-day in Sign in with Apple by fouc on Saturday May 30, 2020 @11:29PM (#23366936)
Oh man, that is classic sloppy web development.

It's often so easy to reach for the values in the params/payload first because you're already working with them, instead of remembering to use the session values instead.

This would be a great audit to do for entire codebases.. Just check all places that are using params/payload values and see if there's actually already a session value that should be used instead.

Re:Zero-day in Sign in with Apple by rags2riches on Sunday May 31, 2020 @01:57AM (#23367542)
Don't just audit. Strengthen the critical APIs with types. A user provided string is not the same type as an authentic identity. Make the developer be explicit about the critical mistake about to be made. Perl had this down decades ago with the tainted checks.
Re:Zero-day in Sign in with Apple by amenod on Sunday May 31, 2020 @05:46AM (#23368394)
This, thousand times. Don't just fix the bug, fix the process that led to the bug. Developers are (usually) not malicious, but we are often working with tooling which makes mistakes easy to do, difficult to detect and grave in consequences. Fix the tooling, not just the bug.
Re:Zero-day in Sign in with Apple by mehrdadn on Sunday May 31, 2020 @12:04AM (#23367091)
I wonder if encoding the query params with some dumb encoding (maybe a custom variant of base64?) and forcing decoding at every usage site would make it inconvenient enough to cause programmers to use the session values instead?
Re:Zero-day in Sign in with Apple by dtech on Saturday May 30, 2020 @05:50PM (#23365080)
That also explains why Apple could exclude abuse happening in the logs, which some commenters have refuted.

If they have all the JWTs, seeing if one had a different e-mail than the logged-in user should be fairly doable.

Re:Zero-day in Sign in with Apple by SV_BubbleTime on Saturday May 30, 2020 @03:42PM (#23363958)
Oh. Ok, so you did have to have an existing logged in session for any account, then could leverage that to get the token for another account by changing out the email?
Re:Zero-day in Sign in with Apple by mazeltovvv on Saturday May 30, 2020 @03:54PM (#23364079)
Ah. So this creates a valid JWT for any email you want, but it is now associated with your own apple account?
Re:Zero-day in Sign in with Apple by SV_BubbleTime on Saturday May 30, 2020 @09:20PM (#23366381)
> but it is now associated with your own apple account?

On the backend, maybe they can look up who requested a token at a time.

But otherwise, no it doesn’t seem to be

Re:Zero-day in Sign in with Apple by dodobirdlord on Saturday May 30, 2020 @11:36PM (#23366962)
This is certainly logged.
Re:Zero-day in Sign in with Apple by thephyber on Saturday May 30, 2020 @07:05PM (#23365633)
I don't have any way to confirm, but yes, this is what I interpreted from the article.
Re:Zero-day in Sign in with Apple by phamilton on Saturday May 30, 2020 @01:55PM (#23363127)
My understanding is that the token itself is fine and within spec. But they altered the flow to accept an email address in one of the request payloads which opened the door for spoofing the email address. I've never seen an OAuth or OpenID flow that relied on the payload for identity.
Re:Zero-day in Sign in with Apple by donmcronald on Saturday May 30, 2020 @03:37PM (#23363933)
This is likely it IMO. They probably pass the preferred email around as a parameter and the user can jump into the flow and modify it.
Re:Zero-day in Sign in with Apple by SV_BubbleTime on Saturday May 30, 2020 @03:40PM (#23363952)
Wait... I don’t get it.

Why was Apple signing a response JWT when the user only supplied an email?

I’m not a web guy so I just don’t see what they were going for here.

Re:Zero-day in Sign in with Apple by phamilton on Saturday May 30, 2020 @06:18PM (#23365294)
The gap is that Apple fully verified identity via the normal OAuth flow, and then once identiy was verified they give the use control over what email to include in the token. The idea is that the user can include their email or an apple relay email (that forwards to their email). The bug seems to be in that step, and an attacker can provide an email that is neither their own nor an apple relay email.

Your apple account is safe, but if a 3rd party trusts the signed apple payload without further verification of email, an attacker could sign in as you on the 3rd party app.

Re:Zero-day in Sign in with Apple by dwaite on Saturday May 30, 2020 @10:44PM (#23366724)
Apple deviated from OpenID Connect, but...

The third party is not supposed to link the information from an OpenID Connect client system by email address, which could change or go away at any time, and is also not guaranteed to be unique.

Rather, they should use the 'sub' claim which is meant to be the same over the lifetime of the user account with the issuer.

Re:Zero-day in Sign in with Apple by hirsin on Sunday May 31, 2020 @02:26AM (#23367669)
Yup, this is it. It's a super common issue though, and we see it all the time. An app expected the email of a user to be static and keys off of it. User gets married and loses their code access.

At best it's a work stoppage when someone changes their email. At worst you make assumptions about reusability of emails and give data access to the wrong account.

Re:Zero-day in Sign in with Apple by SV_BubbleTime on Saturday May 30, 2020 @09:12PM (#23366350)
That makes sense.

Seems little too obvious to exist, but people make mistakes.

It’s just that with JWT/JSE/JOSE already questionable security options that you would be extra super careful if you are using it. (Biggest flaw off the top of my head is it literally says what encryption is used with a NONE option meaning you can just switch to “none” and forge jwts to anyone that didn’t know not to accept those, second would be that they mix symmetric and asymmetric encryption options)

Re:Zero-day in Sign in with Apple by catlifeonmars on Saturday May 30, 2020 @11:33PM (#23366951)
I noticed after reading your comment that HS256 is marked as “required” for compliant implantations. In practice, I have only ever seen signers implement RS256 though...
Re:Zero-day in Sign in with Apple by sascha_sl on Sunday May 31, 2020 @04:50AM (#23368199)
In OIDC you can actually specificy supported key types in the discovery process and the IdP always decides the key type anyway.

HS256 relies in shared secrets, so anyone who can verify a token can also change it. RS256 allows you to download the IdP keychain every once in a while and verify tokens offline.

Re:Zero-day in Sign in with Apple by catlifeonmars on Sunday May 31, 2020 @01:27PM (#23371001)
Yes, that’s what I meant. I only see RS256 implemented by identity providers (and advertised via .well-known/openid-configuration). This makes sense, since most identity providers are decoupled from their clients and thus cannot feasibly share a symmetric key. I am confused what is meant in the JWA specification[1] by “HS256: required” under “implementation requirements” in the table of allowed values (the entry for RS256 reads “recommended” for that column).

[1]: https://tools.ietf.org/html/rfc7518#section-3.1

Re:Zero-day in Sign in with Apple by derangedHorse on Sunday May 31, 2020 @07:59PM (#23374224)
There is no endpoint in the OIDC spec that allows token creation aside from the redirect after login (implicit flow) and the token endpoint though. I don't imagine this vulnerability could've happened at either endpoint, but I could be wrong. I'll definitely be looking into how Apple implements things before I use their login for any of my own applications
Re:Zero-day in Sign in with Apple by noctune on Saturday May 30, 2020 @02:13PM (#23363268)
I think it's actually the OIDC access token and not the ID token. The OIDC spec does not mandate any structure for the access token, but letting it be a JWT isn't out-of-spec.
Re:Zero-day in Sign in with Apple by dwaite on Saturday May 30, 2020 @10:47PM (#23366741)
I do not believe that Apple yet uses the access token bit.

OAuth tokens also are not meant to be used for authentication, and require either a separate token (as OpenID Connect did) with appropriate security, or to wedge additional security on top of access tokens as Facebook did with Connect.

This is basically because access tokens are meant to be messages about allowed access to the API resources, not messages to the client software about the user.

Re:Zero-day in Sign in with Apple by sascha_sl on Sunday May 31, 2020 @04:55AM (#23368215)
A few popular IdPs (e.g. keycloak) have no but semantic difference in access and ID tokens, they're both signed JWTs (EC/RSA or shudder HMAC shared secrets) with different typ fields.
Re:Zero-day in Sign in with Apple by saagarjha on Saturday May 30, 2020 @12:46PM (#23362440)
Apple supposedly marks certain beta builds with a bounty multiplier. I say supposedly because like their "research iPhones" they mentioned it in a presentation once and I never heard about it again.
Re:Zero-day in Sign in with Apple by g_p on Saturday May 30, 2020 @06:18PM (#23365289)
This might be what you're referring to:

From https://developer.apple.com/security-bounty/payouts/

"Issues that are unique to designated developer or public betas, including regressions, can result in a 50% additional bonus if the issues were previously unknown to Apple."

Re:Zero-day in Sign in with Apple by saagarjha on Saturday May 30, 2020 @06:19PM (#23365299)
Yes, that's it.
Re:Zero-day in Sign in with Apple by snazz on Saturday May 30, 2020 @01:26PM (#23362841)
I'm guessing that the research iPhones were given to a very select group of security researchers with track records of reporting important vulnerabilities under some kind of NDA.
Re:Zero-day in Sign in with Apple by saagarjha on Saturday May 30, 2020 @01:31PM (#23362903)
1. Still never heard of anyone getting them and 2. that’s worse than useless.
Re:Zero-day in Sign in with Apple by snazz on Saturday May 30, 2020 @01:33PM (#23362928)
Oh, for sure. I should clarify that I meant that they received the iPhones under an NDA, not that they reported bugs under an NDA (aside from the 90-day disclosure to get any bounties).
Re:Zero-day in Sign in with Apple by saagarjha on Saturday May 30, 2020 @01:40PM (#23362988)
Word on the street suggests they don’t exist: https://twitter.com/thegrugq/status/1236264193906495488
Re:Zero-day in Sign in with Apple by snazz on Saturday May 30, 2020 @01:57PM (#23363140)
I guess it's unrealistic to assume that their supply chain would be secure enough for these that no one would have heard anything.
Re:Zero-day in Sign in with Apple by saagarjha on Saturday May 30, 2020 @02:01PM (#23363173)
Right. You can find pictures of actual internal devices all over the internet (supposedly some people will even sell them to you), so it's quite strange to not hear anything about these. With Apple going after Corellium, I think many researchers are thankful for the various exploits we've had recently that have kept iPhone open.
Re:Zero-day in Sign in with Apple by phamilton on Saturday May 30, 2020 @02:00PM (#23363169)
I'm fine with pre-release bugs being reported under an NDA. If pre-release bugs are publicly disclosed that is arguably a punishment for companies who seek that validation early in the cycle rather than later.