mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-12-03 09:44:08 +00:00
fix: trim AES block padding from a regions reply
The ANON_REQ reply payload is encrypted with a block cipher (Utils::encryptThenMAC -> AES), so the plaintext arrives NUL-padded to a 16-byte boundary, and the firmware's own length is not carried through to us. We stored the padding verbatim. Measured in production: 48 of 65 stored rows carry it. The padding lands inside the LAST region name, so "belml" is stored as "belml\0\0\0..." — which matches no observed scope and therefore reads as a region the repeater declares but never forwards. A systematic false finding, on the last entry of nearly every list. A wildcard-only answer is the worst shape: 0x2A plus seven NULs is exactly one block, so even `regions_csv = '*'` compares false in SQL, and the audit can miss the wildcard entirely and report a contradiction that is not there. Trim before splitting. Padding is also excluded from the truncation measure — it is not part of the repeater's answer and must not count toward the byte ceiling.
This commit is contained in:
1 parent
80d4779971
commit
6847e9ca30
4 files changed
+29
-2
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coredrive-rx",
|
||||
"version": "1.10.1",
|
||||
"version": "1.10.2",
|
||||
"private": false,
|
||||
"license": "GPL-3.0-or-later",
|
||||
"type": "module",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Minimal service worker: makes the app installable and lets the shell load
|
||||
// offline. Network-first (always fresh online), cache fallback (offline).
|
||||
// Only the static app assets go through fetch; MQTT runs over WSS (not cached).
|
||||
const CACHE = 'coredrive-rx-v33';
|
||||
const CACHE = 'coredrive-rx-v34';
|
||||
|
||||
self.addEventListener('install', () => self.skipWaiting());
|
||||
self.addEventListener('activate', (e) => e.waitUntil((async () => {
|
||||
|
||||
Binary file not shown.
@@ -314,3 +314,30 @@ test('an evaluation that asks nobody must not consume the airtime budget', () =>
|
||||
assert.equal(heardAskEligible(A, null, r, t0 + 19_000), false,
|
||||
'but 19s after a real ask the budget is genuinely spent');
|
||||
});
|
||||
|
||||
test('AES block padding is trimmed — it must not land inside the last region name', () => {
|
||||
// The reply is encrypted with a block cipher, so the plaintext arrives NUL-padded
|
||||
// to a 16-byte boundary. Production carried this into storage in 48 of 65 rows:
|
||||
// "belml" became "belml\0\0\0…", which matches no observed scope and reads as a
|
||||
// region the repeater declares but never forwards — a false finding, every time.
|
||||
const csv = 'be,be-vli,belml';
|
||||
const padded = new Uint8Array([
|
||||
0x8c, 0, ...le32(1), ...le32(2), ...ascii(csv), 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
]);
|
||||
const r = parseRegionsResponse(padded);
|
||||
assert.deepEqual(r.regions, ['be', 'be-vli', 'belml'],
|
||||
'the last name must not carry NUL bytes');
|
||||
assert.equal(r.regions[2].length, 5, 'no trailing NULs survive into the name');
|
||||
});
|
||||
|
||||
test('a wildcard-only reply survives padding as exactly "*"', () => {
|
||||
// 0x2A followed by seven NULs is one full AES block; this is the shape that made
|
||||
// regions_csv = '*' compare false in SQL and could mask the wildcard entirely.
|
||||
const padded = new Uint8Array([0x8c, 0, ...le32(1), ...le32(2), 0x2a, 0, 0, 0, 0, 0, 0, 0]);
|
||||
assert.deepEqual(parseRegionsResponse(padded).regions, ['*']);
|
||||
});
|
||||
|
||||
test('a reply that is only padding yields no regions, not one empty name', () => {
|
||||
const padded = new Uint8Array([0x8c, 0, ...le32(1), ...le32(2), 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
assert.deepEqual(parseRegionsResponse(padded).regions, []);
|
||||
});
|
||||
Reference in new issue
Block a user