fix: use random nonce per call in AES-GCM onboarding signature#411
Merged
Conversation
Static IV derived from the key (substr($key, 0, 12)) was reused for every encryption call, enabling keystream recovery and authentication tag forgery via the GHASH Forbidden Attack with just two captured onboarding_signature values. Fix: replace static IV with random_bytes(12) and prepend the IV to the ciphertext output (iv || ciphertext || tag) so receivers can extract the IV for decryption. Output format is unchanged (hex string), but now includes a 12-byte IV prefix (first 24 hex chars). Server-side validation at auth.razorpay.com must be updated to read the first 24 hex chars as the IV before decrypting. Partners should also rotate their client_secret as previously captured signatures remain exploitable under the old key material. Co-authored-by: ankitdas13 <ankit.das@razorpay.com>
This was referenced Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generateOnboardingSignatureto use a random 12-byte IV per encryption call instead of a static IV.hex(iv[12 bytes] || ciphertext || tag[16 bytes])Changes
src/Utility.php: generate fresh 12-byte IV per encryption call; prepend IV to ciphertext outputtests/OAuthTokenClientTest.php: update assertions to match new output format and verify uniqueness across callsCompanion PRs (same fix across all partner SDKs)
Test plan
generateOnboardingSignatureproduces a different hex string on every call with the same input🤖 Generated with Claude Code