fix: Fixes the IV overwrite when trying to encrypt multiple credentials #882
Merged
fix: Fixes the IV overwrite when trying to encrypt multiple credentials #882
Conversation
Contributor
Author
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Claude finished @pmathew92's task —— View job Code Review CompleteOverall Assessment❌ This PR addresses a critical IV collision bug in the credential encryption system, but has several security and code quality issues that should be addressed before merging. Strengths
Critical Issues Requiring AttentionSecurity Concerns:
Code Quality:
Performance: RecommendationsThe cryptographic approach is sound, but the implementation needs hardening against edge cases and malformed input. Please review the inline comments for specific suggestions to improve input validation, error handling, and code clarity. |
auth0/src/main/java/com/auth0/android/authentication/storage/CryptoUtil.java
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/CryptoUtil.java
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/CryptoUtil.java
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/CryptoUtil.java
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt
Show resolved
Hide resolved
auth0/src/test/java/com/auth0/android/authentication/storage/CryptoUtilTest.java
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt
Outdated
Show resolved
Hide resolved
auth0/src/main/java/com/auth0/android/authentication/storage/CryptoUtil.java
Show resolved
Hide resolved
utkrishtsahu
approved these changes
Nov 24, 2025
subhankarmaiti
approved these changes
Nov 24, 2025
NandanPrabhu
approved these changes
Nov 24, 2025
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.
Changes
This PR fixes the issue caused when the Initialisation Vector (IV) used to encrypt the
Credentialsin theSecureCredentialsManagergets overwritten with another IV when used along themultiple resource refresh tokenflow.Cause
The IV generated while encrypting one set of credentials are stored in the shared preference using a key. When used along with the
mrrtflow, the same shared preference key is used to store the new IV which replaces the existing one used to encrypt the first set of credentials. This results in aCryptoExceptionwhen the new IV is used to decrypt the original set of credentials.Fix
Instead of storing the IV in the shared preference , The IV is encrypted alongside the Credentials and stored. This ensures all set of different credentials would have their own IV which can later be extracted to decrypt them hence avoiding any exception. The Fix also ensures seamless migration for existing set of stored Credentials using the old manner.
Testing
Manual tests has been conducted for migration scenario and along with multiple set of credentials
This change adds unit test coverage
This change adds integration test coverage
This change has been tested on the latest version of the platform/language or why not
Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors