r/java • • 1h ago

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

0 Upvotes

27 comments sorted by

37

u/awidesky 1h ago

Obfuscation never protects your code.
Copyright law does.

3

u/ZorakOfThatMagnitude 1h ago

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

-1

u/awidesky 1h 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 52m 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 46m 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 37m ago

Also (gag) software patents

1

u/zazzedcoffee 1h 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 51m 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

42

u/janora 1h 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.

16

u/revilo-1988 1h 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 1h ago

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

6

u/revilo-1988 1h ago

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

0

u/Proper-Ape 1h ago

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

3

u/revilo-1988 1h 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.

8

u/AnotherLexMan 1h ago

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

3

u/sweetno 1h ago

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

3

u/_1dontknow 1h ago

That was never the point of JVM bytecode.

4

u/BoltaHuaTota 1h 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 1h 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 1h 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 1h 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).

0

u/ducki666 1h ago

No giving your (byte)code to public?

0

u/uldall 1h ago

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

0

u/VirtualNorth1279 49m 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)

-3

u/chambolle 1h 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.

4

u/janora 1h 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.