I have pens for my cave bugs in my cave and the tamed one in a pen next to an untamed bug causes them to battle to the death. They ignore the fencing between them. Fences should block this.
Additionally creatures are able to attack through the walls of underground dwellings if they are within striking range of a player or creature.