It's like a wish-granting genie who finds loopholes in your wishes, meeting the letter of the wish but not its spirit, and rendering you worse off than when you started. In fact, there is a mental model for this more specific situation, called the cobra effect, describing when an attempted solution actually makes the problem worse.
Chapter:
Anything That Can Go Wrong, Will
Section:
Be Careful What You Wish For