"What Facebook and OkCupid did wasn't just unethical. It was illegal."

So says James Grimmelmann, a law professor at the University of Maryland who's taking aim at the social media sites for conducting psychological research on its users without properly informing them. Now Grimmelmann is calling on Maryland Attorney General Doug Gansler to force Facebook and OkCupid to stop conducting tests on Maryland residents.

Facebook created a firestorm earlier this year when it acknowledged it had published a scientific paper on mood manipulation based on a secret experiment it did with some users' newsfeeds. The experiment, conducted in 2012, hid emotionally charged content from nearly 700,000 English-speaking users' newsfeeds to try to learn whether emotions were contagious on the network. Turns out they are; "sadder" newsfeeds made people more likely to post sad things, and "happier" newsfeeds made people more likely to post happy things.

Amid the uproar over Facebook's emotional "manipulation," the online dating site OkCupid voluntarily chimed in, saying it had lied to some of its users about their compatibility with other OkCupid members to study the outcomes based on the false information. OkCupid defended its practice by characterizing it as a form of modern product testing, something everyone from politicians to tech companies does these days.

Several concluded that Facebook's research was technically legal, even if the company could have been better at telling users what it was up to. That's because Facebook had gotten a stamp of approval from something called an institutional review board (IRB) — essentially, an ethics council for academic research — even though federal requirements exempted them from doing so. Facebook also argued that it had provided users with notice of possible testing in its fine print.

But Grimmelmann says he's taken a closer look at some of the state laws covering human subject testing. He concludes that Facebook, because it presented its study as science, may have violated a Maryland law known as HB 917. There may be other violations of local, state or federal law, but because Grimmelmann is a University of Maryland faculty, that's what he focused on. Stastically speaking, he said, it's almost certain that some of Facebook's study subjects were based in Maryland. Even if this is the only state with such strong laws — Grimmelmann said Maryland is considered a leader in academic research ethics — it would still raise troubling legal questions for Facebook and OkCupid.

Like the federal laws on human subject testing, HB 917 requires scholars to obtain both informed consent from human subjects and approval from an IRB. But where the federal requirement, called the Common Rule, only applies to federally funded research, HB 917 applies to "all research involving a human subject."

The concern here is whether Facebook obtained informed consent from Maryland users, if not from its entire English-speaking userbase, before engaging in the research. Because Facebook and OkCupid would be subject to the record-keeping requirements of HB 917, Grimmelmann has sentletters to the two companies asking them to make their IRB proceedings available to the public.

In response to Grimmelmann's letter, Facebook privacy lawyer Edward Palmieri denied that HB 917 applies to Facebook. "The federal Common Rule and the Maryland law you cite were not designed to address research conducted under these circumstances and none of the authorities you cite indicates otherwise," Palmieri wrote. Spokespeople for Facebook and OkCupid did not immediately reply to requests for comment.

Grimmelmann has a hard time swallowing Facebook's argument. So he's petitioned Gansler to restrict Facebook and OkCupid from experimenting on the state's residents until the two sites have implemented more robust ways of obtaining informed consent. One way they could do this, said Grimmelmann, would be to explain to users more explicitly about the kinds of tests they may be participating in and the risks associated with them.

"Facebook and OkCupid, by publishing these results that presented them very clearly as scientific experiments — they've placed themselves squarely on the research side of the line," Grimmelmann said in an interview. And unlike other companies that simply perform basic product testing, these companies should be held to a higher legal and ethical standard based on those claims, he said.

"We don't want to stop the research," said Grimmelmann. "We just want it to be done legally and ethically."

Brian FungBrian Fung covers business and technology for The Washington Post. Before joining The Post, he was the technology correspondent for National Journal and an associate editor at the Atlantic. Follow