For the most part bolts that creek or are loose are a pretty easy fix, either tighten them, lube them, or replace them. That's partly true with bicycle bolts as well but when dealing with the crank bolt the hardware can be unique and you need to take a timid approach to the fix. Here's how to alleviate some of the common issues that could be causing your bolts to rattle or underperform in the crank area.
Take the Bolt Out and Remove the Crank
Using most likely an 8mm hex head Allen wrench, unscrew the bolt that is protruding into the crank. Even with the bolt loose the crank shouldn't budge much because it's still sitting on the thread but you'll probably find out that it will. It's best to take the crank off at this time as well to really get to the root of the wobble problem. While everything is off it's a good time to clean both the crank and the thread it goes on to. These areas are prime for picking up road and trail grime and even a good power washing doesn't always get inside of the assembly.
Fix the Loose Bolt
While it would be easy to just buy a replacement bolt if it's loose, many times the actual problem area is within the threads that it screws in to. These splines can become worn down, merged together, split, or a number of things that could prevent a nice tight fit. You don't want to use a Loctite fastener because you need to be able to unscrew the bolt relatively easy but something that actually works very well is nail polish. Simply spread the polish in it's liquid form generously on the thread and then screw in the bolt. The two components make a nice seal and should prevent the annoying rattle.