Skip to content

fix(valkey): the Valkey client resolves a name once, vets every answer and dials the vetted address #1988

Closed

Description

@dan-petty

Friction

  • The Valkey client resolves a name three times. The egress check covers only the first two lookups, so a rebinding DNS server can answer the third lookup with an address that the check never saw.
  • When a lookup fails and the caller allows private networks, the check passes with no address.
  • The check refuses every link-local address, also the address that rootless Podman uses to reach its host.

Evidence

Checked at main a752a14.

Existing tool considered

Proposed remedy

  • Resolve the name once, at the dial, with vet_addresses at EgressLevel.PRIVATE.
  • Dial the vetted IP literals in answer order, as VettingBackend.connect_tcp does.
  • For valkeys://, connect TCP to the vetted literal, and use the URL host for SNI and for the certificate check.
  • Delete validate_destination, _resolved_addresses and the allow_private_network argument from valkey/client.py.

Acceptance criteria

  • The constructor makes no DNS lookup. A test patches socket.getaddrinfo to raise, and the constructor still returns.
  • One dial makes exactly one lookup. A test counts the calls. The name answers one loopback address first and another address second, and the client connects to the first address.
  • The client dials the vetted IP literals in answer order. A test gives two answers: the first refuses the connection and the second accepts it. The client connects.
  • A name with a metadata answer raises ValkeyConnectionError, not SSRFBlockedError, and opens no socket. The same holds for 169.254.169.254 and ::ffff:169.254.169.254.
  • A failed lookup raises ValkeyConnectionError, and the message names the host. This holds also when the caller allows private networks.
  • The client dials a link-local address that is not a metadata address, such as 169.254.1.2.
  • The client judges and dials a numeric spelling such as 2130706433 as 127.0.0.1.
  • For valkeys://, a loopback TLS server with a CA made by cryptography shows that the client accepts a certificate for the URL host, refuses a certificate for another name from the same CA, and sends no command over the refused handshake.
  • validate_destination, _resolved_addresses and the allow_private_network argument no longer exist in valkey/client.py.
  • Tests run offline and never resolve an external name. uv run devops ci passes.

Source: #1113

Activity

  1. added
    source/agent
    type/security
    on Oct 23, 2026
  2. dan-petty commented on Oct 23, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/security. The candidate fixes a security issue with DNS rebinding and egress checks.
    • Priority: P1-High. The fix prevents a known security vulnerability in DNS rebinding.
    • Value: High. The change improves security for all Valkey clients using this library.
    • Effort: High. The change requires significant refactoring of the client's connection logic.
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

    source/agenttype/security

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions