Skip to content

Commit

Permalink
fix: abort S2 bootstrapping when KEXSetEcho has reserved bits set (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Aug 1, 2024
1 parent 95b82ca commit 5ba686e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/cc/src/cc/Security2CC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,7 @@ export class Security2CCKEXSet extends Security2CC {
super(host, options);
if (gotDeserializationOptions(options)) {
validatePayload(this.payload.length >= 4);
this._reserved = this.payload[0] & 0b1111_1100;
this.permitCSA = !!(this.payload[0] & 0b10);
this.echo = !!(this.payload[0] & 0b1);
// The bit mask starts at 0, but bit 0 is not used
Expand All @@ -2108,6 +2109,7 @@ export class Security2CCKEXSet extends Security2CC {
SecurityClass.S2_Unauthenticated,
);
} else {
this._reserved = 0;
this.permitCSA = options.permitCSA;
this.echo = options.echo;
this.selectedKEXScheme = options.selectedKEXScheme;
Expand All @@ -2116,6 +2118,7 @@ export class Security2CCKEXSet extends Security2CC {
}
}

public readonly _reserved: number;
public permitCSA: boolean;
public echo: boolean;
public selectedKEXScheme: KEXSchemes;
Expand Down
9 changes: 9 additions & 0 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3563,6 +3563,15 @@ export class ZWaveController
});
await abort(KEXFailType.WrongSecurityLevel);
return SecurityBootstrapFailure.NodeCanceled;
} else if (kexSetEcho._reserved !== 0) {
this.driver.controllerLog.logNode(node.id, {
message:
`Security S2 bootstrapping failed: Invalid KEXSet received`,
direction: "inbound",
level: "warn",
});
await abort(KEXFailType.WrongSecurityLevel);
return SecurityBootstrapFailure.NodeCanceled;
} else if (
!kexSetEcho.isEncapsulatedWith(
CommandClasses["Security 2"],
Expand Down

0 comments on commit 5ba686e

Please sign in to comment.