/usr/bin/cat establishing connections?

Hi, today I was reviewing Portmaster dashboard and I saw /usr/bin/cat in the list of processes establishing connections to some external IP. This caught my attention as I am not aware of any situation in which cat would ‘own’ a TCP connection. In any situation I can think of the connection would be owned by a different process, not cat. Eg: In a script which uploads something it would be curl, wget, etc or even in a plain redirection (eg: cat < /dev/null > /dev/tcp/www.msn.com/443; echo $?), it would be the shell owning the connection, not cat.

I checked that the sha256sum in my laptop and the package one matched:

8ac897b56dba6fbc560675371ca6c15b5ef73efe695010e8838fd6583b04d158  /usr/bin/cat
Information for package coreutils:
----------------------------------
Repository     : Repositorio principal (OSS)
Name           : coreutils
Version        : 9.1-5.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 5.8 MiB
Installed      : Yes
Status         : up-to-date
Source package : coreutils-9.1-5.1.src
Upstream URL   : https://www.gnu.org/software/coreutils/
Summary        : GNU Core Utilities

Am I missing something? Can anyone explain any circumstance where it is possible to make cat establish these connections?

For example in this snippet bash is establishing the connection via redirection first. Then the exec command is replacing the bash process with cat reusing the open file descriptors. Basically any process could use this fork/exec pattern. First fork a new process establish the connection and then exec the cat.

#!/bin/bash

exec cat </tmp/upload.dat > /dev/tcp/127.0.0.1/4242
2 Likes

Yeah true, thanks so much!