iOS sandbox: a reverse tunnel opens its port to the lease's own simulator while it runs
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- ios, swift, typescript
- Domaine
- mobile-dev, networking, security
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 730
- Forks
- 44
- Merge moyen
- 15 h 28 min
- PR mergées (30 j)
- 387
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de callstackincubator/simlock
-
bug:new
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
callstackincubator/simlock#2088 ·
Les mainteneurs répondent en général sous 1 jour
-
bug:new
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
callstackincubator/simlock#2080 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
task:ready
Difficulté 4/5 3-5 jours Accessibilité débutants 52/100
callstackincubator/simlock#2079 ·
Les mainteneurs répondent en général sous 1 jour
-
platform:ios task:ready
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 18/100
callstackincubator/simlock#2078 ·
Les mainteneurs répondent en général sous 1 jour
-
iOS copy: keep the app database at the copy's own UDIDPeut-être pris @V3RON l’a pris aujourd’hui. Ouverteplatform:ios task:ready
callstackincubator/simlock#2077 · 2 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de callstackincubator/simlock
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
earendil-works/gondolin#222 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
endora-commerce/endora-commerce#2203 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement priority:medium ready-for-human
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
wondermoney/wondermoney#1079 ·
Les mainteneurs répondent en général sous 1 jour