The S&P 500 (^GSPC -0.39%) earlier this year fell from a record high into correction territory in just 22 days. The historical average is 75 days, according to UBS Wealth Management. That rapid drawdown reflects immense economic uncertainty surrounding the radical changes in U.S. trade policy under President Trump.

Dan Ives at Wedbush says cloud and software stocks like Alphabet (GOOGL -1.63%) (GOOG -1.63%) and CrowdStrike (CRWD -0.46%) could be the safest place to invest as Trump's trade war persists. That's because those companies primarily sell services rather than physical goods, and services are not subject to tariffs.

Readers should remember there is no such thing as a perfectly safe investment where the stock market is concerned. Shares of Alphabet and CrowdStrike could fall substantially if tariffs have a material impact on economic growth. But I do agree with Ives in principle: Cloud and software companies are theoretically better positioned.

Here's what investors should know about Alphabet and CrowdStrike.

1. Alphabet

Alphabet subsidiary Google has two important growth engines in digital advertising and cloud services. It is the largest ad tech company in the world because of popular web properties Google Search and YouTube. And despite losing share across the open internet, its search advertising market share is forecast to increase modestly through 2026 because of strength in generative artificial intelligence (AI), according to eMarketer

Meanwhile, Google is also the third largest public cloud behind Amazon and Microsoft. It collected 12% of infrastructure and platform services spending in Q4 2024, up from 11% in Q4 2023, according to Synergy Research. While unlikely to catch the leaders, Google could continue winning market share as demand for AI increases. Forrester Research recently recognized its leadership in AI foundation models and AI platforms.

Alphabet reported solid financial results in the first quarter, crushing estimates on the top and bottom lines. Revenue rose 12% to $90 billion on particularly strong sales growth in cloud services. Meanwhile, operating margin expanded 2 percentage points and GAAP earnings rose 49% to $2.81 per dilute share. CEO Sundar Pichai attributed the strong results to momentum with AI products across the advertising and cloud businesses.

Wall Street expects earnings to increase at 7% annually through 2026. That makes the current valuation of 18 times earnings look reasonable. But analysts are likely underestimating the company. I say that because ad tech and cloud spending are forecast to grow at 14% annually and 20% annually, respectively, through 2030. Additionally, Alphabet beat the consensus earnings estimate by an average of 14% in the last six quarters, according to LSEG.

Investors should feel comfortable buying a small position in this AI stock at its current price.

2. CrowdStrike

CrowdStrike specializes in cybersecurity. Its platform consolidates 30 software modules that address several end markets. The company is a leader in endpoint security, which focuses on protecting endpoint devices like desktops, laptops, and servers. But it also has a strong presence in other verticals, including cloud security, identity protection, and security information and event management (SIEM).

Beyond software, several analysts recently named CrowdStrike a leader in managed detection and response, a subscription service that lets companies supplement or completely outsource their security operations to trained professionals. That is relevant because demand for cybersecurity professionals exceeds supply by 4.8 million workers, which means many businesses are currently understaffed.

Importantly, CrowdStrike's leadership in endpoint security, coupled with its strong presence in other security end markets, affords the company an important competitive advantage: It has a tremendous amount of data. In fact, CEO George Kurtz says CrowdStrike has the "richest data" in the industry, which makes its AI models uniquely effective in stopping attacks.

Management gave disappointing guidance that implies earnings will decline 14% in the current fiscal year. But that reflects "one-time upfront investments" in areas like marketing and AI product development. The company expects returns on those investments in the second half of this year, and earnings should return to growth next year. Investors need to keep that in mind when the company reports financial results in the coming quarters.

Given the circumstances, it makes sense to consider the price-to-sales (PS) ratio rather than the price-to-earnings (PE) ratio. CrowdStrike shares currently trade at 27 times sales, a substantial premium to the three-year average of 21 times sales. That is very expensive. Investors with a time horizon of at least three to five years can buy a small position today, but I think it would be more prudent to wait for a cheaper price.