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
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.
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.
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".
# curl --data '' [http://device/cgi-bin/index.cgi?func=setport&num=AAAAAAAAAAAAAAAAAAAAAAA...](<http://device/cgi-bin/index.cgi?func=setport&num=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&oprate=mode>) If requested for credentials try using the following: User: root Password: ab6TRGT20sY26
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>.
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/>
This advisory has been signed with the GPG key of Core Security advisories team, which is available for download at <http://www.coresecurity.com/files/attachments/core_security_advisories.asc>.