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

Set max_size for SignedJwt: App Store's notification token exceed 16k length #30

Closed
pomelo opened this issue Aug 29, 2024 · 4 comments
Closed

Comments

@pomelo
Copy link

pomelo commented Aug 29, 2024

  • jwskate version:0.11.1
  • Python version:3.12
  • Operating System:Osx 15

Description

Thank you for making this awesome library. Love it so clean and pythonic. Just a question, should we have the max_size for initialize a SignedJwt object for handling some of the super big JWTs? Do we have any special concerns not to do that?

What I Did

I am dealing with App Store's notification v2, which includes a very long x509 header in the JWT. Once the JWT exceeds the length of 16k, the SignedJwt object wouldn't create and an exception was raised, suggesting "You can increase this limit by passing a different max_size value as parameter.". The base classes, Jwt and BaseCompactToken, have the argument to set the max_size for the init method, but SignedJwt doesn't inherit that.

@guillp
Copy link
Owner

guillp commented Aug 31, 2024

Thanks for the report. Indeed, token size is currently arbitrarily limited to 16kB to avoid crazily huge tokens and JSON deserialization issues. But I had in mind to allow bypassing that limit easily. A fix is on the way.

@pomelo
Copy link
Author

pomelo commented Sep 2, 2024

Yeah, 16kB is fine for most of the scenarios, but Apple's JWT just huge.
Thanks!

@guillp
Copy link
Owner

guillp commented Sep 3, 2024

I am curious, what kind of stuff can they put in there? If you can paste such a token (with an altered signature)

@pomelo
Copy link
Author

pomelo commented Sep 5, 2024

It's huge since it contains the public key in the headers, and in the payload, there is a huge data object contains two other JWTs: signedTransactionInfo and signedRenewalInfo.
Here decode sample below, with truncated content, just showing the structure:
HEADER

{
  "alg": "ES256",
  "x5c": [ "MIIEMDCCA7agAwIBAgIQfTlfd0fNvFWvzC1YIANsXjAKBggqhkjOPQQDAzB1MUQwQgYDVQQDDDtBcHBsZSBXb3JsZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9ucyBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTELMAkGA1UECwwCR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cX8iNLFS5UwCgYIKoZIzj0EAwMwZzEbMBkGA1UEAwwSQXBwbGUgUm9vdCBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwHhcNMTQwNDMwMTgxOTA2WhcNMzkwNDMwMTgxOTA2WjBnMRswGQYDVQQDDBJBcHBsZSBSb290IENBIC0gRzMxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzB2MBAGByqGSM49..."
  ]
}

PAYLOAD

{
  "notificationType": "DID_RENEW",
  "notificationUUID": "1618137d-a9fa-45ee-a437-2afdgd5cf8f0",
  "data": {
    "appAppleId": 431222259,
    "bundleId": "com.....",
    "bundleVersion": "542",
    "environment": "Sandbox",
    "signedTransactionInfo": "eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlFTURDQ0E3YWdBd0lCQWdJUWZUbGZkMGZOdkZXdnpDMVlJQU5zWGpBS0JnZ3Foa2pPUFFRREF6QjFNVVF3UWdZRFZRUURERHRCY0hCc1pTQlhiM0pzWkhkcFpHVWdSR1YyWld4dmNHVnlJRkpsYkdGMGFXOXVjeUJEWlhKMGFXWnBZMkYwYVc5dUlFRjFkR2h2Y21sMGVURUxNQWtHQTFVRUN3d0NSell4RXpBUkJnTlZCQW9NQ2tGd2NHeGxJRWx1WXk0eEN6QUpCZ05WQkFZVEFsVlRNQjRYRFRJek1Ea3hNakU1TlRFMU0xb1hEVEkxTVRBeE1URTVOVEUxTWxvd2daSXhR...",
    "signedRenewalInfo": "eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlFTURDQ0E3YWdBd0lCQWdJUWZUbGZkMGZOdkZXdnpDMVlJQU5zWGpBS0JnZ3Foa2pPUFFRREF6QjFNVVF3UWdZRFZRUURERHRCY0hCc1pTQlhiM0pzWkhkcFpHVWdSR1YyWld4dmNHVnlJRkpsYkdGMGFXOXVjeUJEWlhKMGFXWnBZMkYwYVc5dUlFRjFkR2h2Y21sMGVURUxNQWtHQTFVRUN3d0NSell4RXpBUkJnTlZCQW9NQ2tGd2NHeGxJRWx1WXk0eEN6QUpCZ05WQkFZVEFsVlRNQjRYRFRJek1Ea3hNakU1TlRFMU0xb1hEVEkxTVRBeE1URTVOVEUxTWxvd2daSXhRREErQmdOVkJBTU1OMUJ5YjJRZ1JVTkRJRTFoWXlCQmNIQWdVM1J2Y21VZ1lXNWtJR2xVZFc1bGN5QlRkRzl5WlNCU1pXTmxhWEIwSUZOcFoyNXBibWN4TERBcUJnTlZCQXNNSTBGd2NHeGxJRmR2Y214a2QybGtaU0JFW..."
    "status": 1
  },
  "version": "2.0",
  "signedDate": 1724816929984
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants