Marijuana is one of the fastest-growing industries in the US. It's also illegal.

Federal prohibition has given rise to a number of dedicated funds that are looking to capitalize on the "short window" of opportunity before institutional investors start writing checks.

Investors who are patient and willing to take on the risk stand to make huge gains.

Legal marijuana is one of the fastest-growing industries in the US. It generates hundreds of millions in tax revenue in states where selling the drug is legal, and it's expected to become a $32 billion global market in the next four years. It's also considered illegal by the federal government.

But for a few cannabis-specific funds, federal marijuana prohibition is the opportunity of a lifetime.

While many of the biggest Wall Street banks and institutional investors may want to do business in the cannabis industry, their limited partners — typically large pension funds or insurance companies — are spooked by federal prohibition.

Jon Trauben, a partner at the New York City-based Altitude Investment Management, which manages around $25 million, told Business Insider in a recent interview that the firm is taking advantage of that short "window of opportunity" to invest in marijuana before prohibition recedes and the big institutional players jump into the sector.

"It's unique, timely, and you can't ignore it," Trauben said.

Here's how it works: canny investors like Trauben hit up high-net-worth individuals or family offices for capital. These entities are willing to take on tons of risk putting their money to work in what amounts to a legal grey area.

Through dedicated funds — structured as venture capital, private equity, or hedge funds — that capital can be quickly deployed to finance growth in the booming cannabis sector, especially for US-based companies that are working under severe capital constraints.

Most of these funds invest in ancillary companies, like tech startups that provide software and payroll services to the booming marijuana industry but don't actually grow or sell the plant itself. That shields them from most of the risks involved with doing business in an industry the federal government considers illegal, but still allows them to reap profits.

The chaos theory of investing in cannabis

Many investors in the marijuana industry are taking a page straight out of the "Game of Thrones" playbook: Chaos, in this case, is a ladder to strong returns.

"When there's complexity, when there's chaos, when there's uncertainty, that's when the people who are really good at doing what they are doing stand to make really strong gains," Micah Tapman, a managing director at Colorado-based Canopy, which focuses on early-stage investments in the cannabis industry, previously told Business Insider.

"The lack of banking and lack of access to capital is creating a huge opportunity," Danny Moses, a hedge funder behind the famous "Big Short" trade chronicled by Michael Lewis said at the Cannabis World Congress and Business Expo in New York. "It's a gold mine, but it's also a minefield."

Moses, who has called investing in marijuana the "big long," has put some of his personal money into Merida Capital, a New York-city based private equity fund led by a former corporate attorney, Mitch Baruchowitz.

To Baruchowitz, who told Business Insider in June that his firm manages around $50 million, the best investments are those that build the "scaffolds" for the marijuana industry.

"So our investment thesis is one that is much more geared towards that scaffolding," Baruchowitz said. He pointed to Merida portfolio companies like Simplifya, a software service that helps cannabis dispensaries comply with byzantine operating regulations, which tend to differ state-by-state.

As with any cutting-edge industry, there's a learning curve for investors. But it's easier when they're not competing with multibillion-dollar funds.

"There's no truer way to learn something unless you spend your own money," Trauben, of Altitude, said. "And right now, we don't have to compete with the Goliaths."

Wall Street is banging at the door

The legal grey area the cannabis industry finds itself in is slowly shrinking, and the window of opportunity for investors will eventually close.

Big institutional firms are already pushing into marijuana as attitudes around the drug change, and a number of bills legitimizing the industry at the federal level work their way through Congress.

Karan Wadhera, the managing partner of Casa Verde, a Los Angeles-based venture capital fund focused on ancillary cannabis companies, told Business Insider in April that his fund is receiving a lot of inbound interest from large institutional investors.

"I think this is a testament to both the size and pace of growth in the cannabis industry," Wadhera said, adding that last year, "many top VCs would not be ready to entertain a conversation on cannabis."

Just last week, Constellation Brands — the beermaker behind Corona — sunk $4 billion in a stock deal into Canopy Growth, a publicly traded marijuana company. It's the largest corporate investment into a marijuana cultivator to date.

And guess who advised Constellation on the transaction? None other than the most institutional of institutional firms: Goldman Sachs. Bank of America, one of the largest banks in the world, provided the financing.

Read more of our cannabis industry coverage: