Repository navigation
Closed
Labels
Description
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.
- The lookups are in the constructor, in
_GuardedConnection.connect(src/devops_cli/valkey/client.py:100) and in valkey-pyConnection._connect. _resolved_addresses(client.py:52) returns an empty list for a failed lookup when private networks are allowed, andvalidate_destination(:73) then passes.validate_destinationrefuses every link-local address, which includes 169.254.1.2 (src/devops_cli/http/egress.py:13-15).- fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 lists this change as its step C. It follows step B. After the split, fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 only tracks its child issues, and no pull request closes fix(valkey): one validated URL names every Valkey endpoint, valkey-py dials an address that one check vetted, and the unused cache layer goes #1113 itself. So this candidate asks for a change that no other issue holds.
Existing tool considered
devops_cli.http.egress.vet_addresses(host, port, level)is the shared resolve-and-check of fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898.- valkey-py has no resolver hook.
Connection._connectcallssocket.getaddrinfoitself.SSLConnectiontakes nossl_contextand setsserver_hostnamefromself.host. - So the build is one
_connectoverride in aConnectionsubclass, with one variant for TLS. The pull request states the cost in tokens and hours, as AGENTS.md requires for a build.
Proposed remedy
- Resolve the name once, at the dial, with
vet_addressesatEgressLevel.PRIVATE. - Dial the vetted IP literals in answer order, as
VettingBackend.connect_tcpdoes. - For
valkeys://, connect TCP to the vetted literal, and use the URL host for SNI and for the certificate check. - Delete
validate_destination,_resolved_addressesand theallow_private_networkargument fromvalkey/client.py.
Acceptance criteria
- The constructor makes no DNS lookup. A test patches
socket.getaddrinfoto 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, notSSRFBlockedError, and opens no socket. The same holds for169.254.169.254and::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
2130706433as127.0.0.1. - For
valkeys://, a loopback TLS server with a CA made bycryptographyshows 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_addressesand theallow_private_networkargument no longer exist invalkey/client.py. - Tests run offline and never resolve an external name.
uv run devops cipasses.
Source: #1113
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 23, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate fixes a security issue with DNS rebinding and egress checks.The fix prevents a known security vulnerability in DNS rebinding.The change improves security for all Valkey clients using this library.The change requires significant refactoring of the client's connection logic.fix(valkey): valkey.url keeps its scheme, so a valkeys url dials tls …