Facebook will come back stronger than ever from its data privacy scandals, so invest now, RBC Capital Markets' lead internet analyst told CNBC on Thursday.

"I think there's a couple of pieces that are going to come together in terms of new monetization, new products and greater platform security — and that package, when it comes out, that's going to be the asset to buy, but I think you can buy it here," Mark Mahaney said on CNBC's "Power Lunch."

Facebook said last week that it found a bug in a part of its service that allowed hackers to access information of nearly 50 million people. The breach comes at a bad time for the social networking giant, which has had a difficult year dealing with the fallout over various issues including the Cambridge Analytica data scandal and scrutiny over its role in elections.

"Getting hacked last week probably put them back two more steps, but I think these are solvable problems over time with enough spend," Mahaney said.

He said Facebook needs to prove itself by investing an enormous amount in artificial intelligence and building up the security of the platform. Just how much is "an unknowable," Mahaney said.

"What we do know is the size of the spend that they're talking about. They're doubling capex, more data centers, more engineers, 20,000 people just to monitor core content," he said. "Are they putting enough resources behind it? Probably. Are they correctly in panic mode? Yes. And our assumption is they'll get through this."

Facebook also needs to figure out how to best monetize messaging platforms, like Facebook Messenger and WhatsApp, as well as Facebook and Instagram stories, Mahaney said, which the company is addressing by "digging deep into more R&D spend and sales and marketing spend."

In August, Facebook took a definitive step toward monetizing WhatsApp by allowing companies to send information to customers through the app. Companies can also add a link to their WhatsApp chat on their website or pay Facebook to promote the chats in an ad.

Of all the FAANG names, investors are probably least bullish on Facebook, but Mahaney says it poses the best risk/reward ratio.

"The really interesting risk/reward in the group — and you're probably not going to get paid for it in the next 30 days, but in the next year — is Facebook," Mahaney said.

— CNBC's Arjun Kharpal and Michelle Castillo contributed reporting.