It's a foul, it is up to the player to clear the pocket of balls if needed.
A funny story about a similar situation that happened to me years ago at a tournament in a pool hall that was not very well maintained. They had leather pockets, and they were too low, so if you shoot at some tables at a decent speed, the ball would just fly off the table over the pocket instead of hitting the back of pocket and go in. After I saw it happen a few times, I went to my car to get a screwdriver to fix the pockets, and one of the guys yelled at me to "stop fixing the tables" LOL His reasoning was that the tournament needs to be run on the equipment as is, and that fixing an issue was cheating LOL. However, some players at a table had a bit better thinking and reasoning and asked me to fix the pocket on the table they were at, so I was able to get the equipment to actually function properly.