[erlang-questions] Right direction ?
Wed Sep 28 03:25:42 CEST 2011
> I don't really understand. The only (legal) way to modify the beam
> is to change the source and recompile. I think you have to
> decide exactly what the semantics of require are.
I'm actually most concerned about the illegal way of modifying a beam:
a.) Sysadmin gets clever an runs rsync patching the beam with a diff from
one on another server (bad if that server doesn't have the right version)
b.) Developer gets clever and uses source control as a deployment mechanism,
"git push production master", overriding the version there
c.) Nefarious type replaces beams with other beams that have been compiled
with compromised security built in
having a loader that can check at run time (late binding)
> a) We check the require targets *before* compilation with
> a separate program
rebar (http://github.com/basho/rebar) already does a pretty good job at this
(as long as you list all your dependencies as git repos) and I've been
making heavy use of this over the past year. It handles checking out and
compiling all the dependencies, and you can specify which specific tags you
c) we check at usage time. The first time we call daves_module and find
it has not been loaded we check the cache and so on
Right now I'm most worried about c.) in the context
try_load_module(Mod, Dir, Caller, St) ->
File = filename:append(Dir, to_path(Mod) ++
case erl_prim_loader:get_file(File) of
try_load_module(absname(FName), Mod, Binary, Caller, St)
Where the file pointed to by FName is now "trusted" and will then be read
into memory and passed off to hipe.
Part of the problem is I'm also introducing a new risk, because I'm
replacing this load bit with code that can read a URL rather than just a
filename, so I'd like a way to hook in to check that the file I've
downloaded is the same as the signature I have on file in a dets store.
> Good stuff - needs some thought though. I was thinking of
> the source with an RSA public/private keypair.
I've thought about adding RSA public/private key signing, but that
ultimately goes down the route of having a CA to form a trust network, and
since CAs tend to prove to be unworthy of trust, I'm wary. Self publishing
a RSA public key + signing a SHA hash of the source and putting both in DNS
seems like a reasonable way of doing it, but can also be exploited to deny
service by DNS cache poisoning.
If one were to implement a pub/private key signature check, would it best be
done in code_server.erl or somewhere else? That seems to be the first place
the files are loaded into memory at run time.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions