Last year I had a job that included re-wiring a receptacle in a masonry wall. Due to chronic water seepage from the shower on the other side of the wall, the brick was soft and crumbly. I anchored the replacement box with expanding foam. It worked well.