The U.S. House of Representatives on Thursday voted unanimously to criminalize so-called revenge porn -- the non-consensual sharing of nude pictures or video -- in the military.

The lower chamber voted 418-0 in passing the legislation sponsored by Rep. Martha McSally, a Republican from Rhode Island and retired Air Force officer who flew the A-10 ground-attack aircraft on missions in Iraq. The news was first reported by Military Times.

The legislation would update the Uniform Code of Military Justice (UCMJ) to define when private photo sharing is a criminal act, McSally said.

"As the only female Republican veteran in the House of Representatives -- the first woman in the U.S. to fly in combat and to lead a squadron -- I have personally experienced, confronted, and overcome sexist behavior in the military," she said in a statement.

"Our service members should not have to watch their backs among the individuals who are supposed to be their teammates," she added. "The military needs to clean this up. By strengthening and modernizing the UCMJ, this bill enables the military to hold perpetrators accountable, and I am thankful the House has joined me in taking such swift action."

The photo-sharing scandal surfaced in March after journalist Thomas Brennan broke a story about how current and former Marines were sharing nude and compromising photos of female colleagues on a Facebook site Marines United.

The Corps and other services subsequently updated social media training and guidelines in an effort to crack down on the practice.

In a letter to all commanding generals, Marine Corps Commandant Gen. Robert Neller said "this inappropriate, disrespectful, and in some cases criminal behavior has a corrosive and negative effect on our Marines and on the Marine Corps."

Lawmakers, meanwhile, moved to criminalize the behavior.

McSally, a member of the House Armed Services Committee, worked with her colleague, Rep. Mike Coffman, a Republican from Colorado, chairman of the panel's Military Personnel Subcommittee and military veteran, to craft the bill.

The legislation, H.R. 2052, called the Protecting the Rights of Individuals Against Technological Exploitation (PRIVATE) Act, would still need to be passed by the Senate and signed by the president before becoming law. A spokeswoman for McSally couldn't say when the upper chamber may act on the bill.

-- Hope Hodge Seck contributed to this report.

-- Brendan McGarry can be reached at brendan.mcgarry@military.com. Follow him on Twitter at @Brendan_McGarry.