Strategic web compromises in the Middle East with a pinch of Candiru


ESET researchers have discovered strategic web compromise (aka watering hole) attacks against high‑profile websites in the Middle East

Back in 2018, ESET researchers developed a custom in-house system to uncover watering hole attacks (aka strategic web compromises) on high-profile websites. On July 11th, 2020 it notified us that the website of the Iranian embassy in Abu Dhabi had been modified and had started injecting JavaScript code from https://piwiks[.]com/reconnect.js, as shown in Figure 1.

Figure 1. Script injection on the website of the Iranian Embassy in Abu Dhabi

Our curiosity was aroused by the nature of the targeted website and in the following weeks we noticed that other websites with connections to the Middle East started to be targeted. We traced the start of the campaign back to March 2020, when the piwiks[.]com domain was re-registered. We believe that the strategic web compromises only started in April 2020 when the website of the Middle East Eye (middleeasteye.net), a London-based digital news site covering the region, started to inject code from the piwiks[.]com domain.

At the end of July or the beginning of August 2020, all remaining compromised websites were cleaned; it is probable that the attackers themselves removed the malicious scripts from the compromised websites. The threat group went quiet until January 2021, when we observed a new wave of compromises. This second wave lasted until August 2021, when all websites were cleaned again. A few indicators from this second wave were shared on Twitter by a fellow researcher, which allows us to make a link with what Kaspersky tracks as Karkadann.

We detail the inner working of the compromises in the Technical analysis section, below, but it is worth noting that the final targets are specific visitors of those websites, who are likely to receive a browser exploit. The compromised websites are only used as a hop to reach the final targets.

We also uncovered interesting links with Candiru, detailed in the section Links between the watering holes, spearphishing documents and Candiru. Candiru is a private Israeli spyware firm that was recently added to the Entity List (entities subject to licensing restrictions) of the US Department of Commerce. This may prevent any US‑based organization from doing business with Candiru without first obtaining a license from the Department of Commerce.

At the time of writing, it seems that the operators are taking a pause, probably in order to retool and make their campaign stealthier. We expect to see them back in the ensuing months.

Targeting

Our tracking shows that the operators are mostly interested in the Middle East, with a particular emphasis on Yemen. Table 1 shows the known targets in 2020 and 2021.

Table 1. Domains compromised during the first wave

Compromised websiteC&CFromToDetail
middleeasteye.netpiwiks[.]com2020‑04‑042020‑04‑06A UK-based online newspaper covering the Middle East.
piaggioaerospace.itpiwiks[.]com2020-07-082020-11-05An Italian aerospace company.
medica-tradefair[.]corebrandly[.]site2020-07-092020-10-13Fake website impersonating a German medical trade fair in Düsseldorf.
mfa.gov.irpiwiks[.]com2020-07-112020-07-13Ministry of Foreign Affairs of Iran.
almanar.com.lbrebrandly[.]site2020-07-242020-07-30Television channel linked to Hezbollah.
smc.gov.yevisitortrack[.]net
hotjar[.]net
2021-01-18
2021-04-21
2021-04-14
2021-07-30
Ministry of Interior of Yemen.
almasirahnews.comvisitortrack[.]net
hotjar[.]net
2021-01-25
2021-04-21
2021-03-25
2021-07-17
Yemeni Television channel linked to the Ansar Allah movement (Houthis).
casi.gov.syhotjar[.]net2021-02-01UnknownCentral Authority for the Supervision and Inspection of Syria.
moe.gov.syhotjar[.]net2021-02-01UnknownSyrian Ministry of Electricity.
almanar.com.lbwebfx[.]bz
webffx[.]bz
webffx[.]bz
2021-02-03
2021-03-12
2021-03-24
2021-02-23
2021-03-24
2021-03-25
Television channel linked to Hezbollah.
manartv.com.lbwebfx[.]bz2021-02-032021-03-22Television channel linked to Hezbollah.
mof.gov.yehotjar[.]net2021-02-112021-07-14Ministry of Finance of Yemen.
scs-net.orghotjar[.]net2021-03-07UnknownInternet Service Provider in Syria.
customs.gov.yelivesesion[.]bid2021-03-242021-06-16Customs agency of Yemen.
denel.co.za
pmp.co.za
deneldynamics.co.za
denellandsystems.co.za
denelaviation.co.za
site-improve[.]net2021-03-31
2021-03-31
2021-04-03
2021-04-04
2021-04-07
2021-07-22
Unknown
2021-07-27
2021-07-23
2021-07-19
A South African state-owned aerospace and military technology conglomerate.
yemen.net.yehotjar[.]net2021-04-152021-08-04Internet service provider in Yemen.
yemenparliament.gov.yehotjar[.]net2021-04-202021-07-05Parliament of Yemen.
yemenvision.gov.yehotjar[.]net2021-04-212021-06-13Yemeni government website.
mmy.yehotjar[.]net2021-05-042021-08-19Yemeni media linked to the Houthis.
thesaudireality.combootstrapcdn[.]net2021-06-162021-07-23Likely dissident media outlet in Saudi Arabia.
saba.yeaddthis[.]events2021-06-18UnknownYemeni news agency linked to Houthis. However, it seems it was taken over by the Southern Transitional Council in early June 2021, just before this website was compromised.

medica-tradefair[.]co is the outlier in this list, as it was not compromised but was operated by the attackers themselves. It was hosted at ServerAstra, as were all the other C&C servers used in 2020.

It mimics the legitimate website medica-tradefair.com, which is the website of the World Forum for Medicine’s MEDICA Trade Fair held in Düsseldorf (Germany) each year. The operators simply cloned the original website and added a small piece of JavaScript code.

As seen in Figure 2, the content doesn’t seem to have been modified. It is likely that attackers were not able to compromise the legitimate website and had to set up a fake one in order to inject their malicious code.

Figure 2. Cloned version of the Medica Trade Fair website

It is interesting to note that the malicious domains mimic genuine web analytics, URL shortener or content delivery network domains and URLs. This is a characteristic of this threat actor.

Technical analysis – Strategic web compromises

First wave – 2020

First stage – Injected script

All compromised websites were injecting JavaScript code from the attacker-controlled domains piwiks[.]com and rebrandly[.]site. In the first known case, the injection is as shown in Figure 3.

Figure 3. Script injection on the website of the Iranian Embassy in Abu Dhabi

Figure 3. Script injection on the website of the Iranian Embassy in Abu Dhabi

This injection loads a remote JavaScript named reconnects.js and a legitimate third-party library, GeoJS, for IP geolocation lookup.

In the cases of rebrandly[.]site injections, the additional scripts are loaded using HTML script tags, as seen in Figure 4.

Figure 4. Script injected into the medica-tradefair[.]co website

Second stage – Fingerprinting script

reconnects.js and recon-api.js are almost identical; only the order of some lines or functions are changed. As shown in Figure 5, the malware authors tried to avoid raising suspicions by prepending their script with a copy of the jQuery Browser Plugin header. They were probably hoping that malware analysts would not scroll further.

Figure 5. Beginning of the fingerprinting script used in the first wave

The script first implements a function named geoip. It is automatically called by the GeoJS library, previously loaded, as mentioned on the official GeoJS website. The variable json contains the IP geolocation information. The script sends this JSON via an HTTP POST request to the C&C server at the URL https://rebrandly[.]site/reconnect-api.php. If the server returns an HTTP 200 status code, then the script proceeds to a function named main.

First, main gathers information such as the operating system version and the browser version using custom functions shown in Figure 6. They simply parse the browser User-Agent to extract information.

Figure 6. OS and browser fingerprinting functions

As shown in Figure 7, the function then checks whether the operating system is either Windows or macOS and only continues if so. This is interesting because it suggests that this operation is intended to compromise computers and not mobile devices such as smartphones. It also checks for a list of common web browsers: Chrome, Firefox, Opera, IE, Safari and Edge.

Figure 7. The main function of the fingerprinting script used in the first wave

The script also encrypts a hardcoded value, 1122, although we don’t know for what purpose. Despite the function being named decrypt, it actually encrypts using RSA and the library JSEncrypt. The 1024-bit RSA key is hardcoded and set to:

—–BEGIN PUBLIC KEY—–
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDhIxVX6QGlxe1mrkPCgBtz8bWH
nzmek4He5caAE2sH2TFnXN1VdqpxMaJSi+dj9sbqHu0tSYd+5tU20514jlEOX6/D
yFFPCoOvx5TzAm+AkSmevUuMsfZTifK+wQRxRhiuMk2UbnVCVQS0CJDoPTl8Blsp
1oCEF2Kz7uIb0pea3QIDAQAB
—–END PUBLIC KEY—–

Then, the script sends an HTTPS GET request to the C&C server rebrandly[.]site. The id parameter contains the fingerprint data and the last parameter value contains the country provided by the GeoJS library.

If the server returns a reply, it is decrypted using AES from the CryptoJS library, and a hardcoded key flcwsfjWCWEcoweijwf@#$@#$@#499299234@#$!@2. This key stayed the same, even after we tried a few requests.

The decrypted value is supposedly a URL and a new iframe pointing to this URL is created. We were unable to get any valid answer but we believe it leads to a browser remote code execution exploit that allows an attacker to take control of a machine.

Second wave – 2021

In January 2021, a new wave of attacks started. The attackers created an entirely new network infrastructure and changed all their JavaScript code.

First stage – Injected script

In order to be a bit stealthier still, in this second wave, they started to modify scripts that were already on the compromised website. So instead of adding code to the main HTML page, they modified libraries such as wp-embed.min.js, as seen in Figure 8. They simply added a few lines at the end of https://www.smc.gov.ye/wp-includes/js/wp-embed.min.js to load a script from a server they control: https://visitortrack[.]net/sliders.js.

Figure 8. Injected script used in the second wave

Another strategy used to limit their exposure is to create a cookie the first time the visitor executes the malicious script, as shown in Figure 9. As the script is conditionally injected depending on whether the cookie already exists, this will prevent further injections. This specific code was found on the website of the Syrian Central Authority for the [sic] Supervision and Inspection (casi.gov.sy).

Figure 9. Cookie creation to avoid further requests

Second stage

From January to March 2021, for the second-stage script, the operators used a script based on the minAjax library. This is not a fingerprinting script per se as it doesn’t send any information about the browser or the operating system to the C&C server – an example is shown in Figure 10. It should be noted that very similar scripts are used by the LNKR adware, so a detection on this might lead to a high volume of false positives.

Figure 10. Second-stage script of the second wave

This script contains the current timestamp, t0, an expiration timestamp, ex, and two hashes juh and cs, whose significance we don’t know at present. These values are sent to the C&C server https://webfex[.]bz/f/gstats. If the reply is a JSON object and contains the fw key, the script issues a redirection to the URL contained in fw using parent.top.window.location.href. As with the first wave, we were not able to get any valid redirect.

In April 2021, this script was changed to FingerprintJS Pro. This is a commercial product whose developers have an official website shown in Figure 11.

Figure 11. Home page of FingerprintJS

In comparison to the fingerprinting script used in 2020, this is far more complex because it retrieves the default language, the list of fonts supported by the browser, the time zone, the list of browser plugins, the local IP addresses using RTCPeerConnection, and so on. Network communications with the C&C server are encrypted with an AES session key. As shown in Figure 12, the server can return JavaScript code that will be executed in the context of the current web page.

Figure 12. FingerprintJS Pro adds JavaScript code to the current page

As with the previous cases, we never got a valid redirect. We still believe it leads to a browser exploit and it shows that this campaign is highly targeted.

Spearphishing documents and links with Candiru

Reminder of the Citizen Lab publication

In the Citizen Lab Candiru blogpost, there is a section called A Saudi-Linked Cluster?. It mentions a spearphishing document that was uploaded to VirusTotal.

The C&C server used by this document is https://cuturl[.]space/lty7uw and VirusTotal captured a redirection from this URL to https://useproof[.]cc/1tUAE7A2Jn8WMmq/api. The domain useproof[.]cc was resolving to 109.70.236[.]107 and, according to the Citizen Lab, this server matched their so-called CF3 fingerprint for Candiru C&C servers. This domain was registered via Porkbun, as are most Candiru-owned domains.

Two domains resolving to the same IP address caught our attention:

  • webfx[.]cc
  • engagebay[.]cc

The same second-level domains, with a different TLD, were used in the second wave of strategic web compromises. These two domains in the .cc TLD are most likely operated by Candiru too.

The Citizen Lab report mentions a few domains similar to cuturl[.]space, which we detail in Table 2.

Table 2. Domains similar to cuturl[.]space

DomainRegistrarIPHosting Provider
llink[.]linkNjalla83.171.237[.]48Droptop
instagrarn[.]coTLD Registrar Solutions83.97.20[.]89M247
cuturl[.]appTLD Registrar Solutions83.97.20[.]89M247
url-tiny[.]coTLD Registrar Solutions83.97.20[.]89M247
bitly[.]telNjalla188.93.233[.]149Dotsi

These domain names mimic URL shorteners and the Instagram social media website and were registered through Njalla and TLD Registrar Solutions Ltd. This reminds us of the domains used for the strategic web compromises that are all variations of genuine web analytics websites and were also registered via Njalla.

We also independently confirmed that the servers to which these domains were resolving were configured in a similar fashion.

Thus, we believe that this set of websites is controlled by the same threat group that created the documents. Conversely, the domain useproof[.]cc is most likely operated in-house by Candiru and is used to deliver exploits.

Links between the watering holes, spearphishing documents and Candiru

Table 3 summarizes the characteristics of the watering holes, the documents found by Citizen Lab, and Candiru.

Table 3. Summary of links between the three clusters (watering holes, documents found by Citizen Lab and Candiru)

 Watering holesCluster of documentsCandiru
RegistrarsMainly NjallaNjalla and TLD Registrar SolutionsPorkbun
Hosting providersServerAstra, Droptop, Neterra, Net Solutions, The Infrastructure Group, Sia Nano and FlokiNETDroptop, M247 and DotsiM247, QuadraNet, etc.
Domain themesAnalytics and URL shortener servicesURL shortener servicesAnalytics, URL shortener services, media outlets, tech companies, government contractors, etc.
VictimologyMiddle EastMiddle EastMiddle East, Armenia, Albania, Russia, Uzbekistan, etc.
Targeted platformsWindows and macOSWindowsWindows and macOS
TTPsStrategic web compromisesMalicious documents with Document_Open macrosMalicious documents and fake shortened URLs redirecting to exploits and the DevilsTongue implant.

What is interesting to note is that the watering holes are limited to a quite narrow victimology. We also noted that domains known to be operated by Candiru (webfx[.]cc for example) are very similar to domains used for the watering holes (webfx[.]bz). However, they were not registered in the same fashion and their servers are configured very differently.

In July 2021, Google published a blogpost providing details on exploits used by Candiru. It includes CVE‑2021-21166 and CVE-2021-30551 for Chrome and CVE-2021-33742 for Internet Explorer. They are full remote code execution exploits that allow an attacker to take control of a machine by making the victim visit a specific URL that then delivers the exploit. This shows Candiru has the capabilities to exploit browsers in a watering hole attack.

Hence, we believe that the watering holes behave similarly to the documents. The first C&C server, injected in the compromised websites, would redirect to another C&C server, owned by a spyware firm such as Candiru and delivering a browser exploit.

Based on this information, we assess:

  • with low confidence that the creators of the documents and the operators of the watering holes are the same.
  • with medium confidence that the operators of the watering holes are customers of Candiru.

Conclusion

This report describes two strategic web compromise campaigns targeting high-profile organizations in the Middle East, with a strong focus on Yemen. We also revealed links to Candiru, a spyware firm, that sells state‑of‑the‑art offensive software tools and related services to government agencies.

We were unable to get an exploit and the final payload. This shows that the operators choose to narrow the focus of their operations and that they don’t want to burn their zero-day exploits.

We stopped seeing activity from this operation at the end of July 2021, shortly after the release of blogposts by the Citizen Lab, Google and Microsoft detailing the activities of Candiru.

A comprehensive list of Indicators of Compromise (IoCs) and samples can be found in our GitHub repository.

For any inquiries, or to make sample submissions related to the subject, contact us at threatintel@eset.com.

Indicators of Compromise

Legitimate, historically compromised websites

Compromised websiteFromTo (treat as a lower bound)
middleeasteye.net2020-04-042020-04-06
piaggioaerospace.it2020-07-082020-11-05
mfa.gov.ir2020-07-112020-07-13
almanar.com.lb2020-07-242020-07-30
smc.gov.ye2021-01-18
2021-04-21
2021-04-14
2021-07-30
almasirahnews.com2021-01-25
2021-04-21
2021-03-25
2021-07-17
casi.gov.sy2021-02-01Unknown
moe.gov.sy2021-02-01Unknown
almanar.com.lb2021-02-03
2021-03-12
2021-02-23
2021-03-25
manartv.com.lb2021-02-032021-03-22
mof.gov.ye2021-02-112021-07-14
scs-net.org2021-03-07Unknown
customs.gov.ye2021-03-242021-06-16
denel.co.za2021-03-312021-07-22
pmp.co.za2021-03-31Unknown
deneldynamics.co.za2021-04-032021-07-27
denellandsystems.co.za2021-04-042021-07-23
denelaviation.co.za2021-04-072021-07-19
yemen.net.ye2021-04-152021-08-04
yemenparliament.gov.ye2021-04-202021-07-05
yemenvision.gov.ye2021-04-212021-06-13
mmy.ye2021-05-042021-08-19
thesaudireality.com2021-06-162021-07-23
saba.ye2021-06-18Unknown

C&C servers

DomainIPFirst seenLast seenDetails
piwiks[.]com91.219.236[.]382020-03-312020-07-29Watering hole C&C server.
rebrandly[.]site91.219.239[.]191
91.219.236[.]38
2020-03-20
2020-07-13
2020-07-10
2020-09-29
Watering hole C&C server.
medica-tradefair[.]co91.219.236.502021-06-282021-10-20Fake website impersonating a German medical conference.
bitly[.]bz91.219.239[.]1912020-03-192020-03-19Unknown.
tinyurl[.]ist91.219.239[.]1912020-03-192020-04-16Unknown.
tinyurl[.]bz91.219.239[.]1912020-03-202020-04-16Unknown.
bit-ly[.]site91.219.239[.]1912020-03-252020-04-16Unknown.
bitly[.]tw91.219.239[.]1912020-03-262020-04-16Unknown.
bitly[.]zone91.219.239[.]1912020-03-262020-04-16Unknown.
shortlinkcut[.]link91.219.239[.]1912020-03-262020-04-16Unknown.
tinyurl[.]one91.219.239[.]1912020-03-262020-04-16Unknown.
tinyurl[.]photos91.219.239[.]1912020-03-262020-04-16Unknown.
tinyurl[.]plus91.219.239[.]1912020-03-262020-04-16Unknown.
site-improve[.]net185.165.171[.]1052021-01-062021-07-21Watering hole C&C server.
clickcease[.]app83.171.236[.]1472021-01-062021-07-28Unknown.
visitortrack[.]net87.121.52[.]2522021-01-062021-10-06Watering hole C&C server.
webfx[.]bz94.140.114[.]2472021-01-062021-03-24Watering hole C&C server.
livesession[.]bid5.206.224[.]1972021-01-062021-07-25Unknown.
engagebay[.]app185.82.126[.]1042021-01-072021-05-19Unknown.
hotjar[.]net5.206.224[.]2262021-01-072021-08-02Watering hole C&C server.
webffx[.]bz83.171.236[.]32021-02-212021-03-27Watering hole C&C server.
engagebaay[.]app5.206.227[.]932021-03-072021-07-27Unknown.
livesesion[.]bid87.120.37[.]2372021-03-172021-07-28Watering hole C&C server.
sitei-mprove[.]net87.121.52[.]92021-03-172021-07-27Unknown.
webfex[.]bz45.77.192[.]332021-02-26N/AWatering hole C&C server.
bootstrapcdn[.]net188.93.233[.]1622021-04-282021-07-28Watering hole C&C server.
addthis[.]events83.171.236[.]2472021-04-292021-07-28Watering hole C&C server.
sherathis[.]com5.206.224[.]542021-06-272021-08-01Unknown.
yektenet[.]com5.2.75[.]2172021-06-272021-07-27Unknown.
static-doubleclick[.]net87.121.52[.]1282021-06-272021-07-27Unknown.
code-afsanalytics[.]com83.171.236[.]2252021-06-272021-07-28Unknown.
fonts-gstatic[.]net83.171.239[.]1722021-06-272021-07-24Unknown.
moatads[.]co87.121.52[.]1442021-06-272021-07-23Unknown.
doubleclick[.]ac5.2.67[.]822021-06-272021-07-18Unknown.
llink[.]link83.171.237[.]482021-01-252021-05-01Unknown.
instagrarn[.]co83.97.20[.]892020-11-022021-01-23Unknown.
cuturl[.]app83.97.20[.]892020-11-022021-01-20Malicious document C&C server.
url-tiny[.]co83.97.20[.]892020-11-022020-11-25Unknown.
bitly[.]tel188.93.233[.]1492021-01-252021-03-11Unknown.
cuturl[.]space83.171.236[.]1662021-01-252021-04-23Malicious document C&C server.
useproof[.]cc109.70.236[.]1072020-11-252021-02-19Candiru exploit delivery server.

Files

SHA-1FilenameC&C URLComment
4F824294BBECA4F4ABEEDE8648695EE1D815AD53N/Ahttps://cuturl[.]app/sot2qqDocument with VBA macro.
96AC97AB3DFE0458B2B8E58136F1AAADA9CCE30Bcopy_02162021q.dochttps://cuturl[.]space/lty7uwDocument with malicious VBA macro.
DA0A10084E6FE57405CA6E326B42CFD7D0255C79seeIP.dochttps://cuturl[.]space/1hm39tDocument with VBA macro.

MITRE ATT&CK techniques

This table was built using version 10 of the MITRE ATT&CK framework.

TacticIDNameDescription
Resource DevelopmentT1583.001Acquire Infrastructure: DomainsThe operators bought domain names from multiple registrars, including Njalla.
T1583.004Acquire Infrastructure: ServerThe operators rented servers from multiple hosting companies. In 2020, they rented servers mainly from ServerAstra.
T1584.004Compromise Infrastructure: ServerThe operators compromised several high-profile websites.
T1588.001Obtain Capabilities: MalwareThe operators probably bought access to Candiru implants.
T1588.005Obtain Capabilities: ExploitsThe operators probably bought access to Candiru exploits.
T1608.004Stage Capabilities: Drive-by TargetThe operators modify more than twenty high-profile websites to add a piece of JavaScript code that loads additional code from their C&C servers.
Initial AccessT1189Drive-by CompromiseVisitors to compromised websites may have received an exploit after their browser was fingerprinted.
T1566.001Phishing: Spearphishing AttachmentThe operators sent spearphishing emails with malicious Word documents.
ExecutionT1059.005Command and Scripting Interpreter: Visual BasicThe Word documents contain a VBA macro running code using the Document_Open function.
Command and ControlT1071.001Application Layer Protocol: Web ProtocolsThe watering hole scripts communicate via HTTPS with the C&C servers.





Source link

Pin It on Pinterest