Custom “Pygmy Goat” malware used in Sophos Firewall hack on govt network

Teilen:

UK’s National Cyber Security Centre (NCSC) has published an analysis of a Linux malware named “Pigmy Goat” created to backdoor Sophos XG firewall devices as part of recently disclosed attacks by Chinese threat actors.

Last week, Sophos published a series of reports dubbed “Pacific Rim” that detailed five-year attacks by Chinese threat actors on edge networking devices.

One of the custom malware used in these attacks is a rootkit that closely impersonated Sophos product file naming conventions.

The malware, which is designed for compromising network devices, features advanced persistence, evasion, and remote access mechanisms and has a rather complex code structure and execution paths.

Although the NCSC report does not attribute the observed activity to known threat actors, it underlines similar techniques, tactics, and procedures (TTPs) to the “Castletap” malware, which Mandiant has associated with a Chinese nation-state actor.

Sophos has also disclosed the same malware in its Pacific Rim report, stating the rootkit was used in 2022 attacks linked to a Chinese threat actor known as “Tstark.”

“X-Ops identified two copies of libsophos.so, both deployed using CVE-2022-1040 — one on a high-level government device and the other on a technology partner to the same government department,” shared Sophos.

A goat in the firewall

The ‘Pygmy Goat’ malware is an x86-32 ELF shared object (‘libsophos.so’) providing threat actors with backdoor access to Linux-based networking devices such as the Sophos XG firewalls.

It uses the LD_PRELOAD environment variable to load its payload into the SSH daemon (sshd), allowing it to hook into the daemon’s functions and override the accept function, which processes incoming connections.

Pygmy Goat monitors SSH traffic for a specific sequence of “magic bytes” in the first 23 bytes of each package.

The "magic bytes" sequence
The “magic bytes” sequence
Source: NCSC

Once that sequence is found, the connection is identified as a backdoor session, and the malware redirects it to an internal Unix socket (/tmp/.sshd.ipc) to establish communication with its Command and Control (C2).

The malware also listens on a raw ICMP socket, waiting for packets with an AES-encrypted payload that holds IP and port information for C2 communication, which triggers a connect-back attempt over TLS.

ICMP-based exchange overview
ICMP-based exchange overview
Source: NCSC

Pygmy Goat communicates with the C2 over TLS, using an embedded certificate mimicking Fortinet’s “FortiGate” CA, a potential cover for blending into network environments where Fortinet devices are common.

When an SSH connection is established, a fake handshake with pre-set responses is triggered to create a false image of legitimacy on network monitors.

The C2 server can send Pygmy Goat commands for execution on the device, including the following:

  • Open either a /bin/sh or /bin/csh shell.
  • Start capturing network traffic via libpcap, forwarding results to C2.
  • Manage cron tasks using BusyBox to schedule activities when the actor isn’t actively connected.
  • Use the EarthWorm open-source toolkit to establish a SOCKS5 reverse proxy, allowing C2 traffic to traverse the network unseen.

Detection and defense

The NCSC report contains file hashes and YARA and Snort rules that detect the magic byte sequences and fake SSH handshake, so defenders can use them to catch Pygmy Goat activity early on.

Additionally, manual checks for /lib/libsophos.so, /tmp/.sshd.ipc, /tmp/.fgmon_cli.ipc, /var/run/sshd.pid, and /var/run/goat.pid, can reveal an infection.

It is also advisable to set up monitoring for encrypted payloads in ICMP packets and use of ‘LD_PRELOAD’ in the environment of the ‘ssdh’ process, which is unusual behavior that may indicate Pygmy Goat activity.

Bill Toulas

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

lade-bild
London, GB
7:10 pm, Juni 28, 2025
Wetter-Symbol 29°C
L: 28° | H: 30°
aufgelockerte Bewölkung
Luftfeuchtigkeit: 54 %
Druck: 1023 mb
Wind: 14 mph WSW
Windböe: 0 mph
UV-Index: 0
Niederschlag: 0 mm
Wolken: 30%
Regen Chance: 0%
Sichtbarkeit: 10 km
Sonnenaufgang: 4:45 am
Sonnenuntergang: 9:21 pm
TäglichStündlich
Tägliche VorhersageStündliche Vorhersage
Today 10:00 pm
Wetter-Symbol
28° | 30°°C 0 mm 0% 8 mph 59 % 1024 mb 0 mm/h
Tomorrow 10:00 pm
Wetter-Symbol
18° | 31°°C 0 mm 0% 7 mph 83 % 1025 mb 0 mm/h
Mo. Juni 30 10:00 pm
Wetter-Symbol
21° | 36°°C 1 mm 100% 8 mph 67 % 1021 mb 0 mm/h
Di. Juli 01 10:00 pm
Wetter-Symbol
21° | 32°°C 0.74 mm 74% 12 mph 73 % 1019 mb 0 mm/h
Mi. Juli 02 10:00 pm
Wetter-Symbol
17° | 25°°C 1 mm 100% 18 mph 85 % 1021 mb 0 mm/h
Today 10:00 pm
Wetter-Symbol
22° | 27°°C 0 mm 0% 8 mph 59 % 1024 mb 0 mm/h
Tomorrow 1:00 am
Wetter-Symbol
20° | 23°°C 0 mm 0% 7 mph 69 % 1024 mb 0 mm/h
Tomorrow 4:00 am
Wetter-Symbol
18° | 18°°C 0 mm 0% 5 mph 83 % 1025 mb 0 mm/h
Tomorrow 7:00 am
Wetter-Symbol
19° | 19°°C 0 mm 0% 5 mph 75 % 1025 mb 0 mm/h
Tomorrow 10:00 am
Wetter-Symbol
24° | 24°°C 0 mm 0% 5 mph 53 % 1025 mb 0 mm/h
Tomorrow 1:00 pm
Wetter-Symbol
29° | 29°°C 0 mm 0% 6 mph 40 % 1024 mb 0 mm/h
Tomorrow 4:00 pm
Wetter-Symbol
31° | 31°°C 0 mm 0% 5 mph 33 % 1023 mb 0 mm/h
Tomorrow 7:00 pm
Wetter-Symbol
30° | 30°°C 0 mm 0% 4 mph 33 % 1021 mb 0 mm/h
Name Preis24H (%)
Bitcoin(BTC)
€91,724.12
0.57%
Ethereum(ETH)
€2,086.27
1.67%
Fesseln(USDT)
€0.85
0.00%
XRP(XRP)
€1.88
5.21%
Solana(SOL)
€129.84
7.52%
USDC(USDC)
€0.85
-0.01%
Dogecoin(DOGE)
€0.140498
3.20%
Shiba Inu(SHIB)
€0.000009
2.85%
Pepe(PEPE)
€0.000009
4.56%
Nach oben scrollen