Skip to content

[deep-review] C10: v3→v2 signature fallback is sticky-permanent (downgrade attack) #350

Closed

Description

@codemonkeychris

Summary

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).

Where

  • src/OpenClaw.Shared/OpenClawGatewayClient.cs:51, 881-899, 1494-1499 (operator)
  • src/OpenClaw.Shared/WindowsNodeClient.cs:37, 568-575, 828-830 (node)
  • Per-gateway persistence: src/OpenClaw.Tray.WinUI/Services/Connection/GatewayConnectionManager.cs:32, 234-237, 240-241

Why it matters

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.

Severity

High — protocol downgrade attack.

Activity

  1. added
    bug
    on May 14, 2026
  2. github-actions commented on May 14, 2026

    @github-actions
  3. github-actions commented on May 15, 2026

    @github-actions
    Contributor

    🤖 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:

    • 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.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
    
  4. shanselman commented on May 18, 2026

    @shanselman
    Collaborator

    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.

  5. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions