You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[deep-review] C10: v3→v2 signature fallback is sticky-permanent (downgrade attack) #350
The connect handshake supports both v3 and v2 device-identity signature payloads. The client attempts v3; if the gateway responds with code: "DEVICE_AUTH_SIGNATURE_INVALID" or an error containing "device signature invalid", the client flips an instance flag (_useV2Signature = true) and retries with v2 on the next reconnect. The flag is never reset to false. Once tripped, the client uses v2 forever for that session.
_useV2Signature is also persisted across reconnects in GatewayConnectionManager._gatewayNeedsV2Signature (per-gateway, in-memory only; cleared on process exit).
A MITM (or briefly-compromised) gateway can return DEVICE_AUTH_SIGNATURE_INVALID once. After that the client uses v2 even after the gateway is back to normal v3 operation. v2 drops platform and deviceFamily from the signature payload — narrower attack surface for the signature, but also narrower binding to the client. The downgrade itself is the attack: a permanent signature-payload downgrade weakens the per-session binding.
This is the same shape as the well-known v3-to-v2 protocol downgrade attacks (TLS, OAuth, etc.).
Proposed fix
After N (suggest 3) consecutive successful v2 handshakes, attempt v3 on the next reconnect. If v3 succeeds, clear the flag. If v3 fails again with DEVICE_AUTH_SIGNATURE_INVALID, stay on v2 and double N for the next probe (exponential backoff).
Alternatively, attempt v3 on every reconnect that follows a process restart. v2 should be a runtime fallback within a session, not a sticky setting.
Add a diagnostic counter so operators can see "this gateway is forcing v2" in the Connection Status window.
I've created a draft PR implementing the exponential-backoff v3 probe approach described in this issue.
Implementation:
Added _v2SuccessCount, _v2ProbeThreshold (default 3), and _v3ProbeActive to GatewayConnectionManager
After 3 consecutive successful v2 handshakes, the next reconnect probes v3 (UseV2Signature = false)
If v3 is rejected again, the threshold doubles (3 → 6 → 12 ... capped at 96) — exponential backoff
A _v3ProbeActive flag distinguishes the initial v3→v2 fallback from a probe failure, ensuring the threshold only doubles on actual probe rejections (not the first fallback)
Gateway switch or new-gateway setup resets all state
4 new unit tests covering all paths
Note: PR #400 (by Copilot) also addresses this issue — the maintainer may want to compare approaches before merging.
Closing this one-off deep-review issue as consolidated, not necessarily fixed. The useful signal is preserved in #372: v3→v2 fallback is still useful security signal, but stale generated PRs were closed. We will take these one at a time from #372 after verifying against current master instead of keeping the issue list flooded.
Activity
github-actions commentedon May 14, 2026
fix: v3→v2 signature fallback no longer sticky-permanent (#350)
github-actions commentedon May 15, 2026
🤖 This is an automated response from Repo Assist.
I've created a draft PR implementing the exponential-backoff v3 probe approach described in this issue.
Implementation:
_v2SuccessCount,_v2ProbeThreshold(default 3), and_v3ProbeActivetoGatewayConnectionManagerUseV2Signature = false)_v3ProbeActiveflag distinguishes the initial v3→v2 fallback from a probe failure, ensuring the threshold only doubles on actual probe rejections (not the first fallback)Note: PR #400 (by Copilot) also addresses this issue — the maintainer may want to compare approaches before merging.
shanselman commentedon May 18, 2026
Closing this one-off deep-review issue as consolidated, not necessarily fixed. The useful signal is preserved in #372: v3→v2 fallback is still useful security signal, but stale generated PRs were closed. We will take these one at a time from #372 after verifying against current master instead of keeping the issue list flooded.