In 2022, Margin Research presented a jailbreak for RouterOS v6 at REcon that worked on all versions from 6.34 to 6.49.6. The bug was in the www process: an IPC handler called FoisHandler took a pointer from the body of an M2 message and invoked it as a function. The protection was a policy bitmask (0x80000000) unreachable from the GUI, but bypassable by sending a raw M2 message with policy 0xFFFFFFFF. Combined with a ROP chain, it allowed arbitrary code execution. RouterOS v7 is immune: FoisHandler was removed in the architecture redesign. We verified this with strings on the www binary of v7.24.5: the string "Fois" does not appear. ---
In Episode 2, we saw that RouterOS processes communicate via M2 through handlers registered with the Looper. It is an elegant system: each process exposes handlers, and the loader dispatches messages to the correct handler. But what happens if one of those handlers does something dangerous?
In 2022, researchers from Margin Research took the stage at the REcon conference and showed something unseen for three years: a remote jailbreak of RouterOS. Not an exploit for a specific version. Not a theoretical attack. An automatic tool — FOISted — that worked on any RouterOS v6 from 6.34 (2016) to 6.49.6 (2022).
Reserved for members
This content is reserved for those in the dojo.
Entry is free: you subscribe to the newsletter with your email and then choose to join the dojo, without a password. How it works