Verifying root & intermediate certs in the receipt

Apple seems to have omitted this question from their documentation (Parse the Receipt and Verify Its Signature)


It seems to leave it as an excercise for the reader:


/* You must verify the fingerprint of the root certificate and verify the OIDs of the intermediate certificate and signing certificate. The OID in the certificate policies extension of the intermediate certificate is (1 2 840 113635 100 6 2 1), and the marker OID of the signing certificate is (1 2 840 113635 100 6 11 1). */


If you don't do the thing in the comments, and don't verify the fingerprint of the root certificate, but only the fact that it's a known and valid root (such as Apple Root CA), then theoretically, an attacker with a private key and its certificate issued by any root authority (for example, one can use another Apple Developer ID but even a non-Apple one such as a VeriSign SSL key and cert created for a HTTPS website) can sign a receipt that will pass verification by your application without the attacker having paid for it. Because the root cert will be a valid one, not a concrete one, so the entire cert chain will be valid.


But even If you validate the root cert's fingerprint and make sure it's Apple Root CA, the attacker can still use his Developer ID to sign the fake receipt, because the Developer ID certificate is also signed by Apple Root CA.


It means that we also need to verify the intermediate certs, but they are not root and are not pre-installed on the computer. Also, their number may theoretically change in the future, so they can hardly be hard-coded (Apple is free to choose how many intermediate certs to use, and also they can be revoked/expired/replaced etc).


How do you work around this problem? It looks like it's creating a vulnerability? Is there an example of how to verify all intermediate and root certs?

Replies

Why are there no responses to this? This seems to me like a MASSIVE vulnerabiliy.

But the hacker has no way of knowing the identierForVendor (the salt) so they can't sign a correctly salted receipt. And that is why the only secure way of receipt verification is on board.

Do you mean the iOS device ID (vendor-specific)? This question was primarily about Mac apps, not iOS apps. On iOS it's generally very difficult to manipulate apps' receipts without jailbreaking, and this is perhaps the best guard.


The hacker's attack on Mac could be the following: the hacker sets up a website where the user could send his device ID and get back a receipt for any app, signed by hacker's Developer ID, that would validate on the user's Mac. Maybe there can be other types of attacks of this kind too.


I assume that even on Mac this kind of attack is probably also very rare, but it's nevertheless doable. I'm not saying that hackers will attack this way, but why you build an otherwise secure system and leave out some holes, even though you don't expect them to be exploited much.


Prove me wrong?

The Mac receipt includes the guid of the device rather than the identifierForVendor.