I installed proxychains-ng to force certain programs to go through a proxy, but found it works inconsistently on macOS.
After some research, the culprit is macOS SIP (System Integrity Protection).
proxychains4 works by replacing the dynamic libraries of child processes to force them through a proxy. However, macOS SIP prevents all built-in executables from having their dynamic libraries replaced for security reasons — so proxychains4 simply doesn’t work with anything under /usr/bin/.
The fix: use the Homebrew-installed version of the program instead. Programs installed via Homebrew aren’t protected by SIP. (If you absolutely must use a built-in binary, you’d have to disable SIP — but that’s a last resort.)
If both /usr/bin and /opt/homebrew/bin have a program, you can adjust priority by reordering /opt/homebrew/bin in your PATH.
Special case: the Homebrew-installed curl lives at /opt/homebrew/opt/curl/bin.
1export PATH=/opt/homebrew/bin:/usr/bin:$PATH