The CNN Fear & Greed Index currently signals fear, suggesting investors are quite pessimistic about the outlook for the stock market. There are plenty of reasons for them to be worried, as high inflation and rising interest rates threaten to tip the U.S. economy into a recession. Those concerns sent the S&P 500 and the Nasdaq Composite tumbling into bear market territory, erasing more than $9 trillion in wealth in the process.

To be clear, investors often overreact -- both to bad news and to good. That insight led Warren Buffett to share this investing tip: "A simple rule dictates my buying: Be fearful when others are greedy, and be greedy when others are fearful." He wrote those words more than a decade ago as the stock market was descending into chaos during the Great Recession. Investors who followed Buffett's advice and bought during the more fear-dominated parts of that period likely did quite well in the years that followed.

Buffett's advice is just as relevant today. Fears about the direction of the economy drove the stock market down sharply, but that has left many high-quality stocks trading at discounted valuations. For patient long-term investors, this situation represents a buying opportunity. Two growth stocks -- Roku (ROKU 0.09%) and Cloudflare (NET 0.85%) -- look like particularly good bargains in this bear market.

1. Roku: The most popular streaming platform

Roku continued to reign supreme over the streaming industry in the second quarter. Its hardware (streaming media players and smart TVs) accounted for 23% of all global streaming devices, while Amazon ranked second with a market share of just 12%. Similarly, the Roku platform powered 31% of global streaming time, while Amazon ranked second with just 16%. Roku's ability to engage viewers makes it a valuable partner for both content publishers and advertisers.  

The company hopes to further cement its leadership with The Roku Channel, an ad-supported streaming service featuring free movies, TV shows, and live linear channels for news and sports. To drive viewership, the company has added dozens of original titles to The Roku Channel in the past year, and that tactic seems to be paying off. In the second quarter, The Roku Channel once again ranked among the top five most-streamed channels on the platform in the U.S.

However, Roku has struggled a bit financially in this difficult economic environment. Its revenue rose by just 31% to $3 billion over the past year -- a big deceleration from 72% growth in the prior year -- as brands cut ad budgets in response to softening consumer demand and their own macroeconomic fears. Meanwhile, the company continued to invest heavily in its efforts to gain market share, which resulted in its trailing-12-month cash from operations declining by 66% to $73 million as of the end of the second quarter. Fortunately, those disappointing financial results stem from temporary headwinds. Inflation will eventually normalize, and Roku is well-positioned to regain its momentum when that happens.

Why? Roku dominates the connected TV (CTV) advertising market, and ad spend in that segment in the U.S. alone should increase by 20% per year to reach $39 billion by 2026, according to a forecast by eMarketer. But Roku CEO Anthony Wood says all TV ads will eventually be streamed, and according to the market researchers at IMARC Group, global TV ad spend will total $344 billion in 2026. In short, Roku has hardly scratched the surface of its addressable market.

With that in mind, Roku stock currently trades at 2.3 times sales -- its cheapest valuation by that metric since it went public in 2017. That creates an attractive buying opportunity for investors.

2. Cloudflare: A key enabler of digital transformation

Cloudflare is on a mission to make the internet faster. Its global network offers tremendous capacity, and it has data centers sitting within 50 milliseconds of 95% of internet users worldwide, meaning it can move a lot of data to those users fast. Building on that competitive edge, Cloudflare offers a range of cloud services that accelerate and secure corporate resources such as websites and applications.

Of particular note, Cloudflare One is a secure access service edge (SASE) product designed to modernize corporate network architecture. Traditionally, organizations have protected their sensitive data and applications by routing all traffic related to them through central corporate hubs, where security policies were enforced and threats were blocked. But that approach was costly, both in terms of hardware and IT labor.

Cloudflare One does away with that model, allowing customers to provision network connectivity and security through the internet, meaning they avoid the cost and complexity of managing network hardware on site. With Cloudflare One, traffic is routed through Cloudflare's network, where it is inspected and zero trust security policies are enforced, which makes it possible for employees to quickly and safely access corporate resources (or the open internet) from any device or location.

Of course, Cloudflare One is just one of many services in the company's portfolio, which also includes tools for cloud storage, application development, and content delivery. That range of offerings has helped set it on a lofty growth trajectory. In the past year, Cloudflare grew its customer base by 20%, and the average customer spent 26% more than in the year prior. In turn, revenue climbed 53% to $813 million, and the company generated $36 million in cash from operations. More importantly, investors have good reason to think that momentum will continue.

Looking ahead, the growing need for effective cybersecurity and the continued adoption of cloud computing should be tailwinds for Cloudflare. The company estimates that its addressable market will be $135 billion by 2024, and with shares trading at a price-to-sales ratio of 20.4 -- a big discount to the company's three-year average of 41.7 -- this growth stock is worth buying.