I can tell you what I do to deal with this. First of all, Mr. Coffee is pointing you to what I would consider to be the proper solution, although you may choke on the price.
Order some of this and cut it into appropriate shapes:
Shop our selection of closed cell foam solutions today to find high-quality, durable options to suit your needs.
www.foambymail.com
I use the Minicel T600 foam from this site (scroll down that page and its near the bottom). You want the really thick, heavy duty stuff that is thinner than most closed-cell padding, so you can double it up. The 600 type is also durable enough to last for years without damage to itself.
Ideally you want the 1/2" stuff. But if the price hurts too much, buy the 1/4" sheet and use 2 layers.
If you want to try a cheaper solution, a Therma Rest camp mattress is about US$20 and you can cut it up and duct tape it into a shape to match your rack dimensions. I did that as a pannier liner on my longtails. This bag is, by the way, a Rothco parachute bag. and you see a brown one netted down on the top of my cargo box below. This black one I grommeted and used as a 68L pannier.
After that, Get yourself a drawstring laundry bag. Something sized to the container or just a little smaller. OR it can be bigger and just knot the excess so your load is kept inside and the individual items will no longer be able to freely bounce around.
I use the laundry bags in the back hardshell panniers (which are made from office wastebaskets) and cost a small fraction of what a pair of smaller Fjallraven hardshell panniers cost).
Lastly, get yourself a net of some kind to net down the top of the basket. You can see the nets I use on my panniers, but bungee corded ones work great, too. My pannier nets are just covers but on a wire rack you can use them to net stuff DOWN to hold them onto the floor. I did that with my handlebar rack and rear racks on both of my longtails. Also in the pic above you can see the net holding down a canvas bag on the top of my front box. That bag can be filled with stuff and the net locks it all down.
And after all of that, maybe forget about your little box and go big. One of two paths:
There is another post that shows later improvements to these bags. Here is another one that covers a hole I left in this article below. Great Big Bags 2.0 uses a better attachment method. I h…
talesontwowheels.com
or
Commercial products are available but are priced at US$300 for a pair. This alternative offers more space for minimal cost, needs only a few simple tools and can even be assembled in a few minutes.
talesontwowheels.com
I would create a bungee net suspension two inches from the bottom of the basket. Use zip ties all the way around with a hollow foam rolled pad under it for dampening.
The problem with that is action = reaction. Yesterday I used a net and had my thermos interwoven inside one of its squares. After just the wrong pothole, it sprang down and on the rebound, launched itself. Kind of a Wile E. Coyote moment. All the way to where I was going I was eyeballing it as it bounced and hoped it would stay put. It did until I had lunch and then it was empty and more airworthy.