support.mikro.strouter help over vpn
since 2014 Contact us now

Router vulnerability note - MikroTik

MikroTik REST API: a buffer overflow behind /rest/ip/address/print

What happened

The REST endpoint of RouterOS is the friendly face of the box: /rest/ip/address/print answers with JSON, and a monitoring system that asks a question in the wrong shape could make parse_json_element in libjson.so write past a buffer. The attacker needs to reach the REST service, which is the same service a script somewhere is probably reaching from the internet right now.

The disclosure trail here is worth quoting, because it is the everyday version of vendor response: the reporter got exploit code published, MikroTik answered that the bug tracker says it is fixed and that an update would come. 7.20.1 and 7.21beta2 carry it. Nothing sinister, just the reason we tell customers not to run the REST service on a public interface while they wait for a version they like.

Who is affected

RouterOS 7.x with the REST API enabled, before 7.20.1.

Check it yourself

Is REST on, and where does it listen?

[admin@router] > /ip http-service print
         rest-api: yes
[admin@router] > /ip service print where name~"www"
 7  www      80    0.0.0.0/0
 8  www-ssl  443   ::
[admin@router] > curl -s http://127.0.0.1/rest/ip/address/print | head

Do this

  • Upgrade to 7.20.1 or newer.
  • Turn REST off if nothing uses it: /ip http-service set rest-api=no.
  • If a collector uses it, bind it to the collector's address.
  • Prefer the API or SSH for automation from outside the box; the HTTP services are the ones that get scanned.

How we handle it

Our monitoring pull uses the API rather than the web interface where the device allows it, which is a small reason the CVE list for monitoring customers is a shorter read.

Sources

Not your thing? We can run these checks for you over an OpenVPN tunnel: €45 fix visit, or just mail us.