Are wood boxes sturdy enough to support a loft bed?
That's impossible to say because not all such boxes are built to the same specifications. Wood species and size, fastener type and schedule, and other factors vary widely. If forced to answer it would be no out of an abundance of concern for safety.
I would follow your plan, but lay 1x4 posts alongside the boxes where appropriate and aesthetically pleasing. Fasten the boxes to the posts and to the bed frame. Make sure it all has enough diagonal bracing, which is the most likely failure concern. That gets into design a fair bit, which isn't really on topic here.