Irrighino and Yun Rev.2

Irrighino has been one of my most appreciated projects: it’s a automatic irrigation system – based on Arduino Yun – with a web-based interface, optimized for smartphones.

After having published the project on this blog, it was reviewed by Open Electronics and a dedicated shield was also produced. The shield is still sold on Futurashop:

irrighino-shield-001

When it was launched the new Arduino Yun (named Rev.2) and the Yun Shield, the Linux distribution running on the board, OpenWrt, was updated as well. In particular, a key component for Irrighino has been replaced with its newer version, the php engine.

If you own a “first generation” Arduino Yun and you’d like to test the new functionalities shipped with Rev.2, in this post I explain how you can update the operating system of your board!

The commands you have to issue on your Yun to install all the required components for Irrighino now are:

install php with cgi and cli

opkg install php7 php7-cgi php7-cli

install curl, json and sqlite modules

opkg install php7-mod-curl php7-mod-json php7-mod-pdo php7-mod-pdo-sqlite

install zoneinfo

opkg install zoneinfo-core zoneinfo-europe

(replace zoneinfo-europe with the one related to your continent)

Final step is to configure the uhttpd webserver to run the php engine.

Edit the /etc/config/uhttpd file adding the following line (pay attention to its position!):

irrighino-php-002

then restart the webserver with:

irrighino-php-003

Now the Yun is ready to run Irrighino!

Arduino Yun, how to update to rev.2

This year in March, Massimo Banzi announced on the Arduino blog the production of a new revision (Rev.2) of the Arduino Yun board.

yun-rev2-001

In addition to some improvements on the hardware design, the new revision offers a complete update of the software side of the Yun, that is the Linux distribution (OpenWrt) running on the board. The original Yun was indeed stuck to a distribution released in 2014 (still available in the download section of Arduino website) and that distribution contained outdated software packages which also presented some security vulnerabilites.

Who now buy a new Yun board, has the new OS version pre-installed. If you own a “Rev.1″ board, in this article you’ll learn how to update it…

Updater

In the Arduino forum, Martino Facchin (one of the contributors of the OpenWrt porting to Yun) published a post with links to an automatic updater for the different platforms (Windows, Linux, Mac). The application updates both the bootloader and the operating system (rootfs). You have to also update the bootloader because of the new OS requires a bigger partition than the original one.

Before running the updater process, there are 3 prerequisites:

  • the Yun board must be connected both to your computer via USB and to your home router/switch using an ethernet cable (the update process cannot happen using wifi)
  • your computer, which runs the updater application, must be connected to the same home network the Yun is connected to
  • your computer must not run softwares (like firewalls) that could block incoming connections

The third point in particular is the one that can give more problems… for example I use the Eset Internet Security suite and I had to temporary disable the protection:

yun-rev2-002

An additional suggestion is to disable other network cards in your computer, keeping active only the one connected to the home network:

yun-rev2-003

If you’re using Windows 10, it may happen that the yun-go-updater.exe program is blocked… in this case you have to cancel the block from the file properties:

yun-rev2-004

If you run the program, the update process should go automatically. When complete, if you connect to the Yun board you should see the new version:

yun-rev2-005

DHCP

During the update process, the Yun board requests a valid IP address for your network using the DHCP protocol. Sometimes this request could fail; in this case you can assign a static IP to the board answering “n” to the first question:

yun-rev2-006

ArduWorm: A Malware for Your Arduino Yun

We’ve been waiting for this one. A worm was written for the Internet-connected Arduino Yun that gets in through a memory corruption exploit in the ATmega32u4 that’s used as the serial bridge. The paper (as PDF) is a bit technical, but if you’re interested, it’s a great read.

The crux of the hack is getting the AVR to run out of RAM, which more than a few of us have done accidentally from time to time. Here, the hackers write more and more data into memory until they end up writing into the heap, where data that’s used to control the program lives. Writing a worm for the AVR isn’t as easy as it was in the 1990’s on PCs, because a lot of the code that you’d like to run is in flash, and thus immutable. However, if you know where enough functions are located in flash, you can just use what’s there. These kind of return-oriented programming (ROP) tricks were enough for the researchers to write a worm.

In the end, the worm is persistent, can spread from Yun to Yun, and can do most everything that you’d love/hate a worm to do. In security, we all know that a chain is only as strong as its weakest link, and here the attack isn’t against the OpenWRT Linux system running on the big chip, but rather against the small AVR chip playing a support role. Because the AVR is completely trusted by the Linux system, once you’ve got that, you’ve won.

Will this amount to anything in practice? Probably not. There are tons of systems out there with much more easily accessed vulnerabilities: hard-coded passwords and poor encryption protocols. Attacking all the Yuns in the world wouldn’t be worth one’s time. It’s a very cool proof of concept, and in our opinion, that’s even better.

Thanks [Dave] for the great tip!


Filed under: Arduino Hacks, security hacks