Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

cfw: iBoot: disable skywalk fsw netagents on iOS 18 (if_attach_nx=0x3)

zqxwce8781e20c76f6
diff --git a/research/0_binary_patch_comparison.md b/research/0_binary_patch_comparison.md
index b76a0377..667ae852 100644
--- a/research/0_binary_patch_comparison.md
+++ b/research/0_binary_patch_comparison.md
@@ -65,7 +65,7 @@
| --- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ | :-----: | :-: | :-: |
| 1 | Serial labels (2x) | "Loaded iBEC" in serial log | Y | Y | Y |
| 2 | `image4_validate_property_callback` | Signature bypass | Y | Y | Y |
-| 3 | Boot-args redirect | ADRP+ADD -> `serial=3 -v debug=0x2014e %s` | Y | Y | Y |
+| 3 | Boot-args redirect | ADRP+ADD -> `serial=3 -v debug=0x2014e %s`; iOS 18 base adds `if_attach_nx=0x3` (skywalk BSD_ONLY: disables fsw netagents so Network.framework uses BSD sockets, fixes mDNSResponder skywalk-channel crash-loop / DNS) | Y | Y | Y |
| 4 | Modern bootx-handoff panic bypass | `IBootPatcher.patchBootxPrecondition` NOPs gate TBZ via structural anchor (no hash/line tied); no-op pre-26.4 | Y | Y | Y |
| 5 | Ramdisk boot-args overwrite | `ramdisk_build.py:patch_ibec_bootargs` rewrites string to `... rd=md0 ... wdt=-1 ...` (ramdisk-send iBEC only) | Y | Y | Y |
@@ -75,7 +75,7 @@
| --- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ | :-----: | :-: | :-: |
| 1 | Serial labels (2x) | "Loaded LLB" in serial log | Y | Y | Y |
| 2 | `image4_validate_property_callback` | Signature bypass | Y | Y | Y |
-| 3 | Boot-args redirect | ADRP+ADD -> `serial=3 -v debug=0x2014e %s` | Y | Y | Y |
+| 3 | Boot-args redirect | ADRP+ADD -> `serial=3 -v debug=0x2014e %s`; iOS 18 base adds `if_attach_nx=0x3` (skywalk BSD_ONLY: disables fsw netagents so Network.framework uses BSD sockets, fixes mDNSResponder skywalk-channel crash-loop / DNS) | Y | Y | Y |
| 4 | Rootfs bypass (5 patches) | Allow edited rootfs loading | Y | Y | Y |
| 5 | Panic bypass | NOP `cbnz` after `mov w8,#0x328` check | Y | Y | Y |
diff --git a/sources/FirmwarePatcher/IBoot/IBootPatcher.swift b/sources/FirmwarePatcher/IBoot/IBootPatcher.swift
index fdd2daeb..a80f15a0 100644
--- a/sources/FirmwarePatcher/IBoot/IBootPatcher.swift
+++ b/sources/FirmwarePatcher/IBoot/IBootPatcher.swift
@@ -35,6 +35,14 @@ public class IBootPatcher: Patcher {
public let component: String
public let verbose: Bool
+ /// Extra boot-args token(s) inserted before the trailing `%s` in the
+ /// patched boot-args (ibec/llb). Used to add `if_attach_nx=0x3` on iOS 18
+ /// bases (disables the skywalk flowswitch netagents so Network.framework
+ /// uses the BSD path; the 26.1-kernel skywalk channel-create traps in the
+ /// 18.x Network.framework and crash-loops mDNSResponder → no DNS). Empty
+ /// by default, so 26.x bases keep the stock boot-args.
+ public var extraBootArgs: String = ""
+
let buffer: BinaryBuffer
let mode: Mode
let disasm = ARM64Disassembler()
@@ -305,9 +313,17 @@ public class IBootPatcher: Patcher {
// MARK: - 3. Boot-Args (iBEC / LLB)
+ /// Effective boot-args string, with any `extraBootArgs` inserted before `%s`.
+ private var effectiveBootArgs: String {
+ extraBootArgs.isEmpty
+ ? IBootPatcher.bootArgs
+ : "serial=3 -v debug=0x2014e \(extraBootArgs) %s"
+ }
+
/// Redirect ADRP+ADD x2 to a custom boot-args string.
/// Python: `patch_boot_args()`
- func patchBootArgs(newArgs: String = IBootPatcher.bootArgs) {
+ func patchBootArgs(newArgs: String? = nil) {
+ let newArgs = newArgs ?? effectiveBootArgs
guard let newArgsData = newArgs.data(using: .ascii) else { return }
guard let fmtOff = findBootArgsFmt() else {
diff --git a/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift b/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
index d6a9decb..a789de1c 100644
--- a/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
+++ b/sources/FirmwarePatcher/Pipeline/FirmwarePipeline.swift
@@ -196,6 +196,12 @@ public final class FirmwarePipeline {
// capturing self). True only for iOS 18 bases; gates the EXC_GUARD patch.
let applyExcGuard = iosBaseIs18
+ // iOS 18 bases: disable the skywalk flowswitch netagents via boot-arg so
+ // Network.framework uses the BSD path (the 26.1-kernel skywalk
+ // channel-create traps in the 18.x Network.framework and crash-loops
+ // mDNSResponder → no DNS). Empty on 26.x bases (stock boot-args).
+ let extraBootArgs = iosBaseIs18 ? "if_attach_nx=0x3" : ""
+
// 1. AVPBooter — always present, lives in VM root.
// Patched for every non-less variant (regular/dev/jb/exp).
components.append(ComponentDescriptor(
@@ -246,7 +252,9 @@ public final class FirmwarePipeline {
inRestoreDir: true,
searchPatterns: ["Firmware/dfu/iBEC.vresearch101.RELEASE.im4p"],
patcherFactories: [{ data, verbose in
- IBootPatcher(data: data, mode: .ibec, verbose: verbose)
+ let p = IBootPatcher(data: data, mode: .ibec, verbose: verbose)
+ p.extraBootArgs = extraBootArgs
+ return p
}]
))
@@ -256,7 +264,9 @@ public final class FirmwarePipeline {
inRestoreDir: true,
searchPatterns: ["Firmware/all_flash/LLB.vresearch101.RELEASE.im4p"],
patcherFactories: [{ data, verbose in
- IBootPatcher(data: data, mode: .llb, verbose: verbose)
+ let p = IBootPatcher(data: data, mode: .llb, verbose: verbose)
+ p.extraBootArgs = extraBootArgs
+ return p
}]
))