Skip to content

Local Model Error: Failed to establish connection to macOS system extension (deadline has elapsed) #7236

Open

Description

@Bojun-Feng

Problem Description

I installed mitmproxy and it ran wonderfully for around a day.
Then it suddenly stopped to work and instead gave the following error in local mode:

> mitmproxy --mode local
Error logged during startup:
failed to establish connection to macOS system extension

Caused by:
    deadline has elapsed

This only happens in the local mode on my MacBook, it still works when I connect my phone to it.

Steps to reproduce the behavior:

I ran the same command several times (continuously, without modifying any settings), and the it just suddenly stopped working on the last try. The error message was rather mysterious and I'm a bit lost on what might have gone wrong.

The exact command was:

mitmproxy --mode local --set console_mouse=false --view-filter '(~m POST | ~m PUT)' -s script.py

Here is a list of information that might be helpful:

System Information

Mitmproxy: 11.0.0 binary
Python:    3.12.6
OpenSSL:   OpenSSL 3.3.2 3 Sep 2024
Platform:  macOS-14.5-arm64-arm-64bit

Activity

  1. added
    kind/triage
    on Oct 11, 2024
  2. Bojun-Feng commented on Oct 11, 2024

    @Bojun-Feng
    Author

    Tried to uninstall and reinstall, did not fix the issue. Here are the executed commands:

    brew uninstall mitmproxy
    rm -rf ~/.mitmproxy
    brew cleanup
    brew install mitmproxy
    

    Seems like rustdesk also had a lot of trouble replicating the issue, in the end a user said the error was "caused by the client not being able to automatically connect through the transit tunnel", and forcing relay connection solved the issue. Unfortunately I have too little knowledge on the matter to understand what that means, but hopefully this information may be useful to the more experienced folks.

    UPDATE: I tried the exact same command after 5 minutes and suddenly it started working again! I honestly have no clue what happened but problem solved I guess?

    UPDATE2: It stopped working again, but this time I was trying to access Google and Youtube, which might be related? I also managed to collect some of the error logs that were printed in the terminal. They looked something like this:

    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    [e15bea35ca53f7ce] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [808bcb10a398e557] Error: 296, reason: No supported signature algorithm, frame_type: 6
    
    Full Logs
    > mitmproxy --mode local --set console_mouse=false --view-filter '(~m POST | ~m PUT)' -s script.py
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Server QUIC handshake failed. connection closed
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    Client QUIC handshake failed. connection closed early
    [e15bea35ca53f7ce] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [808bcb10a398e557] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [755bbdb644c611ac] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [9091702cd6826729] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [2456a43bb682e576] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [380d5155e7c475b1] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [9bc55106d2ee6228] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [0b09041b5d974e7e] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [8e6f0cc9b65a7b8c] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [183432f0c42cf7ef] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [640e0885c05503e6] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [f847dd9e4d2aebee] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [cdcf298cd73bc149] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [1e1a3944b3b70365] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [f67e7b60bfcb75c2] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [aeb19441f3388a3b] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [7ea99eae3a52b06d] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [c9211e1439bb93d8] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [65e7092245afc1fc] Error: 296, reason: No supported signature algorithm, frame_type: 6
    [a251f06339ddebda] Error: 296, reason: No supported signature algorithm, frame_type: 6
    
  3. mhils commented on Oct 11, 2024

    @mhils
    Member

    Thanks for the detailed report!

    deadline has elapsed

    This is a nice way of saying we hit a timeout, the rustdesk bug is very likely completely unrelated. :)

    The trigger for this is here:
    https://github.com/mitmproxy/mitmproxy_rs/blob/d81b68b0399def1c33835f18833e77ed614ad514/src/packet_sources/macos.rs#L82-L92. We're starting the network system extension, but then somehow fail to get a connection from it.

    It also has a wonderful "XXX: Saw some hangs here during development, not sure why." comment on it, so you are probably not alone. 😅 This is either us not doing a great job with starting up / tearing down the network system extension, or a macOS bug. Unfortunately I cannot reproduce it locally.

    Can you record system logs (https://support.apple.com/guide/console/log-messages-cnsl1012/mac) and see if there's anything interesting in there?

  4. Bojun-Feng commented on Oct 12, 2024

    @Bojun-Feng
    Author

    Even when the proxy is running I am encountering a duplicate of #6617, #7225, or #7082: Client & mitmproxy cannot agree on a TLS version to use no matter how tls_version_client_min is updated. Not sure if these 2 errors are related but I thought I can post the logs I collected.

    info: [13:37:03.779][10.150.121.3:55285] server connect xyks.website.com:443 (59.110.126.151:443)
    info: [13:37:03.786][10.150.121.3:55287] server connect xyks.website.com:443 (59.110.126.151:443)
    info: [13:37:03.981][10.150.121.3:55286] Client TLS handshake failed. The client disconnected during the handshake. If this happens consistently for inappcheck.itunes.apple.com, this may indicate
    that the client does not trust the proxy's certificate.
    info: [13:37:03.984][10.150.121.3:55289] server connect xyks.website.com:443 (8.152.208.113:443)
    info: [13:37:03.988][10.150.121.3:55288] server connect frog.website.com:443 (39.105.71.126:443)
    info: [13:37:03.989][10.150.121.3:55286] client disconnect
    

    Seems like there is a long history behind this bug. What's the current progress like on fixing the issue? Is there a general guess for what might have gone wrong? At first glance this seems like one of these mystery bugs that's caused by race conditions.

    Now the proxy is working again but with this different error. I am using my console to track all the logs. However, there are a lot of logs from different processes on my machine, are there any specific files / names / filters I should focus on? Sorry if this is a newbie question, I don't have much experience with tracking logs.

    UPDATE: I just searched mitmproxy and recorded all console logs from a working session with Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust mitmproxy's tls_version_client_min option error, I will also post a log when it crashes

    Full Logs From MitmProxy
    info: [14:06:02.481] Using existing mitmproxy redirector app.
    info: [14:06:02.557] Local redirector started.
    info: [14:06:02.698][127.0.0.1:0] client connect
    info: [14:06:02.714][127.0.0.1:0] server connect 17.248.207.66:443
    warn: [14:06:02.752][127.0.0.1:0] Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust mitmproxy's tls_version_client_min option.
    info: [14:06:02.752][127.0.0.1:0] client disconnect
    info: [14:06:02.753][127.0.0.1:0] server disconnect 17.248.207.66:443
    info: [14:06:04.806][127.0.0.1:0] client connect
    info: [14:06:04.824][127.0.0.1:0] server connect 17.248.210.70:443
    warn: [14:06:04.845][127.0.0.1:0] Client TLS handshake failed. Client and mitmproxy cannot agree on a TLS version to use. You may need to adjust mitmproxy's tls_version_client_min option.
    
    Full Logs From Console, From Starting Process to First Error
    default	14:06:02.487341-0500	Mitmproxy Redirector	[0x13a004ec0] activating connection: mach=true listener=false peer=false name=com.apple.sysextd
    default	14:06:02.491715-0500	Mitmproxy Redirector	[0x138706ee0] activating connection: mach=false listener=false peer=false name=(anonymous)
    default	14:06:02.491827-0500	Mitmproxy Redirector	[0x13a004ec0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
    default	14:06:02.492021-0500	sysextd	client activation request for org.mitmproxy.macos-redirector.network-extension
    default	14:06:02.492060-0500	sysextd	attempting to realize extension with identifier org.mitmproxy.macos-redirector.network-extension
    default	14:06:02.496104-0500	sysextd	realizing target path: file:///Applications/Mitmproxy%20Redirector.app/Contents/Library/SystemExtensions/org.mitmproxy.macos-redirector.network-extension.systemextension/
    default	14:06:02.505736-0500	sysextd	retrieved bundle code signing info: SecStaticCodeSigningInfo(entitlements: ["com.apple.developer.team-identifier": S8XHQB96PW, "com.apple.developer.networking.networkextension": <__NSArrayM 0x13770e9a0>(
    app-proxy-provider-systemextension
    )
    , "com.apple.application-identifier": S8XHQB96PW.org.mitmproxy.macos-redirector.network-extension], teamID: sysextd.TeamIDType.teamID("S8XHQB96PW"), cdHashes: ["0e9ba54a2e3b850c556e3cf4e40cf2469c111210": sysextd.ArchInfo(name: "x86_64", cputype: 16777223, cpusubtype: 3), "f19e330893fc151b85c3cde69ae8d720f5179aee": sysextd.ArchInfo(name: "arm64", cputype: 16777228, cpusubtype: 0)], signingIdentifier: "org.mitmproxy.macos-redirector.network-extension")
    default	14:06:02.505791-0500	sysextd	/Applications/Mitmproxy Redirector.app/Contents/Library/SystemExtensions/org.mitmproxy.macos-redirector.network-extension.systemextension: package type not `DEXT`
    default	14:06:02.505840-0500	sysextd	/Applications/Mitmproxy Redirector.app/Contents/Library/SystemExtensions/org.mitmproxy.macos-redirector.network-extension.systemextension: entitlement `com.apple.developer.endpoint-security.client` not present or not true
    default	14:06:02.514831-0500	sysextd	retrieved bundle code signing info: SecStaticCodeSigningInfo(entitlements: ["com.apple.developer.system-extension.install": 1, "com.apple.developer.team-identifier": S8XHQB96PW, "com.apple.developer.networking.networkextension": <__NSArrayM 0x138804320>(
    app-proxy-provider-systemextension
    )
    , "com.apple.application-identifier": S8XHQB96PW.org.mitmproxy.macos-redirector], teamID: sysextd.TeamIDType.teamID("S8XHQB96PW"), cdHashes: ["589e0e50c8a3098d742e215edf22a223a28d72df": sysextd.ArchInfo(name: "arm64", cputype: 16777228, cpusubtype: 0), "f03a5cee30628b4d0a1644701fa2388bdedc75ee": sysextd.ArchInfo(name: "x86_64", cputype: 16777223, cpusubtype: 3)], signingIdentifier: "org.mitmproxy.macos-redirector")
    default	14:06:02.514990-0500	sysextd	take reference:
        reference: (Optional("file:///.file/id=6571367.61165455/") + S8XHQB96PW + org.mitmproxy.macos-redirector)
        references: [(Optional("file:///.file/id=6571367.61165455/") + S8XHQB96PW + org.mitmproxy.macos-redirector)]
        result: false
    default	14:06:02.515172-0500	Mitmproxy Redirector	[0x138706ee0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
    default	14:06:02.516630-0500	Mitmproxy Redirector	[0x13a0086d0] activating connection: mach=true listener=false peer=false name=com.apple.cfprefsd.daemon
    default	14:06:02.516707-0500	Mitmproxy Redirector	[0x138611710] activating connection: mach=true listener=false peer=false name=com.apple.cfprefsd.agent
    default	14:06:02.518002-0500	Mitmproxy Redirector	[0x1386146d0] activating connection: mach=true listener=false peer=false name=com.apple.nehelper
    default	14:06:02.519033-0500	Mitmproxy Redirector	Sending load command to nehelper
    default	14:06:02.519085-0500	Mitmproxy Redirector	Clearing 8DA72D98-BC95-48F5-ACED-212FA095C14C from the loaded configurations
    default	14:06:02.519483-0500	Mitmproxy Redirector	Adding 8DA72D98-BC95-48F5-ACED-212FA095C14C to the loaded configurations
    default	14:06:02.519623-0500	Mitmproxy Redirector	[0x1386176b0] activating connection: mach=true listener=false peer=false name=com.apple.nesessionmanager
    default	14:06:02.519869-0500	nesessionmanager	Got a new session client connection from Mitmproxy Redirector(27769)
    default	14:06:02.519920-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Adding a connection for client Mitmproxy Redirector[27769]
    default	14:06:02.522547-0500	Mitmproxy Redirector	 Saving configuration mitmproxy with existing signature {length = 20, bytes = 0x170c094f010ed133f8468b9e6491b3f2c794df60}
    default	14:06:02.530349-0500	Mitmproxy Redirector	Received a com.apple.neconfigurationchanged notification with token 13
    default	14:06:02.530527-0500	Mitmproxy Redirector	 Successfully saved configuration mitmproxy
    default	14:06:02.530864-0500	Mitmproxy Redirector	Sending load command to nehelper
    default	14:06:02.530901-0500	Mitmproxy Redirector	Clearing 8DA72D98-BC95-48F5-ACED-212FA095C14C from the loaded configurations
    default	14:06:02.530982-0500	Mitmproxy Redirector	Sending load command to nehelper
    default	14:06:02.531009-0500	Mitmproxy Redirector	Clearing 8DA72D98-BC95-48F5-ACED-212FA095C14C from the loaded configurations
    default	14:06:02.531562-0500	Mitmproxy Redirector	Adding 8DA72D98-BC95-48F5-ACED-212FA095C14C to the loaded configurations
    default	14:06:02.531845-0500	Mitmproxy Redirector	Adding 8DA72D98-BC95-48F5-ACED-212FA095C14C to the loaded configurations
    default	14:06:02.532072-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Received a start command from Mitmproxy Redirector[27769]
    default	14:06:02.532095-0500	nesessionmanager	Registering session NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]
    default	14:06:02.534059-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Resetting VPN On Demand
    default	14:06:02.534117-0500	nesessionmanager	Found 1 registrations for org.mitmproxy.macos-redirector.network-extension (com.apple.networkextension.app-proxy)
    default	14:06:02.534154-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Plugin is registered with provider manager
    default	14:06:02.534193-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Plugin is installed
    default	14:06:02.535258-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateIdle: update configuration
    default	14:06:02.536711-0500	nesessionmanager	<NESMServer: 0x122009c50>: Register Enterprise VPN Session: NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]
    default	14:06:02.536772-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Successfully registered
    default	14:06:02.538489-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: status changed to connecting
    default	14:06:02.538803-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateIdle: received start message
    default	14:06:02.538882-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStateIdle
    default	14:06:02.538959-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStatePreparingNetwork, timeout 5 seconds
    default	14:06:02.539438-0500	nesessionmanager	Found 1 registrations for org.mitmproxy.macos-redirector.network-extension (com.apple.networkextension.app-proxy)
    default	14:06:02.539627-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStatePreparingNetwork
    default	14:06:02.539674-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStateStarting, timeout 300 seconds
    default	14:06:02.539781-0500	nesessionmanager	NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]): Sending start command
    default	14:06:02.540112-0500	org.mitmproxy.macos-redirector.network-extension	[0x13cf04bd0] Channel could not return listener port.
    default	14:06:02.540787-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Removing a connection for client Mitmproxy Redirector[27769]
    default	14:06:02.548518-0500	org.mitmproxy.macos-redirector.network-extension	[0x13da07cf0] activating connection: mach=false listener=true peer=false name=(anonymous)
    default	14:06:02.548549-0500	org.mitmproxy.macos-redirector.network-extension	[0x13da06d30] activating connection: mach=false listener=false peer=true name=com.apple.xpc.anonymous.0x13cf04bd0.peer[840].0x13da06d30
    default	14:06:02.555969-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) initialized with Mach-O UUIDs (
        "B195606E-764E-3BDC-8D17-EA273DAA2EE1"
    )
    default	14:06:02.556106-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStarting: plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) started with PID 27591 error (null)
    default	14:06:02.556462-0500	nesessionmanager	[Host org.mitmproxy.macos-redirector]: Starting with options 0x0
    default	14:06:02.556510-0500	org.mitmproxy.macos-redirector.network-extension	(0): Creating a new flow director
    default	14:06:02.556607-0500	org.mitmproxy.macos-redirector.network-extension	(0): Set SO_SNDBUF on the control socket to 1048576
    default	14:06:02.556618-0500	org.mitmproxy.macos-redirector.network-extension	(0): Set SO_RCVBUF on the control socket to 2097152
    default	14:06:02.556653-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Calling startProxyWithOptions with options 0x0
    default	14:06:02.556773-0500	org.mitmproxy.macos-redirector.network-extension	[C213 AD639EA5-C93F-4A42-80FB-D5468FEA4DF9 sockaddr#739898f5 tcp, attribution: developer, context: Default Network Context (private), proc: B195606E-764E-3BDC-8D17-EA273DAA2EE1] start
    default	14:06:02.556802-0500	org.mitmproxy.macos-redirector.network-extension	[C213 sockaddr#739898f5 initial parent-flow ((null))] event: path:start @0.000s
    default	14:06:02.556853-0500	org.mitmproxy.macos-redirector.network-extension	[C213 sockaddr#739898f5 waiting parent-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: path:satisfied @0.000s, uuid: 9FBB3382-EB4C-42DA-87BB-F8B02A0BCBA6
    error	14:06:02.557070-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_set_common_sockopts <private> setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
    error	14:06:02.557090-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_set_common_sockopts setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
    default	14:06:02.557305-0500	org.mitmproxy.macos-redirector.network-extension	[C213 sockaddr#739898f5 in_progress socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:start_connect @0.000s
    default	14:06:02.557354-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C213] reporting state preparing
    default	14:06:02.557454-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_connected [C213 sockaddr#739898f5 in_progress socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol connected (socket)
    default	14:06:02.557651-0500	org.mitmproxy.macos-redirector.network-extension	[C213 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:finish_connect @0.000s
    error	14:06:02.557754-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_copy_info <private> getsockopt TCP_INFO failed [102: Operation not supported on socket]
    error	14:06:02.557792-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_copy_info getsockopt TCP_INFO failed [102: Operation not supported on socket]
    default	14:06:02.557998-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C213] reporting state ready
    default	14:06:02.558085-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C213:1] Socket received CONNECTED event
    default	14:06:02.558152-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_connected [C213 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol connected (socket)
    default	14:06:02.558511-0500	nesessionmanager	[Host org.mitmproxy.macos-redirector]: setting tunnel configuration
    default	14:06:02.558335-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: provider set tunnel configuration to 
        tunnelRemoteAddress = <9-char-str>
        includedNetworkRules = (
            {
                matchRemotePrefix = 0
                matchProtocol = <3-char-str>
                matchDirection = <8-char-str>
                appliesToLoopback = NO
            },
        )
        isFullyTransparent = YES
    default	14:06:02.565282-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: didSetStatus - 4
    default	14:06:02.565303-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStarting: plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) status changed to connected
    default	14:06:02.565324-0500	nesessionmanager	<NESMServer: 0x122009c50>: Request to install session: NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]
    default	14:06:02.565344-0500	nesessionmanager	<NESMServer: 0x122009c50>: Request to install Session NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] is Enterprise -
    default	14:06:02.571670-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStarting: set configuration completed with result 1
    default	14:06:02.571732-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStateStarting
    default	14:06:02.571778-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStateRunning
    default	14:06:02.571845-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: status changed to connected
    default	14:06:02.571979-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Updated network agent (active, compulsory, not-user-activiated, not-kernel-activated)
    default	14:06:02.694274-0500	org.mitmproxy.macos-redirector.network-extension	(0): Flow 2785595450 is connecting
    default	14:06:02.694475-0500	org.mitmproxy.macos-redirector.network-extension	(2785595450): New flow: NEFlow type = stream, app = com.apple.syncdefaultsd, name = gateway.icloud.com, 10.150.100.91:0 <-> 17.248.207.66:443, filter_id = , interface = en0
    default	14:06:02.694750-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Calling handleNewFlow with TCP com.apple.syncdefaultsd[{length = 20, bytes = 0x06a654a8eeb0d050fab2b35937d06d21af62e577}] remote: 17.248.207.66:443 interface en0
    default	14:06:02.694971-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: provider accepted new flow TCP com.apple.syncdefaultsd[{length = 20, bytes = 0x06a654a8eeb0d050fab2b35937d06d21af62e577}] remote: 17.248.207.66:443 interface en0
    default	14:06:02.695430-0500	org.mitmproxy.macos-redirector.network-extension	[C214 FAEBF4B5-63B3-48A5-BCDD-B914FEACDFD7 sockaddr#739898f5 tcp, attribution: developer, context: Default Network Context (private), proc: B195606E-764E-3BDC-8D17-EA273DAA2EE1] start
    default	14:06:02.695481-0500	org.mitmproxy.macos-redirector.network-extension	[C214 sockaddr#739898f5 initial parent-flow ((null))] event: path:start @0.000s
    default	14:06:02.695563-0500	org.mitmproxy.macos-redirector.network-extension	[C214 sockaddr#739898f5 waiting parent-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: path:satisfied @0.000s, uuid: 9FBB3382-EB4C-42DA-87BB-F8B02A0BCBA6
    error	14:06:02.695856-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_set_common_sockopts <private> setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
    error	14:06:02.695904-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_set_common_sockopts setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
    default	14:06:02.696218-0500	org.mitmproxy.macos-redirector.network-extension	[C214 sockaddr#739898f5 in_progress socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:start_connect @0.000s
    default	14:06:02.696281-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C214] reporting state preparing
    default	14:06:02.696460-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_connected [C214 sockaddr#739898f5 in_progress socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol connected (socket)
    default	14:06:02.696774-0500	org.mitmproxy.macos-redirector.network-extension	[C214 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:finish_connect @0.001s
    error	14:06:02.696952-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_copy_info <private> getsockopt TCP_INFO failed [102: Operation not supported on socket]
    error	14:06:02.697024-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_copy_info getsockopt TCP_INFO failed [102: Operation not supported on socket]
    default	14:06:02.697448-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C214] reporting state ready
    default	14:06:02.697576-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C214:1] Socket received CONNECTED event
    default	14:06:02.697746-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_connected [C214 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol connected (socket)
    default	14:06:02.698857-0500	org.mitmproxy.macos-redirector.network-extension	(0): Flow 75163116 is connecting
    default	14:06:02.699033-0500	org.mitmproxy.macos-redirector.network-extension	(75163116): New flow: NEFlow type = stream, app = mitmproxy, name = , 10.150.100.91:0 <-> 17.248.207.66:443, filter_id = , interface = en0
    default	14:06:02.699331-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Calling handleNewFlow with TCP mitmproxy[{length = 20, bytes = 0xd294853402f5fdc6e6d2edd5742b0f2e565397b2}] remote: 17.248.207.66:443 interface en0
    default	14:06:02.699574-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: provider rejected new flow TCP mitmproxy[{length = 20, bytes = 0xd294853402f5fdc6e6d2edd5742b0f2e565397b2}] remote: 17.248.207.66:443 interface en0
    default	14:06:02.699887-0500	org.mitmproxy.macos-redirector.network-extension	(75163116): Closing reads (sending SHUT_WR), closed by plugin (flow error: 0)
    default	14:06:02.699932-0500	org.mitmproxy.macos-redirector.network-extension	(75163116): Closing writes, sending SHUT_RD
    default	14:06:02.699999-0500	org.mitmproxy.macos-redirector.network-extension	(75163116): Destroying, client tx 0, client rx 0, kernel rx 0, kernel tx 0
    default	14:06:02.752775-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C214:1] Socket received DISCONNECTED event
    default	14:06:02.752820-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C214:1] Socket SO_ERROR: 0
    default	14:06:02.752865-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_disconnected [C214 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol disconnected
    error	14:06:02.752952-0500	org.mitmproxy.macos-redirector.network-extension	nw_protocol_socket_reset_linger <private> setsockopt SO_LINGER failed [22: Invalid argument]
    default	14:06:02.753035-0500	org.mitmproxy.macos-redirector.network-extension	[C214 sockaddr#739898f5 failed socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:disconnect @0.057s
    default	14:06:02.753042-0500	org.mitmproxy.macos-redirector.network-extension	(2785595450): Closing reads (suppressing SHUT_WR), closed by plugin
    default	14:06:02.753068-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C214] reporting state failed error Network is down
    default	14:06:04.799104-0500	org.mitmproxy.macos-redirector.network-extension	(0): Flow 601189032 is connecting
    default	14:06:04.799493-0500	org.mitmproxy.macos-redirector.network-extension	(601189032): New flow: NEFlow type = stream, app = com.apple.syncdefaultsd, name = gateway.icloud.com, 10.150.100.91:0 <-> 17.248.210.70:443, filter_id = , interface = en0
    default	14:06:04.800040-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Calling handleNewFlow with TCP com.apple.syncdefaultsd[{length = 20, bytes = 0x06a654a8eeb0d050fab2b35937d06d21af62e577}] remote: 17.248.210.70:443 interface en0
    default	14:06:04.800597-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: provider accepted new flow TCP com.apple.syncdefaultsd[{length = 20, bytes = 0x06a654a8eeb0d050fab2b35937d06d21af62e577}] remote: 17.248.210.70:443 interface en0
    default	14:06:04.801604-0500	org.mitmproxy.macos-redirector.network-extension	[C215 5B76AAEC-E30E-4A63-B324-36AD32449965 sockaddr#739898f5 tcp, attribution: developer, context: Default Network Context (private), proc: B195606E-764E-3BDC-8D17-EA273DAA2EE1] start
    default	14:06:04.801700-0500	org.mitmproxy.macos-redirector.network-extension	[C215 sockaddr#739898f5 initial parent-flow ((null))] event: path:start @0.000s
    default	14:06:04.802326-0500	org.mitmproxy.macos-redirector.network-extension	[C215 sockaddr#739898f5 waiting parent-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: path:satisfied @0.000s, uuid: 9FBB3382-EB4C-42DA-87BB-F8B02A0BCBA6
    error	14:06:04.802927-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_set_common_sockopts <private> setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
    error	14:06:04.802968-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_set_common_sockopts setsockopt SO_NECP_CLIENTUUID failed [22: Invalid argument]
    default	14:06:04.803520-0500	org.mitmproxy.macos-redirector.network-extension	[C215 sockaddr#739898f5 in_progress socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:start_connect @0.001s
    default	14:06:04.803608-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C215] reporting state preparing
    default	14:06:04.803893-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_connected [C215 sockaddr#739898f5 in_progress socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol connected (socket)
    default	14:06:04.804421-0500	org.mitmproxy.macos-redirector.network-extension	[C215 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:finish_connect @0.002s
    error	14:06:04.804600-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_copy_info <private> getsockopt TCP_INFO failed [102: Operation not supported on socket]
    error	14:06:04.804685-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_copy_info getsockopt TCP_INFO failed [102: Operation not supported on socket]
    default	14:06:04.804961-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C215] reporting state ready
    default	14:06:04.805160-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C215:1] Socket received CONNECTED event
    default	14:06:04.805247-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_connected [C215 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol connected (socket)
    default	14:06:04.808609-0500	org.mitmproxy.macos-redirector.network-extension	(0): Flow 2391060714 is connecting
    default	14:06:04.808903-0500	org.mitmproxy.macos-redirector.network-extension	(2391060714): New flow: NEFlow type = stream, app = mitmproxy, name = , 10.150.100.91:0 <-> 17.248.210.70:443, filter_id = , interface = en0
    default	14:06:04.809271-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Calling handleNewFlow with TCP mitmproxy[{length = 20, bytes = 0xd294853402f5fdc6e6d2edd5742b0f2e565397b2}] remote: 17.248.210.70:443 interface en0
    default	14:06:04.809551-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: provider rejected new flow TCP mitmproxy[{length = 20, bytes = 0xd294853402f5fdc6e6d2edd5742b0f2e565397b2}] remote: 17.248.210.70:443 interface en0
    default	14:06:04.810282-0500	org.mitmproxy.macos-redirector.network-extension	(2391060714): Closing reads (sending SHUT_WR), closed by plugin (flow error: 0)
    default	14:06:04.810323-0500	org.mitmproxy.macos-redirector.network-extension	(2391060714): Closing writes, sending SHUT_RD
    default	14:06:04.810574-0500	org.mitmproxy.macos-redirector.network-extension	(2391060714): Destroying, client tx 0, client rx 0, kernel rx 0, kernel tx 0
    default	14:06:04.846785-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C215:1] Socket received READ_CLOSE event
    default	14:06:04.846874-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C215:1] Socket received DISCONNECTED event
    default	14:06:04.846899-0500	org.mitmproxy.macos-redirector.network-extension	nw_socket_handle_socket_event [C215:1] Socket SO_ERROR: 0
    default	14:06:04.846924-0500	org.mitmproxy.macos-redirector.network-extension	nw_flow_disconnected [C215 sockaddr#739898f5 ready socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] Output protocol disconnected
    default	14:06:04.846946-0500	org.mitmproxy.macos-redirector.network-extension	(601189032): Closing reads (suppressing SHUT_WR), closed by plugin
    error	14:06:04.846970-0500	org.mitmproxy.macos-redirector.network-extension	nw_protocol_socket_reset_linger <private> setsockopt SO_LINGER failed [22: Invalid argument]
    default	14:06:04.847110-0500	org.mitmproxy.macos-redirector.network-extension	[C215 sockaddr#739898f5 failed socket-flow (satisfied (Endpoint is always satisfied), interface: lo0)] event: flow:disconnect @0.045s
    default	14:06:04.847134-0500	org.mitmproxy.macos-redirector.network-extension	nw_connection_report_state_with_handler_on_nw_queue [C215] reporting state failed error Network is down
    
  5. Bojun-Feng commented on Oct 12, 2024

    @Bojun-Feng
    Author

    It crashed again on starting and I was able to grab the relevant console logs. Here is what it looks like in terminal:

    > mitmproxy --mode local --set console_mouse=false -s script.py
    Error logged during startup:
    failed to establish connection to macOS system extension
    
    Caused by:
        deadline has elapsed
    

    Seems like the error stems from calling NEFlowDirectorCreateInternal with null input:

    default	14:32:42.549977-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStarting: plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) started with PID 27591 error (null)
    default	14:32:42.550338-0500	nesessionmanager	[Host org.mitmproxy.macos-redirector]: Starting with options 0x0
    fault	14:32:42.550390-0500	org.mitmproxy.macos-redirector.network-extension	NEFlowDirectorCreateInternal called with null (control_socket >= 0)
    error	14:32:42.550438-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Cannot start the proxy because the flow director is nil
    

    Hopefully this helps! Please let me know if there are any other things I can do. I'm more than happy to help.

    Full Logs From Console
    default	14:32:42.472163-0500	Mitmproxy Redirector	[0x140804ec0] activating connection: mach=true listener=false peer=false name=com.apple.sysextd
    default	14:32:42.478575-0500	Mitmproxy Redirector	[0x136f06ff0] activating connection: mach=false listener=false peer=false name=(anonymous)
    default	14:32:42.478692-0500	Mitmproxy Redirector	[0x140804ec0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
    default	14:32:42.478904-0500	sysextd	client activation request for org.mitmproxy.macos-redirector.network-extension
    default	14:32:42.478941-0500	sysextd	attempting to realize extension with identifier org.mitmproxy.macos-redirector.network-extension
    default	14:32:42.482928-0500	sysextd	realizing target path: file:///Applications/Mitmproxy%20Redirector.app/Contents/Library/SystemExtensions/org.mitmproxy.macos-redirector.network-extension.systemextension/
    default	14:32:42.492510-0500	sysextd	retrieved bundle code signing info: SecStaticCodeSigningInfo(entitlements: ["com.apple.developer.networking.networkextension": <__NSArrayM 0x13880f0f0>(
    app-proxy-provider-systemextension
    )
    , "com.apple.application-identifier": S8XHQB96PW.org.mitmproxy.macos-redirector.network-extension, "com.apple.developer.team-identifier": S8XHQB96PW], teamID: sysextd.TeamIDType.teamID("S8XHQB96PW"), cdHashes: ["0e9ba54a2e3b850c556e3cf4e40cf2469c111210": sysextd.ArchInfo(name: "x86_64", cputype: 16777223, cpusubtype: 3), "f19e330893fc151b85c3cde69ae8d720f5179aee": sysextd.ArchInfo(name: "arm64", cputype: 16777228, cpusubtype: 0)], signingIdentifier: "org.mitmproxy.macos-redirector.network-extension")
    default	14:32:42.492574-0500	sysextd	/Applications/Mitmproxy Redirector.app/Contents/Library/SystemExtensions/org.mitmproxy.macos-redirector.network-extension.systemextension: package type not `DEXT`
    default	14:32:42.492624-0500	sysextd	/Applications/Mitmproxy Redirector.app/Contents/Library/SystemExtensions/org.mitmproxy.macos-redirector.network-extension.systemextension: entitlement `com.apple.developer.endpoint-security.client` not present or not true
    default	14:32:42.501458-0500	sysextd	retrieved bundle code signing info: SecStaticCodeSigningInfo(entitlements: ["com.apple.developer.system-extension.install": 1, "com.apple.developer.networking.networkextension": <__NSArrayM 0x13770a350>(
    app-proxy-provider-systemextension
    )
    , "com.apple.application-identifier": S8XHQB96PW.org.mitmproxy.macos-redirector, "com.apple.developer.team-identifier": S8XHQB96PW], teamID: sysextd.TeamIDType.teamID("S8XHQB96PW"), cdHashes: ["589e0e50c8a3098d742e215edf22a223a28d72df": sysextd.ArchInfo(name: "arm64", cputype: 16777228, cpusubtype: 0), "f03a5cee30628b4d0a1644701fa2388bdedc75ee": sysextd.ArchInfo(name: "x86_64", cputype: 16777223, cpusubtype: 3)], signingIdentifier: "org.mitmproxy.macos-redirector")
    default	14:32:42.501637-0500	sysextd	take reference:
        reference: (Optional("file:///.file/id=6571367.61165455/") + S8XHQB96PW + org.mitmproxy.macos-redirector)
        references: [(Optional("file:///.file/id=6571367.61165455/") + S8XHQB96PW + org.mitmproxy.macos-redirector)]
        result: false
    default	14:32:42.501816-0500	Mitmproxy Redirector	[0x136f06ff0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
    default	14:32:42.505182-0500	Mitmproxy Redirector	[0x1408070a0] activating connection: mach=true listener=false peer=false name=com.apple.cfprefsd.daemon
    default	14:32:42.505232-0500	Mitmproxy Redirector	[0x136e11710] activating connection: mach=true listener=false peer=false name=com.apple.cfprefsd.agent
    default	14:32:42.507313-0500	Mitmproxy Redirector	[0x136e146d0] activating connection: mach=true listener=false peer=false name=com.apple.nehelper
    default	14:32:42.508831-0500	Mitmproxy Redirector	Sending load command to nehelper
    default	14:32:42.508886-0500	Mitmproxy Redirector	Clearing 8DA72D98-BC95-48F5-ACED-212FA095C14C from the loaded configurations
    default	14:32:42.509358-0500	Mitmproxy Redirector	Adding 8DA72D98-BC95-48F5-ACED-212FA095C14C to the loaded configurations
    default	14:32:42.509479-0500	Mitmproxy Redirector	[0x136e12740] activating connection: mach=true listener=false peer=false name=com.apple.nesessionmanager
    default	14:32:42.509690-0500	nesessionmanager	Got a new session client connection from Mitmproxy Redirector(29069)
    default	14:32:42.510133-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Adding a connection for client Mitmproxy Redirector[29069]
    default	14:32:42.511581-0500	Mitmproxy Redirector	Last disconnect error for mitmproxy changed from "none" to "The operation couldn’t be completed. (NEAppProxyFlowErrorDomain error 8.)"
    default	14:32:42.514348-0500	Mitmproxy Redirector	 Saving configuration mitmproxy with existing signature {length = 20, bytes = 0x8151ab92baabd53d561853f5171203e7898df384}
    default	14:32:42.521042-0500	Mitmproxy Redirector	Received a com.apple.neconfigurationchanged notification with token 13
    default	14:32:42.521219-0500	Mitmproxy Redirector	 Successfully saved configuration mitmproxy
    default	14:32:42.521502-0500	Mitmproxy Redirector	Sending load command to nehelper
    default	14:32:42.521537-0500	Mitmproxy Redirector	Clearing 8DA72D98-BC95-48F5-ACED-212FA095C14C from the loaded configurations
    default	14:32:42.521620-0500	Mitmproxy Redirector	Sending load command to nehelper
    default	14:32:42.521647-0500	Mitmproxy Redirector	Clearing 8DA72D98-BC95-48F5-ACED-212FA095C14C from the loaded configurations
    default	14:32:42.522128-0500	Mitmproxy Redirector	Adding 8DA72D98-BC95-48F5-ACED-212FA095C14C to the loaded configurations
    default	14:32:42.522690-0500	Mitmproxy Redirector	Adding 8DA72D98-BC95-48F5-ACED-212FA095C14C to the loaded configurations
    default	14:32:42.522898-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Received a start command from Mitmproxy Redirector[29069]
    default	14:32:42.522952-0500	nesessionmanager	Registering session NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]
    default	14:32:42.524880-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Resetting VPN On Demand
    default	14:32:42.524940-0500	nesessionmanager	Found 1 registrations for org.mitmproxy.macos-redirector.network-extension (com.apple.networkextension.app-proxy)
    default	14:32:42.524972-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Plugin is registered with provider manager
    default	14:32:42.525007-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Plugin is installed
    default	14:32:42.526885-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateIdle: update configuration
    default	14:32:42.528532-0500	nesessionmanager	<NESMServer: 0x122009c50>: Register Enterprise VPN Session: NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]
    default	14:32:42.528589-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Successfully registered
    default	14:32:42.530783-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: status changed to connecting
    default	14:32:42.531069-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateIdle: received start message
    default	14:32:42.531354-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStateIdle
    default	14:32:42.531544-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStatePreparingNetwork, timeout 5 seconds
    default	14:32:42.532135-0500	nesessionmanager	Found 1 registrations for org.mitmproxy.macos-redirector.network-extension (com.apple.networkextension.app-proxy)
    default	14:32:42.532318-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStatePreparingNetwork
    default	14:32:42.532378-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStateStarting, timeout 300 seconds
    default	14:32:42.532485-0500	nesessionmanager	NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]): Sending start command
    default	14:32:42.532789-0500	org.mitmproxy.macos-redirector.network-extension	[0x13cf04bd0] Channel could not return listener port.
    default	14:32:42.533154-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Removing a connection for client Mitmproxy Redirector[29069]
    default	14:32:42.541657-0500	org.mitmproxy.macos-redirector.network-extension	[0x13da092f0] activating connection: mach=false listener=true peer=false name=(anonymous)
    default	14:32:42.541691-0500	org.mitmproxy.macos-redirector.network-extension	[0x13da09820] activating connection: mach=false listener=false peer=true name=com.apple.xpc.anonymous.0x13cf04bd0.peer[840].0x13da09820
    default	14:32:42.549829-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) initialized with Mach-O UUIDs (
        "B195606E-764E-3BDC-8D17-EA273DAA2EE1"
    )
    default	14:32:42.549977-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStarting: plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) started with PID 27591 error (null)
    default	14:32:42.550338-0500	nesessionmanager	[Host org.mitmproxy.macos-redirector]: Starting with options 0x0
    fault	14:32:42.550390-0500	org.mitmproxy.macos-redirector.network-extension	NEFlowDirectorCreateInternal called with null (control_socket >= 0)
    error	14:32:42.550438-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Cannot start the proxy because the flow director is nil
    default	14:32:42.550590-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: didSetStatus - 0
    default	14:32:42.550612-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStarting: plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) disconnected with reason Plugin initiated
    default	14:32:42.550642-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStateStarting
    default	14:32:42.550664-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStateStopping, timeout 20 seconds
    default	14:32:42.550693-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: config request: pushing handler [(null)] (null)
    default	14:32:42.550713-0500	nesessionmanager	<NESMServer: 0x122009c50>: Request to uninstall session: NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]
    default	14:32:42.550729-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: status changed to disconnecting
    default	14:32:42.550919-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Updated network agent (inactive, compulsory, not-user-activiated, not-kernel-activated)
    default	14:32:42.551204-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStopping: session is now uninstalled
    default	14:32:42.551225-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateStopping: plugin already disconnected, disposing all plugins
    default	14:32:42.551265-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStateStopping
    default	14:32:42.551285-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStateDisposing, timeout 5 seconds
    default	14:32:42.551368-0500	org.mitmproxy.macos-redirector.network-extension	[0x13da09820] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
    default	14:32:42.551480-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Session manager connection was invalidated
    default	14:32:42.551515-0500	org.mitmproxy.macos-redirector.network-extension	[Extension org.mitmproxy.macos-redirector]: Deallocating
    default	14:32:42.551613-0500	org.mitmproxy.macos-redirector.network-extension	[0x13da092f0] invalidated because the current process cancelled the connection by calling xpc_connection_cancel()
    default	14:32:42.551906-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateDisposing: plugin NEFlowDivertPlugin(org.mitmproxy.macos-redirector[inactive]) dispose complete
    default	14:32:42.551975-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)] in state NESMVPNSessionStateDisposing: all plugins have disposed
    default	14:32:42.552052-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Leaving state NESMVPNSessionStateDisposing
    default	14:32:42.552170-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Entering state NESMVPNSessionStateIdle
    error	14:32:42.552203-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: Disconnected session has 1 stale completionHandler(s)
    default	14:32:42.552239-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: config request: popping handler [(null)] (null)
    default	14:32:42.552700-0500	nesessionmanager	NESMTransparentProxySession[Primary Tunnel:mitmproxy:8DA72D98-BC95-48F5-ACED-212FA095C14C:(null)]: status changed to disconnected, last stop reason Plugin initiated
    
  6. mhils commented on Oct 15, 2024

    @mhils
    Member

    Even when the proxy is running I am encountering a duplicate of #6617, #7225, or #7082: Client & mitmproxy cannot agree on a TLS version to use no matter how tls_version_client_min is updated. Not sure if these 2 errors are related but I thought I can post the logs I collected.

    Your comment made me look into this again, the compatibility is now much improved on main via #7241. We'll ship a release soon. It is completely unrelated though. :)

    The console logs look promising, thanks. I won't get to that in the short term, but it looks like we have some pointers there to figure out what's wrong in https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-macos/redirector.

  7. deleted a comment from on Oct 28, 2024
  8. mhils commented on Oct 28, 2024

    @mhils
  9. sureshdsk commented on Mar 18, 2025

    @sureshdsk

    I'm also getting same error

    Mitmproxy: 11.1.3
    Python:    3.12.8
    OpenSSL:   OpenSSL 3.4.1 11 Feb 2025
    Platform:  macOS-14.3-arm64-arm-64bit
    

    It works if i don't pass the script.py. raises below error when using script.

    failed to establish connection to macOS system extension
    
    Caused by:
        deadline has elapsed
    
  10. redbeam commented on Apr 2, 2025

    @redbeam

    As a quick workaround, killing the system extension helps. After running mitmproxy again, a new process is started and everything seems to work (for a while).

    sudo pkill -9 org.mitmproxy.macos-redirector.network-extension

  11. ngyngcphu commented on Mar 3, 2026

    @ngyngcphu

    As a quick workaround, killing the system extension helps. After running mitmproxy again, a new process is started and everything seems to work (for a while).

    sudo pkill -9 org.mitmproxy.macos-redirector.network-extension

    Has this been resolved? I tried this way but still getting the same error. My mitmproxy version is 12.2.1

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions