Article View: muc.lists.freebsd.bugs
Article #666[Bug 301053] fetch(1): FTP data connection does not go through SOCKS5_PROXY
From: bugzilla-noreply
Date: Mon, 23 Nov 2026 18:12
Date: Mon, 23 Nov 2026 18:12
59 lines
4091 bytes
4091 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301053
Bug ID: 301053
Summary: fetch(1): FTP data connection does not go through
SOCKS5_PROXY
Product: Base System
Version: 15.1-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
With SOCKS5_PROXY set, fetch connects to an ftp:// server through the proxy
for the control connection, but the data connection is opened directly. The
proxy never sees it. If the server is only reachable through the proxy, the
download fails.
I wrote a small SOCKS5 server that prints each CONNECT it gets, and ran
stock /usr/bin/fetch on 15.1-RELEASE-p6 (arm64) against a throwaway FTP
server that answers PASV:
$ SOCKS5_PROXY=127.0.0.1:1081 fetch -o out ftp://127.0.0.1:2395/f
$ cat proxy.log
PROXY CONNECT 127.0.0.1:2395
That is the control port. The 1000 bytes came over a second connection that
is not in the log. Everything was on loopback, so the direct connection worked
and the download succeeded. I did not test against a server that can only be
reached through the proxy.
In ftp_transfer() (lib/libfetch/ftp.c) the data socket comes from socket()
and connect(), not fetch_connect(), so the SOCKS5 handshake is never done for
it. For EPSV the address is taken from getpeername() on the control socket,
which with a proxy is the proxy's address. I only ran PASV; the EPSV part is
from reading the code.
I don't have a patch yet. One way is to do a SOCKS5 CONNECT to the address
and port from the PASV/EPSV reply. Active mode would need BIND, which libfetch
doesn't have, so it would have to fail when a SOCKS5 proxy is set. The other
way is to refuse FTP data connections when SOCKS5_PROXY is set and say why.
Which would you rather have?
The same code is in main. The proxy source is attached.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-301053-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 301053] fetch(1): FTP data connection does not go through SOCKS5_PROXY Date: Mon, 23 Nov 2026 18:12:20 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-301053-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="71214"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795457540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AlCRV1AHqAidAOSc0iQLiiYB6jCNMwo/pdx+LraJ1Hc=; b=qdray9LCtUGowKkWuj/FyGr1Y1S+JWqqd3MpQKgT7k2WpC2ljkNFA4nwknA236QbEDLn0S EF5t13icq1ioJP7zQIdhZGKrzhrCAJ9UTaZaULTyflQcAVtpUK9TGRx2zxMb5QwZunp1tF W9n3+fJZwH/sHmvoH2qEqG9QmZJ4fvCpCfrTRnvzUOHGyr/ZvgfOG2WJdxZOLdbO0fvgwz v2TGKDJWqd40VmW8toaSFtbYEAn8rKs47CIqmZXZdZs+HKxu5fgQDow/c8GNqE+KQCfKOx Q/lrwLgtCgYYlNTOgH5fAbqb58hxytNan4VTVJ0z5nTIvpnc1i0Vw4Zg3Ee5EA== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes