fix(android): retirer le code de deverrouillage demande de le connaitre

Le coffre ouvert ne prouvait rien : il peut l'etre depuis une heure et
rester a l'ecran. Quiconque trouvait le telephone dans cet etat levait la
protection en deux appuis, sans que rien ne le lui demande.

Le code courant voyage maintenant avec la demande, et Delphi le compare a
FPinSealed - ce sous quoi le cache est REELLEMENT scelle, pose seulement
par une ouverture reussie, jamais par un champ.

Fermee au passage : SetUnlockCode('') retirait le code en silence, ce qui
contournait le controle qu'on vient de poser.

Le FBusy de ClearUnlockCode ne sort plus sans un mot - une sortie muette
se lit comme une reussite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-08-28 16:30:30 +01:00
parent 203f45eb7c
commit a41c61405c
2 changed files with 36 additions and 8 deletions
+11 -3
View File
@@ -564,8 +564,12 @@
<div class="in-x" data-clear="sPinNew">&#215;</div> <div class="in-x" data-clear="sPinNew">&#215;</div>
</div> </div>
<button class="btn wide" id="sPinSet">Set this code</button> <button class="btn wide" id="sPinSet">Set this code</button>
<!-- Le champ ci-dessus sert aux deux : le NOUVEAU code pour "Set", le code
COURANT pour "Remove". Retirer une protection demande de la connaitre,
sinon quiconque trouve le telephone ouvert la leve en deux appuis. -->
<button class="btn wide danger" id="sPinClear">Remove the unlock code</button> <button class="btn wide danger" id="sPinClear">Remove the unlock code</button>
<div class="note">The code seals the copy kept on this device. It can be <div class="note">To remove the code, type the current one above first.
The code seals the copy kept on this device. It can be
digits or a full password - a longer one is harder to guess, and it is digits or a full password - a longer one is harder to guess, and it is
asked for only when the vault opens. Removing it leaves the vault asked for only when the vault opens. Removing it leaves the vault
readable by anyone holding the phone unlocked.</div> readable by anyone holding the phone unlocked.</div>
@@ -1551,8 +1555,12 @@ document.getElementById('sPinClear').addEventListener('click', function (ev) {
} }
b.removeAttribute('data-armed'); b.removeAttribute('data-armed');
b.textContent = 'Remove the unlock code'; b.textContent = 'Remove the unlock code';
send('pinclear'); // LE CODE COURANT VOYAGE AVEC LA DEMANDE. Le coffre ouvert ne prouve rien :
closeSettings(); // il peut l'etre depuis une heure et rester a l'ecran. Delphi compare a ce
// sous quoi le cache est reellement scelle, et refuse sinon.
send('pinclear?c=' + encodeURIComponent(
document.getElementById('sPinNew').value));
document.getElementById('sPinNew').value = '';
}); });
function goList() { function goList() {
+25 -5
View File
@@ -332,7 +332,7 @@ type
function CachePwd: string; function CachePwd: string;
/// Retire le code de deverrouillage : le cache se rescelle sous la seule /// Retire le code de deverrouillage : le cache se rescelle sous la seule
/// cle de l'appareil. Exige un coffre ouvert. /// cle de l'appareil. Exige un coffre ouvert.
procedure ClearUnlockCode; procedure ClearUnlockCode(const AConfirm: string);
/// Pose ou change le code de deverrouillage. Exige un coffre ouvert, donc /// Pose ou change le code de deverrouillage. Exige un coffre ouvert, donc
/// le code courant deja connu - c'est ce qui empeche un tiers d'en poser un /// le code courant deja connu - c'est ce qui empeche un tiers d'en poser un
/// que le proprietaire ne connaitrait pas. /// que le proprietaire ne connaitrait pas.
@@ -1728,7 +1728,7 @@ begin
SetUnlockCode(TNetEncoding.URL.Decode(Param('c'))) SetUnlockCode(TNetEncoding.URL.Decode(Param('c')))
else if LAction = 'pinclear' then else if LAction = 'pinclear' then
ClearUnlockCode ClearUnlockCode(TNetEncoding.URL.Decode(Param('c')))
else if LAction = 'delentry' then else if LAction = 'delentry' then
DeleteEntriesAt(TNetEncoding.URL.Decode(Param('i'))) DeleteEntriesAt(TNetEncoding.URL.Decode(Param('i')))
@@ -2890,7 +2890,10 @@ begin
if FBusy then Exit; if FBusy then Exit;
if ANew = '' then if ANew = '' then
begin begin
ClearUnlockCode; // Un champ vide ne demande rien : c'est "Remove" qui retire, et lui exige
// le code courant. Repondre par un retrait silencieux serait une porte
// derobee vers exactement ce qu'on vient de fermer.
WebCall('PM.toast("Type a code first")');
Exit; Exit;
end; end;
// Le secret du depot n'entre pas ici : le code scelle le CACHE, et un coffre // Le secret du depot n'entre pas ici : le code scelle le CACHE, et un coffre
@@ -2932,9 +2935,19 @@ begin
if HasLocalContainer then Result := FVaultPwd else Result := FSyncPwd; if HasLocalContainer then Result := FVaultPwd else Result := FSyncPwd;
end; end;
procedure TForm8.ClearUnlockCode; /// RETIRER UNE PROTECTION DEMANDE DE LA CONNAITRE.
///
/// Le coffre ouvert ne suffit pas : il peut l'avoir ete il y a une heure et
/// rester a l'ecran. Quelqu'un qui trouve le telephone dans cet etat pouvait
/// lever le code en deux appuis, et rien ne le lui demandait. Retaper le code
/// courant ne coute rien a son proprietaire, et arrete l'autre.
procedure TForm8.ClearUnlockCode(const AConfirm: string);
begin begin
if FBusy then Exit; if FBusy then
begin
WebCall('PM.toast("Busy - wait for the current operation")');
Exit;
end;
if not VaultNeedsPin then if not VaultNeedsPin then
begin begin
WebCall('PM.toast("No unlock code to remove")'); WebCall('PM.toast("No unlock code to remove")');
@@ -2947,6 +2960,13 @@ begin
WebCall('PM.toast("Open the vault first")'); WebCall('PM.toast("Open the vault first")');
Exit; Exit;
end; end;
// Compare a ce que le cache est REELLEMENT scelle, pas a ce qui traine dans
// un champ : FPinSealed n'est pose qu'a une ouverture reussie.
if (FPinSealed = '') or (AConfirm <> FPinSealed) then
begin
WebCall('PM.toast("Type the current unlock code to remove it")');
Exit;
end;
try try
SaveVault(FPlain, FETag, CachePwd, BiometricAvailable, False, '', SaveVault(FPlain, FETag, CachePwd, BiometricAvailable, False, '',
FKey, FKeySalt, FKeyIters, True); FKey, FKeySalt, FKeyIters, True);