fix(security): remove universal PIN backdoor and eliminate PIN leakage in transfers
This commit is contained in:
+1
-1
@@ -1571,7 +1571,7 @@
|
|||||||
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 14px; margin-bottom: 14px; text-align: center;">
|
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 14px; margin-bottom: 14px; text-align: center;">
|
||||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
|
||||||
<label for="inputTransferPin" style="font-size: 0.8rem; font-weight: 800; color: #0f172a; display: flex; align-items: center; gap: 5px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#475569" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg> Digita tu PIN de seguridad:</label>
|
<label for="inputTransferPin" style="font-size: 0.8rem; font-weight: 800; color: #0f172a; display: flex; align-items: center; gap: 5px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#475569" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg> Digita tu PIN de seguridad:</label>
|
||||||
<span id="lblTransferPinHint" style="font-size: 0.72rem; color: #166534; font-weight: 800; background: #dcfce7; padding: 2px 8px; border-radius: 6px;">(PIN: 1234)</span>
|
<span style="font-size: 0.72rem; color: #64748b; font-weight: 700;">(4 dígitos)</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="position: relative; max-width: 240px; margin: 0 auto;">
|
<div style="position: relative; max-width: 240px; margin: 0 auto;">
|
||||||
|
|||||||
+1
-5
@@ -1148,10 +1148,6 @@ function onTransferTargetIdentified(target) {
|
|||||||
pinInput.value = '';
|
pinInput.value = '';
|
||||||
pinInput.type = 'password';
|
pinInput.type = 'password';
|
||||||
}
|
}
|
||||||
const pinHint = document.getElementById('lblTransferPinHint');
|
|
||||||
if (pinHint && currentStudent) {
|
|
||||||
pinHint.textContent = `(PIN: ${currentStudent.pin_seguridad || '1234'})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('transferStepScan').style.display = 'none';
|
document.getElementById('transferStepScan').style.display = 'none';
|
||||||
document.getElementById('transferStepConfirm').style.display = 'block';
|
document.getElementById('transferStepConfirm').style.display = 'block';
|
||||||
@@ -1493,7 +1489,7 @@ async function executeP2PTransfer() {
|
|||||||
const pin = document.getElementById('inputTransferPin').value.trim();
|
const pin = document.getElementById('inputTransferPin').value.trim();
|
||||||
if (!pin) {
|
if (!pin) {
|
||||||
if (window.sounds) window.sounds.playError();
|
if (window.sounds) window.sounds.playError();
|
||||||
return alert('Por favor ingresa tu PIN de seguridad (por defecto 1234).');
|
return alert('Por favor ingresa tu PIN de seguridad.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const motivo = document.getElementById('inputTransferMotivo').value.trim();
|
const motivo = document.getElementById('inputTransferMotivo').value.trim();
|
||||||
|
|||||||
+7
-7
@@ -494,8 +494,8 @@ function seedInitialData() {
|
|||||||
'+506 8999-0011'
|
'+506 8999-0011'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Asegurar que todos los estudiantes tengan el PIN 1234 estándar para el piloto
|
// Asignar PIN por defecto únicamente si algún estudiante no tiene PIN definido
|
||||||
db.prepare("UPDATE estudiantes SET pin_seguridad = '1234' WHERE pin_seguridad IS NULL OR pin_seguridad != '1234'").run();
|
db.prepare("UPDATE estudiantes SET pin_seguridad = '1234' WHERE pin_seguridad IS NULL OR pin_seguridad = ''").run();
|
||||||
|
|
||||||
console.log('✅ Base de datos inicializada con éxito.');
|
console.log('✅ Base de datos inicializada con éxito.');
|
||||||
}
|
}
|
||||||
@@ -763,14 +763,14 @@ function transferenciaP2PTransaction({ emisorId, qrReceptor, receptorId, monto,
|
|||||||
throw new Error('Tus padres tienen desactivadas las transferencias entre compañeros en tu perfil');
|
throw new Error('Tus padres tienen desactivadas las transferencias entre compañeros en tu perfil');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Validar PIN de seguridad del emisor (permite 1234 universal o el PIN personalizado)
|
// 2. Validar PIN de seguridad del emisor (debe coincidir exactamente con su PIN registrado)
|
||||||
const pinIngresado = String(pin || '').trim();
|
const pinIngresado = String(pin || '').trim();
|
||||||
const pinEstudiante = String(emisor.pin_seguridad || '1234').trim();
|
const pinEstudiante = String(emisor.pin_seguridad || '').trim();
|
||||||
if (!pinIngresado) {
|
if (!pinIngresado) {
|
||||||
throw new Error('Debes ingresar tu PIN de 4 dígitos para transferir');
|
throw new Error('Debes ingresar tu PIN de seguridad');
|
||||||
}
|
}
|
||||||
if (pinIngresado !== '1234' && pinIngresado !== pinEstudiante) {
|
if (pinIngresado !== pinEstudiante) {
|
||||||
throw new Error(`PIN de seguridad incorrecto. Tu PIN es ${pinEstudiante}`);
|
throw new Error('El PIN de seguridad es incorrecto.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Obtener receptor (por ID o por escaneo de QR/código de carné)
|
// 3. Obtener receptor (por ID o por escaneo de QR/código de carné)
|
||||||
|
|||||||
Reference in New Issue
Block a user