Skip to content

CPace guard: forged UDP PAKE1 can ban a client's address or use up the global budget #207

Open

Description

@compot-dev

From the Qodo review of #202 (finding 9), confirmed in the code.

The CPace guard (src/cpaceguard.c, server_handle_pake1()) counts PAKE1 attempts by the UDP source address, and nothing proves that the sender can receive at that address before the attempt is counted. Over UDP the source can be forged, so:

  • cpace_ban_after (30) forged PAKE1 packets from a victim's address (one camera, or a NAT with many) ban it for cpace_ban_time (600 s); an address with a confirmed client within the hour is never banned, but after a server restart no address has one yet;
  • forged PAKE1 from many random addresses at about cpace_total (300) a minute drain the shared bucket, so no unconfirmed client gets a CPace attempt, and they push the confirmed entries out of the fixed 256-slot table.

TCP is not affected: the handshake proves the address.

Options:

  1. A cookie round trip before CPace on UDP (like DTLS / WireGuard under load): the first PAKE1 from an address gets a stateless cookie (a MAC of the address and a rotating secret); only a PAKE1 that carries it is counted and answered. Costs one round trip, only when the guard sees load.
  2. Ban only on TCP, rate-limit only on UDP: forged UDP can still use up the budget, but cannot ban anyone.
  3. Keep the confirmed entries apart from the table forged sources can fill.

1 is the real fix and fits the protocol's message types; 2 and 3 are small steps that can come first.

Activity

  1. added
    securitySecurity vulnerability or hardening
    protocolWire protocol / crypto design
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    protocolWire protocol / crypto designsecuritySecurity vulnerability or hardening

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions