I think we have all experienced a bubble/blow-over brew at some point in our brewing life, all in varying degrees of disaster. I’ve seen chest freezers absolutely covered in worty mess, but sometimes it’s slightly less disastrous, where it has gone only as far as your bubbler. This is why it always a good idea to have one bubbler spare.
The reason for a bubble over is a lack of headspace in your fermenter and the krausen has escaped. Many brewers forget that high gravity brews (anything above 1.060 OG in my opinion) need extra headspace in the fermenter. But even lower gravity brews can blow over if the fermentation is particularly vigorous, usually caused by higher fermentation temperatures or increased aeration etc.
So what do you do?
Don’t panic! It looks worse than it is. Get a spray bottle of sanitiser and do your best to sanitise and clean the outside of the fermenter and surrounds. Only deal with the bubbler/blow off tube once the fermenter and surrounds are clean and sanitary. You don’t want to open the fermenter at all. Transferring your worty beer into a clean fermenter will only harm your brew at this point. Your fermenter will look like a dog’s breakfast on the inside, but it’s a yeasty/worty/hoppy dog’s breakfast, so rather leave it. You can always transfer into a secondary bucket on bottling day.
Once the outside of your fermenter is clean and sanitised, you can swap over to a clean bubbler, or blow off tube of the same diameter as the bubbler (so that it fits snuggly). When you do this, make sure the replacement bubbler/blow-off tube has been properly sanitised. If the rubber bung that holds the bubbler is also mucky, then I would suggest using a cotton bud or cotton wool, also sanitised thoroughly, to gently swab it clean. Cane or Vodka also works very well for this, if you are worried about the sanitising solution getting into your brew. The opening where the bubbler fits is very small, so it is not likely for any nasties to sneak inside during this process, but I would still try and work quickly, and work in an area that is not too draughty. Replace your bubbler, fill with a little alcohol or sanitiser to create an airlock, and you’re good to go again.
Alternatively you can use a blow off tube, place the end of the tube into a bucket of sanitiser solution so nothing gets into your fermenter via the tube.