How to prevent malicious javascript in V8 (with Python)

I am using PyV8 to run untrusted javascript. How can I detect and kill javascript that has inifinite or long loops? I would like to say v8 to run javascript and fail with a timeout if it has not finished in 0.1 seconds.

+2
source share
1 answer

if it is python, you can use cow interrupt:

from interruptingcow import timeout try: with timeout(5, exception=RuntimeError): # perform a potentially very slow operation pass except RuntimeError: print "didn't finish within 5 seconds" 

https://bitbucket.org/evzijst/interruptingcow

+3
source

Source: https://habr.com/ru/post/911085/


All Articles