The port was open, but the risk was hidden. Socat made the connection, yet without least privilege, that connection could become a breach.
Least privilege is not theory. It is the difference between a tunnel that serves its purpose and a tunnel that leaks everything. When you use Socat to forward ports, run command listeners, or bridge systems, the process often gains more access than it needs. That extra access is attack surface. Cut it down.
Start with the user. Do not run Socat as root unless you must. Create a dedicated system user with minimal rights. Restrict file system access, environment variables, and network permissions. On Linux, combine this with setcap to grant only the exact capabilities Socat requires—nothing more.
Lock down your target ports. Use firewall rules to accept traffic only from trusted sources. Pair this with Socat’s own filtering options, such as TCP-LISTEN with fork and reuseaddr, but bound tightly to specific addresses. Avoid wildcard binds like 0.0.0.0 unless absolutely necessary.