It depends on which expanding foam you buy, cheap domestic use foams are generally not waterproof, more expensive trade use foams sometimes are waterproof.
Polyfilla expanding foam is one of the most common foams on the market, it is used for filling holes in building interiors where it will usually be dry.
Polyfilla will absorb a certain amount of water like a sponge so if you are looking for something that is waterproof then Polyfilla is best avoided.
You should also avoid using rigid expanding polyurethane (REP) as this is liquid-based and performs very poorly when exposed to moisture.
Fortunately there are plenty of alternative expanding foams available which are waterproof, though be aware they are generally more expensive than standard foams:
- Polycell expanding foam is used throughout the building trade in areas where waterproofing is necessary. Though it is not a good idea to use it in areas below the waterline as over time it will break down and allow leaks through.
- Expanded Polystyrene is a good choice for filling up large spaces like wall cavities or spaces in boat hulls or pontoon floats which are constantly immersed, it lasts for decades even when fully immersed in water without any problems so can be used for patching up the fiberglass hulls of boats.
PVC Expanding Foam is the top choice if you want to be absolutely certain that the foam you are using is 100% waterproof and won’t break down.
These tend to be very expensive as they are manufactured for use on extremely specialist jobs.
Airex is one brand that makes PVC expanding foam.