I second the Great Stuff. I use it all the time for a variety of uses and it's.... well yeah, great stuff.
It is water proof but more imoportantly, it will insulate the pipe from the warm air inside the room, thus there will be no moisture.
It expands with a lot of pressure, so if you try to fill the box too quick it could blow out the seams. Like inspectorD says, do just a little at a time. Give it about 4 hours between applications to let each application fully expand before the next.