Guidepoint: Enhancement - Improve PIN validation with PBKDF2#2039
Merged
JohnathanWhite merged 1 commit intobitpay:masterfrom Mar 4, 2026
Merged
Guidepoint: Enhancement - Improve PIN validation with PBKDF2#2039JohnathanWhite merged 1 commit intobitpay:masterfrom
JohnathanWhite merged 1 commit intobitpay:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens the app’s PIN handling by introducing weak-PIN validation and migrating PIN hashing from legacy SHA-256 to salted PBKDF2, with support for automatic migration on successful unlock.
Changes:
- Added
src/utils/pin.tswith PIN strength checks, PBKDF2 hashing, and legacy-to-PBKDF2 verification/migration logic. - Updated
PinModalto verify viaverifyAndMigratePin, migrate legacy hashes on success, and surface validation errors when setting a PIN. - Extended the APP redux state to persist a
currentSaltalongsidecurrentPin, and cleared it when removing a PIN.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/pin.ts | New PIN validation + PBKDF2 hashing + verification/migration utilities. |
| src/store/wallet/effects/import/import.ts | Uses legacy SHA-256 PIN hashing during config migration. |
| src/store/app/app.types.ts | Adds CURRENT_SALT action type and action union wiring. |
| src/store/app/app.reducer.ts | Adds currentSalt to persisted APP state and reducer handling. |
| src/store/app/app.actions.ts | Adds currentSalt(...) action creator. |
| src/navigation/tabs/settings/security/screens/SecurityHome.tsx | Clears currentSalt when removing PIN lock. |
| src/components/modal/pin/PinModal.tsx | Switches PIN check/set flows to PBKDF2 utilities and stores salt. |
Comments suppressed due to low confidence (1)
src/components/modal/pin/PinModal.tsx:247
handleCellPressreadspinBannedUntilbut it’s not included in theuseCallbackdependency array. That can leave the callback using a stalepinBannedUntilvalue, potentially allowing input during a ban (or blocking after a ban clears). Add the missing dependencies (at leastpinBannedUntil, and any other referenced values not guaranteed stable).
const handleCellPress = useCallback(
(value: string) => {
if (pinBannedUntil) {
// banned wait for entering new pin
return;
}
setMessageError(null);
haptic('soft');
switch (value) {
case 'reset':
reset();
break;
case 'backspace':
setPinStatus(prevValue => {
const newPin = prevValue.pin.slice();
newPin.splice(-1);
return {...prevValue, pin: newPin};
});
break;
default:
// Adding new PIN
setPinStatus(prevValue => {
if (
Number(value) >= PIN_CONFIG.PIN_MIN_VALUE &&
Number(value) <= PIN_CONFIG.PIN_MAX_VALUE &&
prevValue.pin.length < PIN_CONFIG.PIN_LENGTH
) {
const newPin = prevValue.pin.slice();
newPin[newPin.length] = value;
return {...prevValue, pin: newPin};
} else {
return prevValue;
}
});
break;
}
},
[setPinStatus, reset, pinStatus],
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
17a5d38 to
dbd6bf1
Compare
dbd6bf1 to
18ba9e7
Compare
Collaborator
|
Works as expected. Migration successfully tested on both Android and iOS simulator. |
94437f8 to
729ce89
Compare
729ce89 to
75abeb4
Compare
gabrielbazan7
approved these changes
Mar 3, 2026
JohnathanWhite
approved these changes
Mar 4, 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.
GP-18