I try to have about an inch of screw threads in the wood, You could perhaps go a little shallower, but I haven't wanted to push my luck and see how short was too short.
You may already know this, but a lot of folks recommend that you don't use wood screws, but use sheet metal screws instead. My preference is to use 1 1/2" long hex head screws...mini lag bolts. I think I use #8 size screws (if memory serves me).