microsoft-authentication-library-for-android icon indicating copy to clipboard operation
microsoft-authentication-library-for-android copied to clipboard

Redirect URI Verification enforces using the oldest app signature in it's signature history instead of the newest

Open felix-klose opened this issue 2 years ago • 3 comments

We recently updated our signing key in the google play store and updated our app's redirect URL to use the updated signature. This resulted in an exception thrown by PublicClientApplicationConfiguration::verifyRedirectUriWithAppSignature() when trying to authenticate users since it iterates the signature history from oldest to newest but throws an exception as soon as the first signature hash doesn't match the redirect URI.

Is this intended behavior or a bug? We expected to be able to use our updated signatures with AAD but it doesn't seem to be possible.

felix-klose avatar Oct 12 '23 14:10 felix-klose

Hi @felix-klose, Can you please share the following:

  • Device: [e.g. Pixel, OnePlus 6, etc]
  • Android Version: [e.g. API Level, Build Number]
  • Browser [e.g. Chrome, Edge]
  • MSAL Version

This needs further investigation from our side in order to confirm you.

negoe avatar Oct 16 '23 22:10 negoe

Hi @negoe,

we tested our implementation with the following devices:

  • Samsung Galaxy A50, Android 11 (SDK 30), Build Number RP1A.200720.012A505FNXXU9CWB4
  • Google Pixel 7a, Android 13 (SDK 33), Build Number TD4A.221205.042.A1
  • Nokia X20, Android 13 (SDK 33), Build Number 00WW_3_500_SP02

with Chrome with MSAL version 4.1.3

We further analyzed our certificate history to fully understand what's going on, so in case this helps you, here's what we found:

As I said the issue happened after updating the signing key in the Play Store. It has to be noted though, that we switched from a Google managed key to our own key, which means that the certificate DN changed. A change in certificate DN can however not be rolled out to devices running on Android 12 or below, which means apks for older devices are still signed with the original Google key. For Android 13 and above, the new key is used, but the old key ist still valid in the certificate history.

When generating the redirect URL, we used the newest signature from the history, which is the new signature for Android 13 and above, and the old signature for Android 12 and below. For older devices, this worked, for newer devices we got an exception from the code cited above, showing that MSAL expected the old signature.

We haven't tried to verify this with signing key updates where the new key has the same DN as the old key or where the old key is no longer valid, so it's possible that this issue only happens if multiple keys are valid for signing at the same time.

felix-klose avatar Oct 17 '23 08:10 felix-klose

Thanks for the details. We will get back to you post validation from our side. Thanks.

negoe avatar Oct 23 '23 06:10 negoe