NotQuiteLagom

NotQuiteLagom

Elixir source code obfuscation

I’m wondering about the best approach to “obfuscating” Elixir source code that needs to be available for a group of software developers as they need to use the components/functions but just the component API as the internals should be a black box.
I had a recent case of a group leaving the company and taking source code with them.
So, I was thinking…

  1. pre-compiled Deps?
  2. Obfuscating source code like in Javacscript but with the Mix format…
    So, if you use a component/modular approach where each component/module has one owner but it’s needed for the global project and developers can customise those components (for example in the presentation layer like a button, but not only) in their code, what would be the best approach.
    Thank you in advance!

Most Liked

cmo

cmo

Sound to me this topic is entirely about creating troubles for yourself :stuck_out_tongue:

mindok

mindok

IP protection is an org-level discussion, not just a technical one. Obfuscation is way down the list of things to think about - code is always exposed to being copied, decompiled etc by someone working on the codebase and honestly, the vast majority of the time it really makes no difference.

Really, the focus should be on the “secret sauce” unique to your application (hopefully there is such a thing). Secret sauce can be algorithms, datasets (e.g. used to train ML models), customer data etc, so understanding where and how value is created is key to any IP protection strategy. A lot of wiring up code is common to a large number of applications and if folks steal it, well, whatever - it shouldn’t make or break your company if it’s taken.

How you protect the secret sauce is then a combination of legal, social & technical. I have seen “inner-circle” developers who are “motivated” (better pay, equity, proven trustworthy, explicit legal threats or whatever) to be “stay close” being the only ones allowed to work on the core algorithms and outer-circle developers (e.g. contractors, new hires) only access the core algorithms via well defined APIs. This can be taken a step further if the algorithms are particularly valuable by, for example, offering an alternate, inferior algorithm with the same API for the purpose of building and testing integrations / UIs etc, but only deploying the real one into production to minimise the possibility of reverse-engineering.

Also, if an algorithm is valuable enough to want to prevent casual IP theft, it’s probably valuable enough to build some bits in a different language where the build artefacts are harder to reverse-engineer.

hst337

hst337

Obfuscated code like in JavaScript can still be easily deobfuscated. Providing .beam is not secure because they can be easily decompiled (even by hand).

w0rd-driven

w0rd-driven

I would definitely approach this from what decompilation tools are available and how user friendly they are. With .NET (though this may not be true now), I could decompile a release into somewhat full featured source code files and their respective project containers. Like beam languages, the code is interpreted as MSIL but being able to read that bytecode or put it in my IDE of choice is no simple task.

If tools existed to only view MSIL I’d personally consider it a small threat because the average developer isn’t going to choose to work at that level. The same would be true for Erlang’s bytecode. If code can be decompiled to a relatively working project, that’s when I’d be concerned with obfuscation.

I suspect the average Elixir developer when confronted with a release and no source is likely not too concerned to reverse engineer intellectual property from bytecode. There will always be determined hackers. As an anecdote, JavaScript obfuscation absolutely does not stop me from changing Vue to developer mode so I can use Vue tools extensions to analyze the components of popular websites. JS can obfuscate function names but magic strings have to leak through.

Taking your API example, anyone using your library would have to be obfuscated with it. Otherwise they’d have to use function names like MyModule.c() or some random thing that would ideally change every obfuscation run. Obfuscation in JS works because the source is bundled together then minified. If I were a developer presented with a library that required I also obfuscate my application, I’d likely look for a new library. What about connecting with iex? Would I have to run MyModule.my_function() or MyModule.c()? I’d use .c() exactly once before I ripped it out. You could be in the enterprise space where I’d be forced to use your library but I wouldn’t willfully choose something that put those kind of stumbling blocks in my path. That’s only my 2 cents but those would be the things I wrestled with.

Having said all that, you may want to look at DockYard’s BeaconCMS (beacon/lib/beacon/loader at main · BeaconCMS/beacon · GitHub) as pages and components are generated with unique names. Its been a minute since I analyzed how the modules in that directory worked but in the console you can see your components have hashed names to prevent collisions. My guess is this is so one CMS can handle multi-tenancy or multiple sites without one page or component stepping on the other. This may be what you’re looking for but the word “obfuscate” obviously triggers some things with me.

dimitarvp

dimitarvp

The BEAM languages are compiled into a fairly transparent bytecode so you absolutely cannot make it as opaque as you would like.

Where Next?

Popular in Questions Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement