How to find caller process name in NetworkExtension that Monterey's Safari.

Hello,

I have an issue when I develop NetworkExtension in Monterey and Safari. I want find a caller process name when metadata that sourceAppAuditToken is not exist.

I compare blocked content with process fd information using IP:PORT.

// 0. Input blockedSrc, blockedDest
if([[blockedPacket metadata] sourceAppAuditToken] == nil )
{
    // 1. get a list of process pid.
    sysctl( procList ... );
    kinfo_proc proc = procList[procIdx];

    // 2. get process fd Information
    proc_pidinfo(proc.kp_proc.p_pid, PROC_PIDLISTFDS, socketInfo, ...);

    // 3.  get IP, Port in process information.
    srcIP = (struct in_addr *)&socketInfo.psi.soi_proto.pri_tcp.tcpsi_ini.insi_laddr.ina_46.i46a_addr4;
    srcPort = (int)socketInfo.psi.soi_proto.pri_tcp.tcpsi_ini.insi_lport;
    destIP = (struct in_addr *)&socketInfo.psi.soi_proto.pri_tcp.tcpsi_ini.insi_faddr.ina_46.i46a_addr4;
    destPort = (int)socketInfo.psi.soi_proto.pri_tcp.tcpsi_ini.insi_fport;
    ...
    
    // 4. compare blocked content with information using srcIP:Port and destIP:Port
    if( blockedSrc == src && blockedDest == dest )
    {
        // 5. found process name
        proc_pidpath(proc.kp_proc.p_pid, pathBuffer, sizeof(pathBuffer)-1);
    }
}

In BigSur Chrome, Safari and Monterey Chrome is working same routine. and In these case, I can found list of process that open TCP using terminal("lsof -i -P")

But it is not works when use Safari in Monterey. So, I have checked a list of process that open TCP in Monterey. I have couldn't found it.

How can I found caller process name in Monterey when Safari web is blocking? Thank you for reading.

I’d like to clarify this situation. Reading your post it seems like you can reproduce the core problem without any of your code. That is:

  1. Make an outgoing TCP connection with Safari on macOS 12 beta.

  2. Run lsof and see that no process has a socket file descriptor that matches that TCP connection.

Is that right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

For those reading along at home, Matt is helping blackson in another context.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to find caller process name in NetworkExtension that Monterey's Safari.
 
 
Q