fix(security): pin validated DNS for bytes hostnames

This commit is contained in:
wkd authored and chengyongru committed 2026-10-10 11:58:04 +08:00
1 parent f04ed1c2eb
commit cb03b0938d
2 files changed
+91 -5

No files matched your search

+2 -1
View File
@@ -238,7 +238,8 @@ def pin_resolved_url_dns(url: str, resolved_ips: tuple[str, ...]):
proto: int = 0,
flags: int = 0,
) -> list[Any]:
if str(host).rstrip(".").lower() != pinned_host:
normalized_host = host.decode("ascii") if isinstance(host, bytes) else str(host)
if normalized_host.rstrip(".").lower() != pinned_host:
return original_getaddrinfo(host, port, family, type, proto, flags)
infos: list[Any] = []
for ip in resolved_ips: