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

[apksigtool] handle "frosting" block in APK Signatures #46

Open
eighthave opened this issue Aug 30, 2021 · 11 comments
Open

[apksigtool] handle "frosting" block in APK Signatures #46

eighthave opened this issue Aug 30, 2021 · 11 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed maybe Unsure whether this will be worked on

Comments

@eighthave
Copy link

The frosting block in the APK signature can include a separate signature that is tied to the app store that distributed the APK. apksigcopier should be aware of frosting, and have options to handle it. I think it should be able to either copy it, or strip it out when copying an APK signature.

Here's some code that works with frosting that @U039b pointed me to:
https://bi-zone.medium.com/easter-egg-in-apk-files-what-is-frosting-f356aa9f4d1

@obfusk obfusk self-assigned this Aug 30, 2021
@obfusk obfusk added the enhancement New feature or request label Aug 30, 2021
@obfusk
Copy link
Owner

obfusk commented Aug 30, 2021

I think it should be able to either copy it

It's part of the APK Signature Scheme v2 Block, so it's already being copied.

or strip it out when copying an APK signature.

I'm considering that; but maybe that's more suited to apksigtool.

@obfusk
Copy link
Owner

obfusk commented Aug 30, 2021

Here's some code that works with frosting that @U039b pointed me to:
https://bi-zone.medium.com/easter-egg-in-apk-files-what-is-frosting-f356aa9f4d1

That's the same link I posted here :)

@eighthave
Copy link
Author

I like to make sure all the relevant stuff is in the issue so the implementer doesn't have to go on a wild goose chase to find it. For example, here's a Golang implemenatation which might have been posted elsewehre:
https://github.com/avast/apkverifier/blob/master/signingblock/frosting.go

@U039b
Copy link

U039b commented Aug 30, 2021

Frosting detection implemented in Python: https://github.com/Pithus/bazaar/blob/master/bazaar/core/tasks.py#L326

@obfusk
Copy link
Owner

obfusk commented Aug 30, 2021

I've been working on apksigtool, which currently supports parsing the APK Signature Block and validating v2 (and to some extent) v3 signatures.

It detects the frosting block, but doesn't "look inside"; porting the Go code might be interesting if we have a use case for that.

@eighthave
Copy link
Author

eighthave commented Aug 30, 2021 via email

@obfusk
Copy link
Owner

obfusk commented Aug 30, 2021

We can "invent" our own signature block; I'd be happy to implement that in apksigtool.

@obfusk
Copy link
Owner

obfusk commented Aug 30, 2021

$ apksigtool parse original.apk | grep -v '^    '
PAIR ID: 0x7109871a
  APK SIGNATURE SCHEME v2 BLOCK
  SIGNER 0
  VERIFIED
PAIR ID: 0x504b4453
  DEPENDENCY INFO BLOCK
PAIR ID: 0x42726577
  VERITY PADDING BLOCK
PAIR ID: 0x2146444e
  GOOGLE PLAY FROSTING BLOCK
$ cp original.apk cleaned.apk
$ apksigtool clean cleaned.apk
$ apksigtool parse cleaned.apk | grep -v '^    '
PAIR ID: 0x7109871a
  APK SIGNATURE SCHEME v2 BLOCK
  SIGNER 0
  VERIFIED
PAIR ID: 0x504b4453
  DEPENDENCY INFO BLOCK
PAIR ID: 0x42726577
  VERITY PADDING BLOCK
$ apksigner verify -v cleaned.apk | grep -v WARNING:
Verifies
Verified using v1 scheme (JAR signing): true
Verified using v2 scheme (APK Signature Scheme v2): true
Verified using v3 scheme (APK Signature Scheme v3): false
Number of signers: 1

Fun fact: the verity padding block only provides the correct amount of padding after removing the "frosting" block.

@obfusk obfusk added the maybe Unsure whether this will be worked on label Aug 1, 2022
@obfusk
Copy link
Owner

obfusk commented Oct 20, 2022

@obfusk obfusk added the help wanted Extra attention is needed label Oct 20, 2022
@obfusk
Copy link
Owner

obfusk commented Oct 26, 2022

@U039b @eighthave I haven't worked or stayed up-to-date on this topic for a year, but I'm working on apksigtool again.

If you know of any new information or tools from the last year, I'd appreciate a link :)

@obfusk obfusk pinned this issue Oct 27, 2022
@eighthave
Copy link
Author

eighthave commented Oct 31, 2022 via email

@obfusk obfusk changed the title handle "frosting" block in APK Signatures [apksigtool] handle "frosting" block in APK Signatures Nov 5, 2022
@obfusk obfusk unpinned this issue Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed maybe Unsure whether this will be worked on
Projects
None yet
Development

No branches or pull requests

3 participants