Skip to content
RCE Write-up Advanced

Symlinks as mount portals: Abusing container mount points on MikroTik's RouterOS to gain code execution

RouterOS container mount points resolved symlinks relative to the host filesystem for both source and destination, allowing an attacker with container access to mount a symlink over a host executable that points to a malicious binary on a non-noexec filesystem. This enabled arbitrary code execution on the host device.

nns Follow

Published on nns.ee

RouterOS release 7.4beta4 introduced containers for MikroTik devices. From the changelog:

nns, on nns.ee

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the mount implementation resolved symlinks in both src and dst parameters relative to the host root rather than confining them to the container root, and did not prevent mounting over host executables via symlinks on non-noexec filesystems.

Impact

An attacker with the ability to configure containers could execute arbitrary code on the host device, though the mount is created with noexec so direct execution of mounted binaries is blocked and a symlink to a non-noexec location is required.

What the attacker needed

Container feature enabled; ability to add container mounts; ability to place files in container

The fix

The issue was fixed in RouterOS versions 7.4beta5, 7.4, 7.5beta1, and higher.

How it was found

  1. Create a symlink inside the container pointing to the host root.
  2. Add a mount point using that symlink as the source to expose the host filesystem inside the container.
  3. Place a malicious binary inside the container and create a symlink to it.
  4. Add a mount point using the symlink as the source and a host executable as the destination.
  5. Start the container so the host executable becomes a symlink to the malicious binary.
  6. Trigger the host executable to run and obtain a reverse shell.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Containers are meant to be isolated from the main device, like a box inside a box. A symlink is a shortcut file that points to another file. The router followed these shortcuts using the main device's file paths instead of the container's, so a shortcut created inside the container could point to files on the main device. By placing a shortcut over a program the device runs, the attacker made the device run their own program.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by nns

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.