I want to remove unwanted functions from the BEAM, but without recompiling it.
My scenario is the following, someone is going to connect at my BEAM node, and I only want they to be able to execute a small subset of the normally available functions (like restricting SYSCALLS in a ELF file).
I know this is not the ideal approach, but it is part of a series of experiments that I’m doing on the BEAM. So any help would be nice.
If you want untrusted users run code on your node, provide them a way to connect via telnet or ssh (the BEAM has server applications for both) and provide them a shall that way that has a shrinked down language, either erlang or elixir like, or something completely different, which you then restrict by your own runtime environment before delegating to the BEAM.
Or even better, is to not let untrusted users connect to your node…
This is the part that is functionally impossible unless all you want to do are let people use math operators or something. It’s simply too easy to generate atoms dynamically and then use them as function calls. You’re better off using something like https://github.com/rvirding/luerl
This seems like a bit of an XY problem. What problem are you trying to solve here ultimately?
I think both, but I’m assuming node A cannot be trusted.
Ideally for my proof of concept, I’ll have a chess game running on a genserver in B. And players will only be allowed to spawn process with functions from the module of the chess game. Sure a function inside the module may be vulnerable and break the protection, but the problem I’m trying to address is the spawn itself.
This could be used for mesh networks in embedded systems using https://github.com/bettio/AtomVM for example, where I open myself to the world, but not too much.