The S&P 500 climbed 15.9% in the first half of 2023, and history says the index -- widely regarded as a benchmark for the broader U.S. stock market -- will maintain its momentum in the second half of the year. Since 1950, when the S&P 500 rose at least 10% in the first half of any given year, it returned an average of 7.7% in the latter half.

That figure is significant because the S&P 500 is just 6% below its all-time high, meaning the index would be on the cusp of a new bull market. Of course, past performance is never a promise of future results, but with the S&P 500 inching toward bull-market territory, now might just be a good time to buy shares of Cloudflare (NET 1.58%) and HubSpot (HUBS 1.97%) -- no matter what happens in the second half of the year.

Here's why.

1. Cloudflare

Cloudflare provides a broad range of cloud computing services that accelerate and protect corporate infrastructure and applications while eliminating the need for costly on-premises hardware. Cloudflare has spent a good deal of time and money building a difficult-to-replicate network that shares a direct connection with every major internet service provider, cloud vendor, and enterprise.

So what? Its platform can deliver content to 95% of internet users within 50 milliseconds, making Cloudflare the fastest cloud provider on the planet. That unparalleled performance has led to strong demand -- about 20% of the web runs on Cloudflare -- and handling that traffic affords the company unique insight into performance issues and security threats across the internet. Those intangible assets helped Cloudflare earn a leadership position in several cloud verticals, including content delivery network software, edge development platforms, zero-trust network access (ZTNA), and web application firewalls.

Cloudflare reported solid results in the first quarter. Its customer count increased 13% and the average customer spent 17% more. In turn, revenue rose 37% to $290 million, non-GAAP operating margin improved to a record 6.7%, and the company generated positive free cash flow of $14 million, up from a loss of $36 million in the prior year.

Looking ahead, Cloudflare says its addressable market will reach $204 billion by 2026, and a large portion of that figure comes from ZTNA and developer services, two areas where the company already has a strong competitive foothold. Building on that, CEO Matthew Prince said its "win rate against the competition remained at record high levels" during the most recent quarter, illustrating its ability to execute amid a difficult economic environment.

In short, investors have good reason to be bullish on Cloudflare. Shares currently trade for 20.7 times sales -- not a cheap valuation by any means, but still a bargain compared to the three-year average of 41.6 times sales. At that price, it's worth buying a small position in this growth stock today.

2. HubSpot

HubSpot specializes in customer relationship management (CRM) software. Its platform comprises a suite of tools that boost productivity across sales, marketing, customer service, and operations. Its platform also includes solutions for content management and commerce. Those products help businesses attract leads, convert leads into paying customers, and delight those customers at every opportunity. In other words, HubSpot helps companies build and maintain lasting customer relationships, making its software relevant to virtually any organization.

Despite tough competition, HubSpot ranks among the most popular CRM platforms on the market, and the company owes that success to its focus on small and medium-sized businesses (SMBs). Whereas Salesforce and Microsoft tailor their products to larger enterprises, HubSpot targets SMBs with simple software, a freemium pricing model, and a broad partner ecosystem that streamlines adoption. That strategy has paid off in spades. In 2023, research company G2 crowned HubSpot the best global software seller in any category due to high user satisfaction scores and a strong market presence.

HubSpot makes a habit of delivering solid financial results, and that trend continued in the first quarter. Its customer count increased by 23% and average subscription revenue per customer rose by 3%. In turn, revenue popped 27% to $502 million and non-GAAP earnings climbed 122% to $1.20 per diluted share. Better yet, HubSpot's capacity for innovation should help it maintain that momentum in the future.

HubSpot's latest products use artificial intelligence (AI) to further boost productivity across departments like sales, marketing, and customer service. Content Assistant leans on AI to write content for blogs, websites, and marketing material, while ChatSpot.ai leans on AI to automate simple tasks in response to natural language commands. Those products have already garnered praise from industry experts. In fact, G2 recently recognized HubSpot as leader in AI sales assistant software.

Looking ahead, management says its addressable market will reach $72 billion by 2027, leaving plenty of room for growth. Yet shares trade for 14.7 times sales, a discount to the three-year average of 17.4 times sales. That is a reasonable price to pay for this growth stock given HubSpot's strong position in a large market.