When I started building my first frame I (stupidly) decided to bolt it together, I was worried but stripping threads etc so I did some experimenting...

The test piece was 4mm steel box section drilled and tapped for use with regular M6 socket screws. With a screwdriver and a hex head I couldn't do the bolts up tight enough to strip or damage the thread in the box section. With a regular Allen key I generally couldn't damage the thread, after repeated re-tightening as tight as I could do by hand I did manage to make a couple of the test holes a bit loose. With a cheater bar on the Allen key I could strip the threads and using a drill driver without torque limiting I could strip the threads. My conclusion was 4mm box + M6 was more than strong enough for what I was doing.

I also experimented with some 3mm box + M6 and concluded it wasn't good enough. You can get a thread in it but it's clearly not much good. M5 worked and M4 (which is what I suspect your rails will be using) was fine.