nasc: Add more integrity checks

This commit is contained in:
Daniel López Guimaraes
2024-04-13 22:37:29 +01:00
parent 20eed7fc96
commit 603b209cb5

View File

@@ -122,8 +122,8 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
// * If a user performs a system transfer from
// * a console to another using a Nintendo account
// * during the transfer and both consoles have
// * a Pretendo account, the devices will be swapped
// * since we check it using the LFCS.
// * a Pretendo account, the new device won't have
// * the user's PID.
// *
// * So, the linked PIDs won't have the user's PID
// * anymore.
@@ -133,6 +133,16 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
await device.save();
}
}
if (device.serial !== serialNumber) {
response.status(200).send(nascError('102').toString());
return;
}
if (device.mac_hash !== macAddressHash) {
response.status(200).send(nascError('102').toString());
return;
}
}
// * Workaround for edge case on system transfers
@@ -142,10 +152,6 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
// *
// * This would make the Pretendo account to not have
// * a device on the database.
// *
// * TODO: With this change, now multiple devices can
// * have the same serial number and MAC address.
// * Do we want this? If not, are there other solutions?
if (!device && pid) {
device = new Device({
model,