whether your webserver sends data to a launched program, or another daemon via a socket, or is embedded in your handler, nothing changes
cgi doesn't add custom code based on request, it just runs predetermined commands, which you should have written properly, and should have sanitised data properly