Google’s Mandiant subsidiary has unveiled GoStringUngarbler – an open-source deobfuscation framework designed to neutralize advanced string encryption techniques in Go-based malware.
This innovation specifically targets binaries obfuscated using garble, an increasingly prevalent obfuscation compiler that has complicated malware analysis through sophisticated literal transformations and control flow manipulation.
The garble compiler implements Abstract Syntax Tree (AST) manipulation through Go’s go/ast library to transform source code during compilation while preserving program semantics.
Its -literals flag activates four principal string transformation methodologies:
This category employs three encryption variants:
Simple transformation: Using a randomly produced mathematical operator and a randomly generated key of identical length to the input string, this transformation applies byte-by-byte encoding.
Swap transformation: Byte-pair swapping and position-dependent encoding are combined in this transformation, which shuffles and encrypts byte pairs using locally generated keys.
Shuffle transformation: Multi-layer permutation involving index scrambling via obfRand.Perm and XOR-based position mapping.
Implements chained encryption where each byte’s decryption depends on previous operations through a continuously modified seed value.
The runtime implementation creates nested function call chains visible in decompilation outputs.
Fragments strings into randomly sized chunks processed through a state machine built from switch statements.
Decryption involves reassembling chunks while applying position-dependent XOR keys derived from global encryption parameters.
Mendiant’s solution combines static pattern recognition with dynamic emulation to bypass garble’s defenses:
The tool leverages instruction patterns around Go’s runtime_slicebytetostring function to detect decryption routines.
For x64 binaries, consistent register usage (RBX=string pointer, RCX=length) enables signature-based detection via regular expressions:
Identified subroutines are executed in Unicorn Engine’s isolated environment to extract plaintext strings.
The framework handles garble’s stack manipulation and control flow redirections by emulating from subroutine prologues to runtime_slicebytetostring calls.
Decrypted strings are reinjected into the binary using optimized assembly stubs that replace the original decryption logic.
This in-place patching strategy leverages garble’s stack allocations to store plaintext strings without section modifications.
Early testing indicates GoStringUngarbler successfully processes binaries from Go v1.21–1.23 across PE/ELF formats.
The tool’s YARA rules (available on Mandiant’s GitHub) enable rapid identification of garble-protected samples.
For reverse engineers, the automated deobfuscation:
While currently optimized for stack/shuffle transformations, Mandiant plans to expand support through:
Security teams can deploy GoStringUngarbler alongside existing EDR solutions to improve detection rates for garble-obfuscated malware.
GoStringUngarbler is now available under the Apache 2.0 license on GitHub.
The tool’s release marks a critical advancement in countering the growing abuse of Go’s compilation ecosystem for offensive operations.
Collect Threat Intelligence on the Latest Malware and Phishing Attacks with ANY.RUN TI Lookup -> Try for free
Your SaaS estate M365, Salesforce, Workday, Slack, hundreds of others is a sprawl of misconfigurations,…
DSPM finds sensitive data you didn’t know you had, classifies it, maps who can reach…
Open-source packages are meant to save developers time. In the GemStuffer campaign, that trust became…
Google has released an important Chrome 153 security update that fixes 42 vulnerabilities across the…
The Cybersecurity and Infrastructure Security Agency (CISA) and the National Institute of Standards and Technology…
CISA and five international cybersecurity agencies have released detailed guidance describing 17 common techniques hackers…