1. Advisory Information
Title: Advantech EKI-1221D Buffer Overflow
Advisory ID: CORE-2015-0004
Advisory URL: http://www.coresecurity.com/advisories/advantech-eki-1221d-buffer-overflow
Date published: 2015-02-09
Date of last update: 2015-02-06
Vendors contacted: Advantech
Release mode: Coordinated release
2. Vulnerability Information
3. Vulnerability Description
The Advantech EKI-1200 series Modbus gateways  are are bi-directional gateways for integrating new and existing Modbus/RTU and Modbus/ASCII serial devices to newer TCP/IP networked-based devices. The EKI-1221D/1222D feature two Ethernet ports with one IP address for easier network wiring. One port can be used to connect to the network, and the other port can be used to connect to another Ethernet device or another EKI-1221D/1222D.
Advantech EKI-1221D is vulnerable to a Buffer Overflow, which can be exploited by remote attackers to execute arbitrary code, by using a hardcoded root user credential and a specific query against a vulnerable CGI file.
4. Vulnerable packages
- Advantech ADAM-4572 and EKI-1221/1222/1224/1221D/1222D V1.61
- Other versions may probably be affected too, but they were not checked.
5. Vendor Information, Solutions and Workarounds
The vendor released a new version of the firmware  that fixes the vulnerabilities. Is recommended that all the vulnerable users update their devices.
This vulnerability was discovered and researched by Enrique Nissim and Pablo Lorenzatto from the Core Security Engineering Team. The publication of this advisory was coordinated by Joaquín Rodríguez Varela from the Core Security Advisories Team.
7. Technical Description / Proof of Concept Code
This vulnerability is caused by an incorrect manipulation of an input parameter of the file "index.cgi". When it receives at least 136 characters in the num variable it generates a segmentation fault, which means that it can be exploited in order to execute arbitrary code. The request must be done using the POST method in order to work.
The CGI file may require authentication, and the webserver's config file defines the localhost root user as the server admin. Taking into account that the root user is hardcoded in the firmware, there is a chance that it could remain unchanged. This user may work for authentication, the username is "root" and the password "ab6TRGT20sY26".
7.1. Proof of Concept
# curl --data '' http://device/cgi-bin/index.cgi?func=setport&num=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&oprate=mode If requested for credentials try using the following: User: root Password: ab6TRGT20sY26
8. Report Timeline
- 2014-10-01: Initial notification sent to ICS-CERT informing of the vulnerability and requesting the vendor's contact information.
- 2014-10-01: ICS-CERT informs that they will ask the vendor if they want to coordinate directly with us or if they prefer to have ICS-CERT mediate. They request the vulnerability report.
- 2014-10-01: ICS-CERT informs that the vendor answered that they would like the ICS-CERT to mediate the coordination of the advisory. They requested again the vulnerability report.
- 2014-10-01: We send the vulnerability detail, including technical description and a PoC.
- 2014-10-09: We request a status update on the reported vulnerability.
- 2014-10-20: ICS-CERT informs that the vendor is currently working on a fix for EKI-1221D.
- 2014-11-13: We inform them that we would like to make a coordinated release of the fix and we requested to be informed before the update/fix is published.
- 2014-12-09: We request a status update regarding the development of the fix.
- 2014-12-09: ICS-CERT informs that the vendor has a new firmware for EKI-1221D to fix the problem. They say they'll keep us updated tregarding the release date.
- 2014-12-09: We request to be informed with due notice when the vendor is going to release the new firmware.
- 2014-12-09: ICS-CERT informs that the vendor has sent us an early copy of the new EKI-1221D firmware. They ask if we can test it to ckeck if it is no longer vulnerable.
- 2014-12-16: We inform ICS-CERT that based on our test, the new firmware is no longer vulnerable to the buffer overflow. We request the estimated date for publishing the new firmware.
- 2015-01-06: We request a status update regarding the publication date for the new firmware.
- 2015-01-15: ICS-CERT informs that the vendor has told them that they expect the official release of the fix to be on February 6th, 2015.
- 2015-01-16: We recommended the vendor to publish the new firmware on Monday 9th of February instead of Friday 6th, to avoid two non-working days to pass by without giving their clients a chance to update their devices.
- 2015-02-03: We ask ICS-CERT if the vendor decided to follow our recommendation to publish the fix the following monday, 9th of February, or they still want to publish it on Friday 6th of February.
- 2015-02-05: We requested an urgent response from ICS-CERT regarding the date of publication of the fix.
- 2015-02-05: ICS-CERT informed us that they belived that the vendor was still planing to release the fix on on February 6th, 2015. They sent us a copy of their own advisory for us to review.
- 2015-02-05: We answered ICS-CERT informing the draft document was accurate and we included the missing information they had marked in it.
- 2015-02-09: Advisory CORE-2015-0004 published.
10. About CoreLabs
CoreLabs, the research center of Core Security, is charged with anticipating the future needs and requirements for information security technologies. We conduct our research in several important areas of computer security including system vulnerabilities, cyber attack planning and simulation, source code auditing, and cryptography. Our results include problem formalization, identification of vulnerabilities, novel solutions and prototypes for new technologies. CoreLabs regularly publishes security advisories, technical papers, project information and shared software tools for public use at: http://corelabs.coresecurity.com.
11. About Core Security
Core Security enables organizations to get ahead of threats with security test and measurement solutions that continuously identify and demonstrate real-world exposures to their most critical assets. Our customers can gain real visibility into their security standing, real validation of their security controls, and real metrics to more effectively secure their organizations.
Core Security's software solutions build on over a decade of trusted research and leading-edge threat expertise from the company's Security Consulting Services, CoreLabs and Engineering groups. Core Security can be reached at +1 (617) 399-6980 or on the Web at: http://www.coresecurity.com.
The contents of this advisory are copyright (c) 2015 Core Security and (c) 2015 CoreLabs, and are licensed under a Creative Commons Attribution Non-Commercial Share-Alike 3.0 (United States) License: http://creativecommons.org/licenses/by-nc-sa/3.0/us/
13. PGP/GPG Keys
This advisory has been signed with the GPG key of Core Security advisories team.