Any noble who does not have a unit, and who passes through another realm with which they are at war, has a chance of being captured by that realm. For infiltrators, the chance to be captured is greatly reduced.
If the new treaty system ever goes active, then the chance to be captured would also be increased by a Closed Borders treaty. For right now, although you can still sign these treaties, they have no game mechanics effects.