Presidential hopeful Elizabeth Warren wants to ban private prisons because "no one should make a profit locking people up," but the senator has financially benefited from private prison companies in the past.

The Massachusetts senator invested up to $50,000 in a Vanguard Group fund that owned hundreds of millions of dollars worth of shares in leading private prison companies. Warren sold her stakes in that fund in exchange for a different retirement account in 2013. At the time, the fund was the largest shareholder of America's largest private prison corporation.

Warren invested in Vanguard Target Retirement 2025—a retirement account run by the Vanguard Group, an investment management company—which in turn invested more than 30 percent of its money in Vanguard's domestic stock index fund. Vanguard was the top shareholder of Corrections Corporation of America (CCA), and one of the largest of GEO Group, both private prison companies, according to data from the Securities and Exchange Commission. Vanguard owned more than 12 million CCA shares and nearly 9 million GEO Group shares, which were worth roughly $456 million and $216 million, respectively, in March 2013.

CCA, now called CoreCivic, was already the country's largest owner of private prisons in 2013, according to an annual report. The company owned or controlled more than 50 correctional or detention facilities in the country, "with a total design capacity of approximately 86,000 beds in 20 states and the District of Columbia." GEO Group is also one of the largest private prison providers in the country with 66 prison facilities across the world as of 2013. The two companies also operate many Immigration and Customs Enforcement (ICE) detention facilities for illegal immigrants.

The Warren campaign did not respond to request for comment.

In June Warren announced in a Medium post she would "ban private prisons and detention facilities." The plan would also prevent private contractors from charging fees to inmates for in-prison services such as phone calls.

"There should be no place in America for profiting off putting more people behind bars or in detention," Warren wrote in a June Medium post. "That's why I will shut down the use of federal private detention facilities by ending all contracts that the Bureau of Prisons, ICE, and the U.S. Marshals Service have with private detention providers."

"No one should make a profit locking people up, and no one should have a financial incentive to lobby Congress to lock up even more people," Warren said at a Sept. 16 rally in New York's Washington Square.

Vanguard Group previously told CNN it would be very difficult to eliminate every controversial business from its stock portfolio. Index funds purchase stocks in a wide range of companies to guarantee low costs and high stability to investors.

"We believe it would be exceedingly difficult to manage our funds effectively and efficiently while seeking to address the many social, political, and environmental concerns of our 20 million clients and the broader global community," the company told CNN.