fix(federation): address code review findings for FED-011
- Fix race window: store pendingHmacSecret AFTER remote peer confirms, not before (admin endpoint + auto-rotation worker) - Add hex validation on newSecret at /peer/rotate endpoint - Use pending-secret-aware signing in initial sync worker - Add test for corrupt state (pendingHmacSecret set, secretRotationAt null)
This commit is contained in:
@@ -67,4 +67,14 @@ describe('verifyPeerSignature', () => {
|
||||
const sig = signRequest(body, primarySecret, timestamp, null);
|
||||
expect(verifyPeerSignature(body, sig, timestamp, null, makePeer())).toBe(true);
|
||||
});
|
||||
|
||||
it('does not try pending secret when secretRotationAt is null', () => {
|
||||
const timestamp = Date.now();
|
||||
const sig = signRequest(body, pendingSecret, timestamp, nonce);
|
||||
const peer = makePeer({
|
||||
pendingHmacSecret: pendingSecret,
|
||||
secretRotationAt: null,
|
||||
});
|
||||
expect(verifyPeerSignature(body, sig, timestamp, nonce, peer)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user