If you're a criminal, be careful who you friend on Facebook.

A federal judge ruled last week that law enforcement can create fake social network profiles in order to search through a suspect's account. Cops can lure suspects into "friending" them and then use the content of their Facebook (FB), Instagram or other social media accounts against them in court.

United States District Judge William Martini denied a defendant's motion to suppress evidence collected from his Instagram profile after he connected with an undercover account created by police officers.

The defendant Daniel Gatson argued that the police had no probable cause to search through his Instagram account. But Judge Martini argued that since Gatson accepted the request to become friends with the police officers, he enabled law enforcement to view photos and other information that he posted to his Instagram account.

As a result, the police did not need a search warrant. The sharing was consensual, the judge ruled.

Related: Facebook tells DEA: Stop impersonating users

Law enforcement has increasingly made use of the fake accounts tactic over the past year, angering social media companies, including Facebook and its Instagram subsidiary. Facebook has said it is "deeply troubled" that its customers consent to a legal search by friending fake accounts.

In October, Facebook sent a letter to the U.S. Drug Enforcement Administration demanding that agents stop impersonating users on the social network.

"The DEA's deceptive actions... threaten the integrity of our community," Facebook chief security officer Joe Sullivan wrote to DEA head Michele Leonhart. "Using Facebook to impersonate others abuses that trust and makes people feel less safe and secure when using our service."