Funkyenv: mix your binaries up

Four, four, the point’s marked four

Ace, Deuce, craps wants four

- Funky Dealer from Jet Set Radio Future

If you don’t want people guessing the function layout in your version of PHP or its extensions for some reason, mold has you covered :handshake:. Just use funkyenv and set a seed for your binaries. A ld.lld version is also included for things like glibc.

funkyenv compiles 32 tiny stub functions (that all just return $x) into the final binary so it can verify they were shuffled afterwards. The overhead is only a couple hundred bytes and loss of spatial locality. A passthru is also included that exports the function layout so you can diff it against the original.

php =
  let
    callPackage = pkgs.newScope {
      # oh my god please do not use this seed
      stdenv = pkgs.funkyenv.seed 4;
      inherit callPackage;
    };
  in
  (callPackage (pkgs.path + "/pkgs/development/interpreters/php") { }).php85;
6 Likes

Update: Firefox works, and there’s an example (and test) for openssh too. Get funky and scramble all your binaries :grin:

1 Like