iOS sandbox: a reverse tunnel opens its port to the lease's own simulator while it runs
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- ios, swift, typescript
- Área
- mobile-dev, networking, security
Línea de trabajo
Read ADR 0103 sections 3a and 6, then trace the named entry points in drivers/ios/device-tcp.ts, drivers/ios/jail-grants.ts, and drivers/ios/jail/main.swift. Start with the listed B9 and B10 unit test seams, then cover the recovery and real simulator cases in e2e/slow-ios-sandbox.test.ts. Done means the specified behavior cases pass, the protocol version bump check passes, and the slow lane verifies grant, release, isolation, and reboot behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Part of #1648.
Scope
On a sandboxed worker a lease's reverse on a listed port opens that port to its own simulator while the simulator runs, with no reboot, and closes it again; other ports are refused with TUNNEL_PORT_NOT_ALLOWED. A tunnel connection is handed on only from the lease's own simulator, forward tunnels included. Grants come back after a recovery boot or a boot simlock did not make; a daemon start releases the port grants a crash left, so a lease reopens its reverse after a restart. An app cannot kill its simulator's launchd_sim, and after launchctl reboot agent-device boots it sandboxed.
If it goes wrong, Metro on a sandboxed worker cannot reach its dev server, or one lease reaches another lease's tunnel.
Technical spec
Commit b037ae2a0.
Rows
- Behaviours: B9, B10, B11, B16, B17
- Interfaces: I16, I9, I10, I12, I13
- Existing code: X4, X12, X13, X14, X20, X21, X22
Facts
none
Modules touched
drivers/ios (device-tcp.ts, index.ts, new jail-grants.ts, jail/main.swift issue, jail/Jail.swift grants watcher), ports (tcp-stream.ts, tcp-listener.ts, their Node adapters and fakes, filesystem.ts readSmallRegularFile), contract (errors.ts, protocol.ts), core (src/core/device-tcp.ts:7 DeviceTcpError code union gains TUNNEL_PORT_NOT_ALLOWED; src/tunnel/sessions.ts:457 passes it on), drivers/ios index.ts (IosSimctlDriver hands the grants writer to device-tcp.ts), src/drivers/ios/AGENTS.md (the tunnel rule on SIMULATOR_UDID), website (reference/errors.mdx, the tunnels page), e2e/slow-ios-sandbox.test.ts. Searches: rg "TUNNEL_PORT_IN_USE|holdsUdid|onConnection|TcpStream" src.
Rules in play
- ADR 0103 (Accepted — not yet implemented): the sections named on each line below; the feature's rows hold the shapes.
- ADR 0103 §3a, §6: tokens issued only by the worker with
simlock-jail, bound to the rootlaunchd_sim; self-issue denied; peer check by the process tree. - ADR 0064: a tunnel reaches simulator ports; the sandboxed check narrows who may listen.
- Contract: a new error code bumps
DAEMON_PROTOCOL_VERSIONby one in this PR. - Documentation rule 9:
errors.mdxand the tunnels page.
Tests
Seams: src/drivers/ios/device-tcp.test.ts:100 setup with scripted lsof and ps and a fake TcpStream with a peer; createDriver with a scripted grants file; the slow-lane file T2 adds.
- B9: On a sandboxed worker
reverse <port>on a listed port hassimlock-jail issue generic(I16) make a token bound to the rootlaunchd_sim, appends agrantline, waits for the acknowledgement, then opens;closeappends therelease; an unlisted port is refusedTUNNEL_PORT_NOT_ALLOWEDbefore anything listens; no acknowledgement within 2 s, or an acknowledgement file that is not a small regular file, closes the listeners and answersTUNNEL_FAILED: listed port; unlisted port; empty list; acknowledgement late; acknowledgement file a pipe or a link (read refused,TUNNEL_FAILED, no hang); port in use (TUNNEL_PORT_IN_USEfirst); close;issuefails; without the sandbox: no grant - B10: On a sandboxed worker a connection to a
reverselistener is handed on only when the process that opened it (found by its local port) descends from the lease's rootlaunchd_sim; a forward tunnel connects only to a listener whose process descends from it; otherwise the connection is closed: app of the lease; app of another simulator; worker process; peer exited beforelsof;lsoffails; process with a forgedSIMULATOR_UDID; a decoylaunchd_simof another simulator naming this lease's folder (not the root, refused); forward listener of another simulator with the lease'sSIMULATOR_UDID; without the sandbox: as today - B11: Inside a sandboxed simulator the jail library in the root
launchd_simconsumes each newgrantline of its grants file and releases on eachreleaseline, writing the last line's number to the acknowledgement file; a process of the simulator cannot issue acom.simlock.grant itself, cannot use a token it read from the grants file, cannot signal the rootlaunchd_simor start another one, and consumes every line whatever its result, so an old line's failed consume stops nothing: grant opens the port for a running app; release closes it; generic self-issue refused; file self-issue refused; a token read from the grants file and consumed by an app does nothing; an app's SIGKILL, SIGTERM and SIGSTOP of the rootlaunchd_simrefused; an app'skill(-1, SIGKILL)leaves the rootlaunchd_simrunning; an app's exec oflaunchd_simrefused; an ad-hoc signed program namedcom.apple.xpc.launchdstays killable; an app'slaunchctl rebootshuts the simulator down and agent-device's next command boots it sandboxed (B18, B17); a token line bound to an olderlaunchd_simis skipped - B16: At startup on a sandboxed worker, the iOS driver appends a
releaseline for every port grant left in a leased simulator's grants file, and numbers new lines after the file's last one; after a recovery boot it issues the grant of eachreversetunnel of that lease still open: two port grants left: two releases; none left; recovery with one openreverse: one new grant - B17: On a sandboxed worker, when
listManagedfinds a leased simulator's rootlaunchd_simwith another pid than the one its last driver boot recorded and the check passes, the driver records the new pid in place of the old (X4) and issues again the grants of that lease's openreversetunnels, as after a recovery boot (B16); the lease-folder grant follows the new pid by itself (B12); found at the health monitor's next tick (src/leasing/lease-health-monitor.ts:113, everyhealth.probeIntervalMs): same pid: nothing; new pid, check passes, one openreverse: one grant bound to the new pid; the next tick with the same new pid: nothing; new pid, check fails: B15; new pid, no open tunnel: no line
Done when
- Every unit case of B9, B10, B16, B17 passes.
.agents/scripts/protocol-bump-check.mjspasses with the bump.- Slow lane (real simulator):
e2e/slow-ios-sandbox.test.tsruns B11's cases: a grant opens a port for a running app and a release closes it, self-issued and copied tokens do nothing, the kill routes are refused, and after an app'slaunchctl rebootagent-device's next command boots the simulator sandboxed.
Out of scope
The lease-folder grant (T5).
Depends on
- #2043 because: the profile's port pairs and the root lookup (I2, X14)
- #1153 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #1154 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #1155 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #1904 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #1905 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #1907 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #2005 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts) - #2006 because: both bump
DAEMON_PROTOCOL_VERSION(src/contract/protocol.ts)
Written by an agent.
- Lenguaje dominante
- TypeScript
- Estrellas
- 730
- Forks
- 44
- Merge medio
- 15 h 28 min
- PR fusionados (30 d)
- 387
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de callstackincubator/simlock
-
bug:new
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
callstackincubator/simlock#2088 ·
Los mantenedores suelen responder en 1 día
-
bug:new
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
callstackincubator/simlock#2080 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
task:ready
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
callstackincubator/simlock#2079 ·
Los mantenedores suelen responder en 1 día
-
platform:ios task:ready
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
callstackincubator/simlock#2078 ·
Los mantenedores suelen responder en 1 día
-
iOS copy: keep the app database at the copy's own UDIDPosiblemente ocupada @V3RON la tomó hoy. Abiertoplatform:ios task:ready
callstackincubator/simlock#2077 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de callstackincubator/simlock
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
earendil-works/gondolin#222 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
endora-commerce/endora-commerce#2203 ·
Los mantenedores suelen responder en 1 día
-
enhancement priority:medium ready-for-human
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
wondermoney/wondermoney#1079 ·
Los mantenedores suelen responder en 1 día