there are probably 10 ways to do it. I'd probably cut out like you would for footholds and then de-foam that area. Throw a couple layers of 1708 knytex or similar behind the damage. Go to the outside and grind down to your knytex then throw a couple layers of kyntex on the outside to get back to original shape, with each layer larger than the previous. Sand it all smooth, repaint and then go. For the rail, just reinforce underneath with a couple layers and then do maybe a layer on top of the damage, with all the loose stuff being ground away. It all gets turfed over so it shouldn't be hard to make it look decent.
again. there are probably 10 ways to do it.....that's my first stab at it.