cyber security

STOCKSTAY Malware Uses WebSocket C2, RSA Encryption, and Environmental Keying for Stealth

Analysis of a .NET backdoor tracked as STOCKSTAY exposes a mature, modular espionage implant actively developed and deployed by the Russia-linked Turla cluster since at least December 2022.

STOCKSTAY demonstrates several operational techniques designed to maximize stealth and survivability: secure WebSocket-based C2, asymmetric encryption using a 4096-bit RSA keypair, inter-component IPC, and environment-based keying of configuration material.

These design choices, along with code and architectural overlaps with Turla’s KAZUAR toolkit, indicate STOCKSTAY is a deliberate addition to a long-standing nation-state toolkit optimized for targeted reconnaissance and data exfiltration.

At runtime STOCKSTAY separates functionality across distinct .NET components: STOCKBROKER (network tunneler), STOCKMARKET (orchestrator/config manager), and STOCKTRADER (backdoor/task executor).

STOCKBROKER establishes proxied wss:// WebSocket sessions using a bespoke build of the open-source websocket-sharp library, isolating network traffic from host activity and enabling operators to blend payload messaging into otherwise legitimate WebSocket flows.

STOCKMARKET loads an encrypted on-disk configuration that is frequently disguised as stock market or crypto-service metadata; that configuration contains C2 endpoints, an internal server identifier, and flags controlling operational windows and environmental keying.

Google Cloud said in a report shared with GBhackers, STOCKSTAY is a multi-component backdoor written in .NET, using the Windows Forms framework, which communicates with its command and control (C2) via a secure WebSocket connection.

Overview of STOCKSTAY malware architecture (Source : Google Cloud).

On first execution the implant generates a unique 4096-bit RSA keypair and transmits its public key to upstream infrastructure so that outbound task results can be encrypted server-side, ensuring confidentiality even when traffic traverses third-party hosting platforms.

STOCKSTAY Malware Uses WebSocket C2

The C2 server implemented by the actors is lightweight and WebSocket-first. GTIG located a Python Tornado-based controller in a public GitHub repository and observed the threat actor hosting these controllers on third-party platforms such as Render and glitch.me, complicating takedown and attribution.

The server acts as a message store, decoupling operator controllers from edge-facing WebSocket relays by inserting encrypted messages into a local SQLite database.

This multi-hop design mirrors KAZUAR’s infrastructure model and adds operational flexibility: operators can push encrypted tasking to intermediate infrastructure without exposing the origin or decryptable payloads to platform providers.

STOCKSTAY’s use of environmental keying is notable. Configuration decryption can require a hash derived from host attributes (hostname, domain, and in some cases username), preventing the payload from revealing C2 locations or operational details outside the intended environment.

Timeline of STOCKSTAY observations (Source : Google Cloud).

GTIG observed two operational patterns: initial deployments using extractable default passwords to gain footholds where the actor lacks deep knowledge of the target, and stage-later deployments where recon allowed precise environmental keying that restricts execution to a specific host or domain.

Functionally STOCKTRADER supports a full set of espionage primitives: file collection (selective Get and in-memory zipping), remote execution, registry manipulation, screen capture, directory enumeration, and multi-task orchestration.

The implant encrypts outbound payloads using its RSA key and encodes messages in base64 before transmission, minimizing plaintext artifacts.

The actor also leverages decoy lures academic and diplomatic themes, malicious RDP files, and MSI with plausible product names to steer phishing and initial access campaigns, with a heavy operational focus on Ukrainian government and military targets and select European foreign-policy interests.

Code-level ties to KAZUAR are evident: identical multi-component separation of duties, shared string-obfuscation techniques (including the Squirrel3-based K1MORPHER routines), and reuse of .NET development patterns.

GTIG assesses with moderate confidence that common developers or teams are iterating across both projects.

Follow us on Google News, LinkedIn, and X to Get Instant Updates and Set GBH as a Preferred Source in Google.

Mayura Kathir

Mayura Kathir is a cybersecurity reporter at GBHackers News, covering daily incidents including data breaches, malware attacks, cybercrime, vulnerabilities, zero-day exploits, and more.

Recent Posts

Hackers Use ConnectWise SkyKick Credentials to Access Microsoft 365, Halting Cloud Backups

Attackers abused compromised ConnectWise Cloud Backup credentials to access Microsoft 365 customer environments, prompting ConnectWise…

19 hours ago

Anthropic’s Claude AI Uncovers Origins of NSA-Provided Cryptographic Keys After 25 Years

Anthropic says an internal Claude research model reconstructed how the National Security Agency generated seeds…

23 hours ago

Critical WordPress Flaws Allow Attackers to Execute Remote Code Without Authentication

Two WordPress Core vulnerabilities can be chained to execute remote code without authentication, according to…

23 hours ago

OpenBSD Kernel Flaw Dating Back 37 Years Enables Local Privilege Escalation to Root

A newly disclosed OpenBSD kernel exploitation chain combines a shared memory accounting flaw with a…

23 hours ago

GhostAction Hackers Hide Credential-Stealing Malware in Fake Font Files Across 94 GitHub Repositories

GhostAction attackers have expanded their GitHub credential theft campaign with a second stage that disguises…

23 hours ago

SideCopy Hackers Target Indian Organizations With ReverseRAT Malware to Steal Data

Indian authorities have warned that SideCopy hackers are targeting Indian organizations, including academic institutions, with…

24 hours ago