In a past life spent working as a shipper, we used expanding foam regularly. The trick was to place a large plastic sheet over the box and tuck it inside. (the sheet would then overlap the edges of the box by about half the box's width all around) then add the A and B components. The plastic sheet prevented the foam from adhering to the interior of the box, but would allow it to expand upward. Using this method you'll have individual blocks of foam that you could replace at will if an error were committed. If that's an undesirable side affect, I'd run a bead of wood glue around the bottom of the area of the buck you're filling, then tuck a plastic sheet down inside and smooth it out against the interior, then add your A-B foam. Clear as mud?