Skip to content

Local redirect mode reports is_running=true before the macOS extension is approved and capturing #8632

Open

Description

@Giardi77

Problem Description

LocalRedirectorInstance._start assigns cls._instance = self before awaiting mitmproxy_rs.local.start_local_redirector(...) (mitmproxy/proxy/mode_servers.py:452-462), and is_running is self._instance is not None (mitmproxy/proxy/mode_servers.py:428). On macOS the start includes the first-run system-extension approval and a control-channel handshake with a 5 s timeout. During that wait to_json()["is_running"] is already true, so an addon cannot tell "waiting for approval" from "capturing". If the handshake times out, _instance is reset and last_exception is set, but a reader during the wait sees a running instance.

There is also no way to read the active intercept spec or the extension/approval state: listen_addrs is (), LocalRedirector.unavailable_reason() returns None on macOS regardless of approval, and requestNeedsUserApproval is only logged by the redirector app. _stop() empties the intercept but keeps the extension installed, again with no observable state beyond is_running=False.

Steps to reproduce

On macOS, with the network system extension not yet approved:

mitmdump --mode local

An addon that reads ctx.master.addons.get("proxyserver").servers during startup sees is_running: true while the approval is still pending. I did not run this end-to-end (it installs and prompts for a system extension); the state transition is from the v12.3.1 code path cited above.

Proposal

  • Make is_running true only after the redirector control channel is established, or expose an explicit state (stopped / awaiting approval / starting / running / failed) with a reason.
  • Expose the active intercept spec and the extension's approval state to addons.
  • If the control-channel timeout fires while approval is pending, report that as "awaiting approval" rather than a generic timeout.

Additional context

A desktop UI built on mitmdump shows a Local capture row; it must not tell the user "capturing" while macOS still waits for approval. Related: #7236 (startup timeout), #6970 (redirector output).

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions