sensepost / gowitness

🔍 gowitness - a golang, web screenshot utility using Chrome Headless
GNU General Public License v3.0
2.87k stars 329 forks source link

Docker Chrome is left as a zombie process #94

Closed Daviey closed 3 years ago

Daviey commented 3 years ago

Running in my own docker image (without dumb-init), each run leaves Zombie Chrome processes.

Version

Installed / built using go get.

$ google-chrome --version
Google Chrome 89.0.4389.90
$
$ gowitness version                                                                                                                                                                                        
gowitness: 2.3.4

git hash: dev
go version: dev

Steps to reproduce

I see this on single and server mode. Each time gowitness is called, the zombie processes for chrome increase.

$ ps -elf | grep chrome
0 S root        67     6  0  80   0 -   794 -      10:09 pts/0    00:00:00 grep chrome
$ 
$ gowitness single https://github.com
20 Mar 2021 10:09:28 INF preflight result statuscode=200 title="GitHub: Where the world builds software · GitHub" url=https://github.com
$ 
$ ps -elf | grep chrome                                                                                                                                                                                    
0 Z root        83     1  0  80   0 -     0 -      10:09 pts/0    00:00:00 [chrome] <defunct>
0 Z root        84     1  0  80   0 -     0 -      10:09 pts/0    00:00:00 [chrome] <defunct>
5 Z root       102     1 42  80   0 -     0 -      10:09 pts/0    00:00:05 [chrome] <defunct>
1 Z root       103     1 24  80   0 -     0 -      10:09 pts/0    00:00:03 [chrome] <defunct>
0 S root       131     6  0  80   0 -   794 -      10:09 pts/0    00:00:00 grep chrome
$ 
$ sleep 1m
$ 
$ ps -elf | grep chrome
0 Z root        83     1  0  80   0 -     0 -      10:09 pts/0    00:00:00 [chrome] <defunct>
0 Z root        84     1  0  80   0 -     0 -      10:09 pts/0    00:00:00 [chrome] <defunct>
5 Z root       102     1  5  80   0 -     0 -      10:09 pts/0    00:00:05 [chrome] <defunct>
1 Z root       103     1  3  80   0 -     0 -      10:09 pts/0    00:00:03 [chrome] <defunct>
0 S root       134     6  0  80   0 -   794 -      10:11 pts/0    00:00:00 grep chrome
$ 
Daviey commented 3 years ago

Confirming that if the container is run under dumb-init, this issue doesn't happen.

leonjza commented 3 years ago

That makes perfect sense! I'll update the Dockerfile soon! :D

leonjza commented 3 years ago

Looking into this, I realise we are already using dumb-init in the official Dockerfile. Running with docker run --rm -it leonjza/gowitness:latest bash:

root@e9ac1762375c:/data# gowitness single https://github.com
23 Mar 2021 16:17:36 INF preflight result statuscode=200 title="GitHub: Where the world builds software · GitHub" url=https://github.com
root@e9ac1762375c:/data#
root@e9ac1762375c:/data# ps hax | grep -i chrome
  509 pts/0    S+     0:00 grep -i chrome
root@e9ac1762375c:/data#
Daviey commented 3 years ago

Apologies @leonjza I should have been clearer, this was running in my own docker image. Initially I thought it was something gowitness was doing, but it now seems to be an issue purely with chrome.

I'm not sure there is anything gowitness could/should do different, so i'm going to close this.

Apologies for the noise!

Thanks