Is there a way to attach a safe box to a bike?
There's a product called a Northcore Keypod which is essentially a combination padlock with a key box built in.  I've got one (it's meant for locking under your car with the car key in while surfing etc.)  I strongly suggest that if you use something like this you make sure your address isn't marked anywhere on the bike or in the keybox.

Combined with a looped cable you could use it to lock up your bike, but only somewhere quite secure.  I'd use a D-lock as well, locking the helmet and front wheel with this and a cable.

Anything like this will be a bit of an ovious target.

Something I've considered for emergency cash is hiding it in a screwed-shut rear light (the sort that's screwed to the bike's rack).  A mini penknife screwdriver would then open it up. Most of my lights would take a key, but there's a difference between losing (accidentally or by theft) a little cash, and losing your house key.  Further downsides: the screws aren't really meant to be used that much; it's a bit tedious.  But it could be good for a one-off if you're otherwise stuck.