My first thought on this is to write a small shell script (or C program or python, or you choose the language) and set its SUID bit. This will make it run with root permissions. Hence you CGI can call this program and properly set GPIOs. My assumption is that you want to configure this from the web. However if you need to set it once you can do at boot time (more securely IMHO) using rc scripts.