fix forking exploits

This commit is contained in:
Thomas Hobson 2021-04-26 19:37:40 +12:00
parent 6fe0da030d
commit 9a52e369f2
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
1 changed files with 11 additions and 0 deletions

View File

@ -192,6 +192,17 @@ class Job {
processes = processes.filter(proc => proc.uid == this.uid); processes = processes.filter(proc => proc.uid == this.uid);
for(const proc of processes){ for(const proc of processes){
// First stop the processes, but keep their resources allocated so they cant re-fork
try{
process.kill(proc.pid, 'SIGSTOP');
}catch{
// Could already be dead
}
}
for(const proc of processes){
// Then clear them out of the process tree
try{ try{
process.kill(proc.pid, 'SIGKILL'); process.kill(proc.pid, 'SIGKILL');
}catch{ }catch{