ALBANY, N.Y. - The 18-year-old woman was driving with two friends near Coney Island in September when the two plainclothes detectives pulled her over and found marijuana. The officers released the two male passengers, handcuffed the woman and told her she was under arrest, prosecutors say.

Then, investigators say, detectives Eddie Martins and Richard Hall repeatedly sexually assaulted her before releasing her on Sept 5. The woman went to the hospital, where prosecutors say DNA was obtained that matched both men.

According to the victim, named Anna, the officers brutally took turns raping her inside an undercover NYPD van, CBS New York reports.

Get Breaking News Delivered to Your Inbox

But the officers have pleaded not guilty to rape and other charges, and the case has highlighted an apparent loophole in the laws of New York and many other states that may allow police to escape sexual assault charges by claiming sex acts were consensual. While New York law already bars sexual contact between corrections workers and inmates, it doesn't apply explicitly to police.

"I was shocked," Democratic state Sen. Diane Savino said of when she learned of the oversight. "It should be clear across the state for officers from every department, that when someone is in custody they do not have the ability to consent to sexual activity."

Gov. Andrew Cuomo is part of a bipartisan push to close what the Democrat calls "an egregious loophole" with legislation that would make it clear that people in police custody cannot give consent. A bill has already passed the state Assembly and was pending in the Senate.

The case underscores a chronic problem that was documented in an Associated Press investigation in 2015 that found about 1,000 officers across the country had lost their badges in a six-year period for rape, sodomy and other sexual assault. That total didn't even include New York or California because those states didn't track the number of officers fired for such offenses.

Bowling Green State University criminal justice Professor Philip Stinson has studied sexual misconduct by police around the country and confirmed such loopholes exist in many state laws.

But he cautioned that the legislation in New York might create new loopholes. Citing cases in which officers requested sexual favors in exchange for dropping a ticket or the threat of arrest, Stinson said motorists or pedestrians stopped by police are still under the power of the officer even though they haven't been formally arrested or detained.

But laws are needed, he said, as are internal department policies and programs that make it easy and safe for victims to file complaints. A study released two years ago reviewed policies of 35 policy departments and found that only about half had rules relating to sexual misconduct by officers.

In New York City, for example, a police watchdog group announced just this past week that it will begin investigating allegations of sexual misconduct by officers. Previously, such allegations were handled internally by the department.

Stinson said his research shows that the small minority of officers who engage in sexual misconduct often target drug addicts, sex workers, children, young women or others that they believe will be too frightened to come forward.

"It's the most vulnerable girls and women - and sometimes teenage boys and men - that I worry about," he said. "The ones who are perceived by officers as being throwaways."

In New York, the two detectives resigned from the department before they were to face an administrative proceeding that could have resulted in their firing. Their criminal trial has yet to begin. Martins' attorney Mark Bederow wouldn't talk about the defense, but stopped short of saying his client denied all contact with the woman.

"The allegation that there was any non-consensual sexual activity is patently false," he said.

John Arlia, who represents Hall, didn't respond to calls.