r/java • • 7h ago

AIs read bytecode very well and can infer source code from it: how do you continue to protect code?

0 Upvotes

31 comments sorted by

40

u/awidesky 7h ago

Obfuscation never protects your code.
Copyright law does.

3

u/ZorakOfThatMagnitude 7h ago

Hard agree, though it hasn't stopped the entertainment industry from trying.

-1

u/awidesky 6h ago

Sadly, death penalty hasn't stopped murderers from trying too.
So it's the law enforcement system that actually stops that behavior, maybe.

But since law enforcement system is powered by governments, I'm quite worried that they might cut off some slack for their companies to give them advantages.

Like, it's been a while we heard the news about kimi stealing claude, but did we hear chinese government doing anything?

1

u/zackel_flac 6h ago

Crazy how people are discovering that today. For something to run on your local computer, it needs to read something locally, no way around that.

1

u/awidesky 6h ago

About 12 years ago, I posted a question in Stack Overflow asking(actually, complaining) about why there's no easy way to completely obfuscate my 20 line .bat script.

Those people hated me so bad.

1

u/best_of_badgers 6h ago

Also (gag) software patents

1

u/zazzedcoffee 6h ago

This is just a fun aside: for some types of software, it can be obfuscated in a cryptographically secure way. That is, it is more efficient to enumerate inputs and outputs (which is still inefficient) than it is to try to reverse engineer it.

I have no idea how it works, but a CS PhD student I knew worked on it.

1

u/awidesky 6h ago

Mostly "Obfuscation" limited in making symbols hard to read for humans(which makes it vulnerable for AI-driven cracking), or encrypt the script with a key and hide the key inside the app as hard as possible(which is not secure at all actually), but there must be lots of other stuff people are working on.

I heard Homomorphic Encryption is powerful in securing LLM privacy, letting server process the input without decrypting it.
I have no idea if that technology can be used in obfuscation, but it seems fun XD

19

u/revilo-1988 7h ago

Since when do you need to protect Java code? Decompilers and such have always existed. Java is the wrong language for that.

0

u/Proper-Ape 7h ago

Yeah, especially since you don't ship your Java backend as a binary to your customers. You host it.

6

u/revilo-1988 7h ago

It depends on where it's running and what kind of software is being delivered.

-1

u/Proper-Ape 7h ago

Yeah of course, but Desktop Java, while possible, is really not that common anymore.

2

u/revilo-1988 7h ago

It's not necessarily about fat clients; often you overload the code for the customer, and they take care of whether they want to run it in a private network.

42

u/janora 7h ago

https://java-decompiler.github.io/ can read bytecode even better and lets you even export the sources. There was never a protection from anyone reading the code. You could obfuscate it but in the end the logic does not change.

8

u/AnotherLexMan 7h ago

You've been able to do this with intellij for years at this point anyway.

4

u/_1dontknow 7h ago

That was never the point of JVM bytecode.

3

u/sweetno 7h ago

You put it on a server. It was the only way all along.

1

u/VirtualNorth1279 6h ago

There's a new tool that can fuck up with LLMs that try to reverse engineer code: https://github.com/qybaihe/bla

Though it looks like it does not support Java yet.

Other possibilities:

  • There are free pro-grade obfuscation tools (not LLM resistant necessarily)
  • Add an annotation to your classes that warns LLMs that your code is copyrighted and you don't permit LLMs to reverse engineer it (not all LLMs may respect that and it can be worked around by first writing a script to change the wording)

1

u/chambolle 5h ago

thanks a lot!

4

u/BoltaHuaTota 7h ago

the truth is, you can’t. companies like rockstar are getting their most expensive game ever reverse engineered, there’s not much we can do if someone with enough claude credits to burn decides it’s our time

2

u/AnyPhotograph7804 7h ago

You can't if you distribute the binaries. This is not even possible with programming languages, which compile to machine code. If you want to protect your ideas, put the app on a server.

2

u/OhGodNotHimAgain 7h ago

AIs can also slop-copy any product, making a good product that doesn't make consumers think "I should just make my own copy"

2

u/FlatWorldliness1061 7h ago

In my opinion you are cooked. If it is possible to completely decompile native binaries (see NFSU2, Fallout 3, ...), then there is no chance in hell to protect your JAR files if they are given to external users (e.g. lib in classpath).

1

u/cecil721 5h ago

Has anyone tried adding like an empty if block that basically tells the agent to delete Windows to compile or something? Lol.

0

u/ducki666 7h ago

No giving your (byte)code to public?

0

u/uldall 7h ago

Host the code on a server and only expose an API or UI

-5

u/chambolle 7h ago

To be more precise, even with code obfuscation, the AI recovers very readable source code. What bothers me is not being able to protect code ideas (i.e., algorithms) anymore.

6

u/janora 7h ago

You never could protect your code by technical means. Everything just increased the effort a decompiler had to work through. Use the law to protect them by using your intellectual property rights and contracts! And even then some countries have laws that allow decompilation in certain cases. Maybe checkout the EU Software Directive.

-1

u/chambolle 5h ago

In the EU, decompiling code is prohibited except in exceptional cases, and besides, it wasn't easy at all, especially for very complex code. So until now, compilation still protected it rather effectively. Now, it's a whole different story.