Repository navigation
Description
There are broadly two classes of obfuscation in garble:
- Destructive, where the obfuscated binary has strictly less information than a regular binary. For example, we remove debug and build information, and hash names and positions. None of those can be reverted unless one has the original source code, which is basically what
garble reversedoes. - Transformative, where the obfuscated binary still has the information, but we try to hide it. For example, obfuscated literals still need to be present in the binary for the program to work. Similarly, control flow obfuscation must ultimately keep the original code logic to preserve program behavior. These can all be reverted with enough effort.
This is why -literals and control flow obfuscation are not on by default; they are, by design, imperfect solutions with trade-offs. On one hand, they sometimes work; they can fool basic or cheap analysis, especially the kind that isn't specific to Go or garble. On the other hand, they can result in slower and larger programs, and the end user can reverse the process if they try hard enough.
Unsurprisingly, plenty of projects have already figured out how to automatically reverse -literals:
- https://github.com/mandiant/gostringungarbler
- https://github.com/Invoke-RE/ungarble_bn
- https://cloud.google.com/blog/topics/threat-intelligence/gostringungarbler-deobfuscating-strings-in-garbled-binaries
- https://invokere.com/posts/2025/03/ungarble-deobfuscating-golang-with-binary-ninja/
As explained above, this doesn't "break" garble; the literals were always present, they were just not in their plain form. Put another way, it was always possible to deobfuscate literals by simply running the Go program and looking at the string that results from running the obfuscated literal code.
At this point, -literals is in a weird position. Given that it's easy enough to tell that an obfuscated binary used garble (e.g. due to #193), all one has to do is use one of those tools and the process is reversed.
I personally do not have the time nor interest in playing the cat-and-mouse game between obfuscators and deobfuscators when it comes to transformative features like -literals. It's a little like game developers using increasingly complex anti-piracy tools, only for them to end up being cracked a week after release time and time again.
I see a few options going forward:
- Continue as we are; accept that
-literalsonly aims to avoid basic and cheap analysis, and not specialised tools. - Remove
-literals, to not give the illusion that literals are somehow protected from deobfuscation. - Rewrite
-literalswith a plug-in system so that garble users can provide their own literal obfuscation, effectively letting others play the cat-and-mouse game without us needing to write or maintain the code.
Personally, I don't use -literals so I don't have a strong opinion on any of these.
Activity
chatonick commentedon Dec 23, 2025
It seems to me that the plugin golang subsystem for garble is a good idea to implement.
pagran commentedon Dec 28, 2025
Just throwing out some ideas that come to mind:
But all options require unpleasant compromises or organisational problems.
mvdan commentedon Dec 28, 2025
@pagran that's why I was thinking of plugins of some sort. Closed source, custom made, AI generated - any of these can delay the reverse engineering. But they won't be developed directly in this repo, hence plugins.
The tricky bit would be designing the interface.
pagran commentedon Dec 29, 2025
I think this will cause the project to become very fragmented (somewhere in Discord messages with
UBERCRYPT_UNDETECTED_29.12.25.goattached), however, I can't quite figure out if this is good or bad :)But the API interface is a tricky question. Obviously, there is no point in copying the current
obfuscator{}. I think it's best to give people an SDK with basic functions (ah.*), collect all literals into a structure, and pass them to one functionobfuscate(allLiterals []Literal, currPkg PackageAstAndTypeInfo)I guess this could significantly reduce obfuscation performance, but I don't think it's critical.P.S. One more question: how will plugins be loaded? (windows?)
chatonick commentedon Dec 30, 2025
Daniel is right that he wants to absolve himself of responsibility for supporting these defenses. It's our client's problem to create and maintain such obfuscators. It will be possible to keep a list of such plugins separately in the discussions.
But the issue is not about performance at all. It's about source code security. The main goal is to ensure it and how it is done is no longer important, even if the build time of the project increases by an order of magnitude.
https://pkg.go.dev/plugin
Why should this be a universal solution? After all this is necessary only for those who really want to protect the source code.
MarvinJWendt commentedon Mar 19, 2026
Just adding my 2 cents here, Traefik has a nice cross-platform plugin system. They made this runtime go interpreter for it: https://github.com/traefik/yaegi
It's battle tested in Traefik itself. Maybe worth a look.
1514599514 commentedon May 22, 2026
I am looking forward to the plugin system very much
I have a recent request to obfuscate the
. pb.gofile for protobufConfuse the field names and
rawDescto avoid exposing too much metadataFor these specific scenarios, users can make many assumptions that
Garblecannot guarantee, thereby achieving more aggressive confusionscripts: stop testing third party projects with -literals