There are several excellent documents available that explain CGI risks and WWW security in general. I will provide the main points here. You are encouraged to read the documents in the reference section for more detailed information. CGI scripts are as dangerous as they are useful. This is not to say that you should not use them.
Computer security is a give and take situation.
However, without offering services you may as well not have the computer in the first place. Thus, security becomes more about acceptable risk and emergency recovery than impregnability. This does not mean we should abandon scripts altogether, however. It is possible to write insecure code very easily in any language. It means we should take a good look at our scripts to make sure they are secure.