Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shim breaks on ROMs with different transaction IDs #33

Closed
kdrag0n opened this issue Mar 23, 2021 · 2 comments
Closed

Shim breaks on ROMs with different transaction IDs #33

kdrag0n opened this issue Mar 23, 2021 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@kdrag0n
Copy link
Owner

kdrag0n commented Mar 23, 2021

On some ROMs (such as certain versions of Samsung One UI), there have been enough changes to the keystore service that the attestKey transaction is no longer assigned to the same ID as AOSP, so the shim solution doesn't work at all.

It is technically possible to obtain the transaction ID at install time by decompiling the framework, but this is very fragile and needs to be done on every update.

My proposal is to inspect the contents of the AIDL Parcel object to determine the call instead of relying on the transaction code. attestKey takes a unique set of arguments:

  • IKeystoreCertificateChain callback (AIDL service)
  • String alias
  • KeymasterArguments params

This allows to identify the transaction by checking the data in the Parcel. For IKeystoreCertificateChainCallback, the client sends a Binder to its implementation of the callback as a value in the Parcel, so we can check whether the service is correct by doing the equivalent of Java's Binder#queryLocalInterface("android.security.keystore.IKeystoreCertificateChainCallback") in C++. The other arguments should be easy to inspect as they are either primitive Parcel data types or Parcelables composed of primitives.

It must be noted, however, that the raw Parcel data format is not necessarily stable across major Android versions to the best of my knowledge. Attempting to read the data blindly using the C++ Parcel API is also dangerous because it could cause an out-of-bounds read when attempting to read a string at the wrong position.

Implementations are free to be submitted to the shim branch for #13. This is currently blocking #32.

@m5t5t

This comment has been minimized.

@kdrag0n
Copy link
Owner Author

kdrag0n commented Aug 23, 2021

Superseded by the new solution in v2.0.0.

@kdrag0n kdrag0n closed this as completed Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants