There are lots of these sorts of things available if you look around a little. For instance, these may work:
Mortise BedlocksMortise-free Bedlocks (these don't look quite as handy to me)
Taper Connectors (these look quite promising)
Titan Railing ConnectorsStriplox Surface-Mount Connectors (these also look promising)
Panel ConnectorsFlush-mount ClipsA lot of nicer toy wagons have removable side panels that are held on with a simple U-shaped bracket that a square post slides into. Something like that could work out well, too. They're (currently) unavailable
here but shouldn't be too hard to manufacture if one has access to a decent vice or sheet metal brake (and can't find something similar suitable).
Another possibility besides a solid rail might be a cargo net that could be anchored to either wall and the front frame of the drop-down bunk. Do take care to make sure the net openings are appropriately sized if you have little children sleeping there to ensure that they can't get their head caught in the netting.