According to IBM, the average cost of a data breach is $4.35 million. While this figure includes the cost of the breach, customer loss, and fixing the problem, it's still a hefty hit that many businesses couldn't survive.

The answer to these problems? Better cybersecurity software. That same study also found artificial intelligence (AI)-powered security reduced data breach costs by 70%. Additionally, customers with these types of cybersecurity programs also experience breaches less often.

This aspect makes this software invaluable, and the providers often make great investments. Even during difficult economic times, companies aren't just going to eliminate their cybersecurity provider. It's this kind of necessity that adds to the investment thesis of cybersecurity companies.

Two cybersecurity stocks that I believe are great investments are CrowdStrike (CRWD 0.13%) and Cloudflare (NET -1.05%). Each of these displays the traits I mentioned above but are also market leaders in their respective industries.

1. CrowdStrike

CrowdStrike's endpoint security platform protects network access points like phones or laptops from attacks. While this may sound like a typical antivirus program, it's related but much more powerful. CrowdStrike uses trillions of data points gathered weekly to feed AI models and determine if an activity is normal, an anomaly, or a threat. It can then stop the breach and use that information to improve its protection on all of its customers' endpoints.

This functionality is just the beginning of CrowdStrike's software package, as it has more than 20 different modules that customers can purchase to add to their cybersecurity functionality. In fact, 59% of customers use five or more modules, while 20% use seven or more.

Module expansion is primarily how CrowdStrike generates more revenue from existing customers, which is captured by CrowdStrike's revenue retention rate metric of 124% (meaning customers spent $124 this quarter for every $100 they spent in last year's quarter).

Altogether, CrowdStrike's annual recurring revenue is $2.14 billion as of its Q2 (ending July 31). This metric is up 59% year over year, which shows how rapidly CrowdStrike is growing. It's also free cash flow positive, indicating to investors that it doesn't need outside funding to continue its operations.

While more profits will come as the company matures and reaches scale, it's currently doing everything possible to capture its 2025 estimated $126 billion market opportunity. Compared to its current $2.14 billion annual run rate, CrowdStrike has a long way to go before saturating its market.

2. Cloudflare

Unlike CrowdStrike, Cloudflare has other businesses besides cybersecurity. Cloudflare has data centers worldwide that are dedicated to hosting websites. By placing website code in these locations, those navigating to and around the website will experience unparalleled speeds, as the website code is physically closer to the user.

Cybersecurity naturally flows into this offering, as Cloudflare must protect its customers' websites from attacks. Like CrowdStrike, Cloudflare also uses machine learning to evolve its algorithm and better protect all customers.

While this may seem like a product only massive companies use, Cloudflare has designed its product to be useful for businesses of all sizes. With more than 151,000 paying customers, it's safe to say Cloudflare has made its valuable platform for everyone. However, more than 50% of its revenue comes from large customers who pay more than $100,000 annually to Cloudflare.

In Q2, Cloudflare also continued its impressive trend of growing revenue at about 50% from a year ago, just as it has since coming public.

NET Revenue (Quarterly YoY Growth) Chart

NET Revenue (Quarterly YoY Growth) data by YCharts

Cloudflare is also rapidly approaching profitability, improving its non-GAAP operating margin metrics significantly.

Year Non-GAAP Operating Margin
2019 (25%)
2020 (8%)
2021 (1%)
2022 (Projected) 1%

Data source: Cloudflare.

With Cloudflare's rapid growth and rising profitability, investors should feel good about the financials. Throw in Cloudflare's estimated $135 billion market opportunity by 2024 against trailing-12-month revenue of $812 million, and investors can quickly see Cloudflare's business trajectory of growing into a large, successful business.

Expensive stocks for great companies

With CrowdStrike and Cloudflare, one investment risk is their stock valuation. From a price-to-sales standpoint, each is highly valued and remains above its pre-2020 levels.

NET PS Ratio Chart

NET PS Ratio data by YCharts

However, with each company growing its revenue at a 50% year over year minimum pace and facing a massive market opportunity, these stocks could easily grow into their valuation. Of course, sustaining that level of growth will be difficult as the businesses get larger, so their valuation will likely taper down with this growth drop. Still, there's a reason why these companies are so expensive: their execution.

Both businesses have proven they can grow during good and bad times, so they have earned their premium. But if they begin to falter, expect the stock to tumble down hard. However, CrowdStrike and Cloudflare are led by their founders (CrowdStrike's CEO and co-founder is George Kurtz, and Cloudflare's CEO and co-founder is Matthew Prince), and their vision and leadership will push these companies to innovate and capture additional market share.

Cyberthreats aren't going away anytime soon, and considering how much these breaches cost, cybersecurity providers will continue to grow their businesses. As a result, investors should ensure they have a segment of their portfolio devoted to this vital space.