Merge pull request #3033 from Aerilym/ses-1114-recovery-phrase-spam-exploit

Fix: enforce password check before modal view for recovery phrase
pull/3053/head
Audric Ackermann 2 years ago committed by GitHub
commit ed0937b478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -188,7 +188,6 @@ interface ModalInnerProps {
const SessionSeedModalInner = (props: ModalInnerProps) => { const SessionSeedModalInner = (props: ModalInnerProps) => {
const { onClickOk } = props; const { onClickOk } = props;
const [loadingPassword, setLoadingPassword] = useState(true);
const [loadingSeed, setLoadingSeed] = useState(true); const [loadingSeed, setLoadingSeed] = useState(true);
const [recoveryPhrase, setRecoveryPhrase] = useState(''); const [recoveryPhrase, setRecoveryPhrase] = useState('');
const [hasPassword, setHasPassword] = useState<null | boolean>(null); const [hasPassword, setHasPassword] = useState<null | boolean>(null);
@ -197,30 +196,22 @@ const SessionSeedModalInner = (props: ModalInnerProps) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
useMount(() => { useMount(() => {
async function checkHasPassword() { async function validateAccess() {
if (!loadingPassword) { if (passwordHash || recoveryPhrase) {
return; return;
} }
const hash = await Data.getPasswordHash(); const hash = await Data.getPasswordHash();
setHasPassword(!!hash); setHasPassword(!!hash);
setPasswordHash(hash || ''); setPasswordHash(hash || '');
setLoadingPassword(false);
}
async function getRecoveryPhrase() {
if (recoveryPhrase) {
return false;
}
const newRecoveryPhrase = getCurrentRecoveryPhrase(); const newRecoveryPhrase = getCurrentRecoveryPhrase();
setRecoveryPhrase(newRecoveryPhrase); setRecoveryPhrase(newRecoveryPhrase);
setLoadingSeed(false); setLoadingSeed(false);
return true;
} }
setTimeout(() => (document.getElementById('seed-input-password') as any)?.focus(), 100); setTimeout(() => (document.getElementById('seed-input-password') as any)?.focus(), 100);
void checkHasPassword(); void validateAccess();
void getRecoveryPhrase();
}); });
const onClose = () => dispatch(recoveryPhraseModal(null)); const onClose = () => dispatch(recoveryPhraseModal(null));

Loading…
Cancel
Save