Open jberryman opened 2 years ago
Things we'll want to change or add in haskell bindings:
IO
not in MonadIO
IO ()
and IO value
eval/call
Thank you Brandon, this is super valuable!
I'm going to keep adding notes here @GavinRay97 , as I think of them. Also need to start a fork anyway to make more progress on the typescript POC
There are two threat model scenarios:
But eval()
complicates the first scenario. We might wish to prohibit eval in duktape in order to protect customers in scenario 1 from injection attacks (which also breaks the threat model because it could allow an escalation from scenario 1 to scenario 2)
Not clear if we can actually do this without breaking code everywhere, but we'd need to shim/overwrite:
passing cyclic object to haskell code results in immediate exit(0). This is very bad:
const cycle = {};
cycle.cons = cycle;
console.log(cycle); // Probably any exposed haskell func works here
console.log("We never get here");
exit originates from some call to fastExit
; trace further https://github.com/ghc/ghc/search?q=fastExit
Breakpoint 1, __GI_exit (status=status@entry=0) at exit.c:139
139 exit.c: No such file or directory.
(gdb) bt
#0 __GI_exit (status=status@entry=0) at exit.c:139
#1 0x0000000000f04bb8 in stg_exit (n=n@entry=0) at rts/RtsStartup.c:646
#2 0x0000000000f04eee in shutdownHaskellAndExit (n=0, fastExit=fastExit@entry=0) at rts/RtsStartup.c:579
#3 0x0000000000f0eda1 in hs_main (argc=<optimized out>, argv=<optimized out>, main_closure=<optimized out>, rts_config=...)
at rts/RtsMain.c:99
#4 0x000000000041ccb6 in main ()
empty panic message when we return cycle
from a function we call using callDuktape
(once we install a FatalFunction
; otherwise we get SIGABRT, which is expected). This might be fine but the fact we don't get an error message is worrying
duktape to test:
function id(x) { return x }
to check:
safe
FFI calls: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html#unlifted-ffi-types (...and how might we try to test this. Triggering a bunch of GCs in another thread?)misc:
hs-duktape
or a fork ourselves, but this seems totally doable