There is a product called "Great Stuff" It works very well for this application. You can obtain it at Home Depot. This foam does not absorb water, It will fill a void and stop unless it finds a hole and it will protrude through the hole. This product is semi rigid, or hardens to a firm but not hard state. Buy a can and try it, I think you will like it.
Frank