A loophole in a law often contravenes the intent of the law without technically breaking it. For example, in some places, one may avoid paying taxes to the jurisdiction by forming a second residence in another location, or a commercial property can be built in a residential zone if it is made also for residential use.
In a security system, the one who breaches the system (such as an inmate escaping from prison or a terrorist) exploits the loophole during breach. Such weaknesses are often studied in advance by the violator, who spends time observing and learning the routine of the system and sometimes conducts surreptitious tests until such a loophole can be found.
An example of a legal loophole: