Commit 8a7a86b
committed
fix(proxy): preserve SOCKS5 remote DNS semantics
SOCKS5 clients can send domain-name targets with ATYP=0x03, which gives the proxy an unresolved hostname and lets resolution happen on a remote transport path. If that flow later falls through to raw TCP direct passthrough, TcpStream::connect((host, port)) asks the local resolver for the destination address and can expose the target hostname outside the tunnel.
The SOCKS5 request handler now marks ATYP=domain flows as requiring remote DNS preservation before handing the stream to the shared tunnel dispatcher. HTTP CONNECT and plain HTTP proxy requests pass the flag disabled, so this guard is tied to SOCKS5 domain-name semantics rather than changing every proxy mode.
Raw TCP passthrough now refuses direct hostname fallback when remote DNS is required and no upstream SOCKS5 proxy is available. If an upstream SOCKS5 proxy is configured, the hostname is sent to that proxy unchanged so resolution can remain remote. If the upstream SOCKS5 connection fails for a hostname that requires remote DNS, the proxy returns without falling back to direct local resolution.
IP literals remain eligible for direct passthrough because they do not require DNS resolution. Full Tunnel, Apps Script HTTP relay, MITM relay, and SNI-rewrite paths continue to receive the original hostname without introducing local destination lookups.
The guide documents the fail-closed behavior for SOCKS5 domain targets, and unit coverage exercises hostname refusal, IPv4 and IPv6 literal allowance, upstream SOCKS5 allowance, and non-SOCKS call-site behavior.1 parent 40b5386 commit 8a7a86b
3 files changed
Lines changed: 104 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
835 | | - | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
836 | 846 | | |
837 | 847 | | |
838 | 848 | | |
| |||
960 | 970 | | |
961 | 971 | | |
962 | 972 | | |
963 | | - | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
964 | 985 | | |
965 | 986 | | |
966 | 987 | | |
| |||
1626 | 1647 | | |
1627 | 1648 | | |
1628 | 1649 | | |
| 1650 | + | |
1629 | 1651 | | |
1630 | 1652 | | |
1631 | 1653 | | |
| |||
1641 | 1663 | | |
1642 | 1664 | | |
1643 | 1665 | | |
1644 | | - | |
| 1666 | + | |
1645 | 1667 | | |
1646 | 1668 | | |
1647 | 1669 | | |
| |||
1675 | 1697 | | |
1676 | 1698 | | |
1677 | 1699 | | |
1678 | | - | |
| 1700 | + | |
1679 | 1701 | | |
1680 | 1702 | | |
1681 | 1703 | | |
| |||
1761 | 1783 | | |
1762 | 1784 | | |
1763 | 1785 | | |
1764 | | - | |
| 1786 | + | |
1765 | 1787 | | |
1766 | 1788 | | |
1767 | 1789 | | |
| |||
1776 | 1798 | | |
1777 | 1799 | | |
1778 | 1800 | | |
1779 | | - | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
1780 | 1809 | | |
1781 | 1810 | | |
1782 | 1811 | | |
| |||
1802 | 1831 | | |
1803 | 1832 | | |
1804 | 1833 | | |
1805 | | - | |
| 1834 | + | |
1806 | 1835 | | |
1807 | 1836 | | |
1808 | 1837 | | |
| |||
1843 | 1872 | | |
1844 | 1873 | | |
1845 | 1874 | | |
1846 | | - | |
| 1875 | + | |
1847 | 1876 | | |
1848 | 1877 | | |
1849 | 1878 | | |
| |||
1854 | 1883 | | |
1855 | 1884 | | |
1856 | 1885 | | |
| 1886 | + | |
1857 | 1887 | | |
1858 | 1888 | | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
1859 | 1898 | | |
1860 | 1899 | | |
1861 | 1900 | | |
| |||
1867 | 1906 | | |
1868 | 1907 | | |
1869 | 1908 | | |
1870 | | - | |
| 1909 | + | |
1871 | 1910 | | |
1872 | 1911 | | |
1873 | 1912 | | |
| |||
1879 | 1918 | | |
1880 | 1919 | | |
1881 | 1920 | | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
1882 | 1931 | | |
1883 | 1932 | | |
1884 | 1933 | | |
| |||
1928 | 1977 | | |
1929 | 1978 | | |
1930 | 1979 | | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
1931 | 1988 | | |
1932 | 1989 | | |
1933 | 1990 | | |
| |||
3228 | 3285 | | |
3229 | 3286 | | |
3230 | 3287 | | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
3231 | 3322 | | |
3232 | 3323 | | |
3233 | 3324 | | |
| |||
0 commit comments