Skip to content

decide what to do with -literals going forward #984

Closed as not planned
Closed as not planned

Description

@mvdan

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 reverse does.
  • 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:

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:

  1. Continue as we are; accept that -literals only aims to avoid basic and cheap analysis, and not specialised tools.
  2. Remove -literals, to not give the illusion that literals are somehow protected from deobfuscation.
  3. Rewrite -literals with 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

  1. chatonick commented on Dec 23, 2025

    @chatonick

    3. Rewrite -literals with 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.

    It seems to me that the plugin golang subsystem for garble is a good idea to implement.

  2. pagran commented on Dec 28, 2025

    @pagran
    Member

    Just throwing out some ideas that come to mind:

    1. Make project a little less open source. For example, move the obfuscation logic literals to wasm binary blobs and hope that they will live a little longer.
    2. Add a paywall and provide unique obfuscation algorithms (generated via llm's but verified, I've been working on something similar for six months now :) ), with a generation cost of ~$5.

    But all options require unpleasant compromises or organisational problems.

  3. mvdan commented on Dec 28, 2025

    @mvdan
    MemberAuthor

    @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.

  4. pagran commented on Dec 29, 2025

    @pagran
    Member

    I think this will cause the project to become very fragmented (somewhere in Discord messages with UBERCRYPT_UNDETECTED_29.12.25.go attached), 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 function obfuscate(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?)

  5. chatonick commented on Dec 30, 2025

    @chatonick

    I think this will cause the project to become very fragmented

    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.

    I guess this could significantly reduce obfuscation performance, but I don't think it's critical

    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.

    how will plugins be loaded?

    https://pkg.go.dev/plugin

    windows?

    Why should this be a universal solution? After all this is necessary only for those who really want to protect the source code.

  6. MarvinJWendt commented on Mar 19, 2026

    @MarvinJWendt

    https://pkg.go.dev/plugin

    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.

  7. 1514599514 commented on May 22, 2026

    @1514599514

    I am looking forward to the plugin system very much
    I have a recent request to obfuscate the. pb.go file for protobuf
    Confuse the field names and rawDesc to avoid exposing too much metadata

    For these specific scenarios, users can make many assumptions that Garble cannot guarantee, thereby achieving more aggressive confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址