libfetch connection reuse corrupts proxied requests after cross-host redirect
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
- Lĩnh vực
- networking
Hướng nghiên cứu
Start by reproducing the issue with xbps-fetch -v using the listed two-URL sequences, then trace libfetch's proxy connection reuse across the cross-host redirect. Focus on the cached CONNECT tunnel and connection state; done means sequential requests to different hosts open a correct tunnel or reset state, while same-host requests continue to work.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug: libfetch connection reuse corrupts proxied requests after cross-host redirect
Observed on: xbps 0.60.7, bundled libfetch
Proxy: HTTP_PROXY=http://localhost:1080 (sing-box mixed inbound, also using ALL_PROXY/SOCKS_PROXY)
Symptoms
xbps-install -S fetches repodata files for all configured repositories sequentially in a single process. The first repository always syncs successfully. Every subsequent repository fails with varying HTTP errors:
[reposync] failed to fetch file `https://github.com/.../x86_64-repodata': Forbidden
The status code depends on which server receives the corrupted request:
- GitHub releases (release-assets.githubusercontent.com): 403 Forbidden or 500 Internal Server Error
- voidlinux mirrors: 404 Not Found
Third-party repositories like the GitHub-hosted librewolf repo are always affected because they're listed last in the xbps config.
Isolated Reproduction
Tested with xbps-fetch -v (same libfetch as xbps-install), fetching two repodata URLs in one invocation:
| # | 1st URL | 2nd URL | Result |
|---|---|---|---|
| 1 | voidlinux | voidlinux (same host) | Both OK |
| 2 | voidlinux | github (→ release-assets) | 1st OK, 2nd = 403 |
| 3 | github (→ release-assets) | voidlinux | 1st OK, 2nd = 404 |
| 4 | github (→ release-assets) | github (→ release-assets) | 1st OK, 2nd = 500 |
| 5 | github (solo) | — | OK |
| 6 | voidlinux (solo) | — | OK |
Root Cause
After following an HTTP redirect to a different host (e.g., github.com → release-assets.githubusercontent.com), libfetch caches the proxy CONNECT tunnel for that host. When the subsequent fetch targets a different host, libfetch incorrectly reuses the cached tunnel — the HTTP request is sent with stale/wrong connection state, causing the server to reject it with varied error codes.
Same-host fetches (voidlinux → voidlinux) work because the cached tunnel still matches the connection target.
Traffic Pattern
libfetch connects to the HTTP proxy and uses a SOCKS5 + HTTP CONNECT sequence:
→ SOCKS5 greeting (method: no-auth)
→ SOCKS5 CONNECT to proxy's own loopback (localhost:1080)
→ HTTP CONNECT <target-host>:443
→ TLS handshake
→ HTTP GET /path
The first request follows this correctly. On the second request it reuses the first tunnel rather than opening a new one.
Workaround
Pre-fetch problem repos' repodata using xbps-fetch in separate invocations, then run xbps-install -S (the failed fetch leaves the existing file intact):
xbps-fetch -o /var/db/xbps/<repodir>/x86_64-repodata <repo-url>/x86_64-repodata
xbps-install -Su
Expected Fix
libfetch should either:
- Open a fresh proxy CONNECT tunnel for each host transition (correct behavior)
- Or properly reset connection state before reusing across hosts
System Details
Void Linux x86_64, kernel 7.1.3_1
xbps-0.60.7 (API: 20250629)
- Ngôn ngữ chính
- C
- Star
- 1.1k
- Fork
- 151
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của void-linux/xbps
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
void-linux/xbps#475 ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
void-linux/xbps#696 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
void-linux/xbps#695 · 7 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
void-linux/xbps#694 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
void-linux/xbps#693 · 1 bình luận ·
Tất cả issue của void-linux/xbps
Issue tương tự
-
level/task module/gcp type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Build failure with newer clang Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
P3 sonic-vpp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
sonic-net/sonic-buildimage#29662 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
spack/spack-packages#6586 ·