Shares of Alphabet (GOOGL 1.42%) (GOOG 1.43%) trade below their median price-to-sales and price-to-earnings ratios over the last 10 years. As a result, many consider the stock undervalued compared to the many long-term growth opportunities it has. And the U.S. government is on the verge of either banning or forcing the sale of TikTok, potentially a significant benefit to Alphabet's YouTube segment.

However, before you invest in Alphabet, you should consider three risks that could derail its upside.

1. ChatGPT could disrupt Google Search

ChatGPT is a chatbot based on artificial intelligence (AI) developed by OpenAI and backed by Microsoft. It was released in late November 2022.

As one of the first AI technologies made available for public use, the service took the internet by storm. According to a report from the Swiss bank UBS, ChatGPT is the fastest-growing consumer app in history.

Shortly after OpenAI released ChatGPT, former Google executive Sridhar Ramaswamy, head of its ad team for five years, told Bloomberg that it could disrupt Google's business model. And Gmail creator Paul Buchheit said on Twitter: "Google may be only a year or two away from total disruption. AI will eliminate the Search Engine Result Page, which is where they make most of their money."

If ChatGPT does disrupt Google Search and Google Network's ad sales, it could imperil the source of 69% of Alphabet's revenue, according to 2022 results -- a devastating blow to the company.

2. The Justice Department lawsuit against Alphabet

On Jan. 24, the U.S. Justice Department announced it had filed a lawsuit in the Eastern District Court of Virginia against Google claiming it monopolizes key digital advertising technologies. In the complaint, the agency said, "This enforcement action marks the first monopolization case in approximately half a century in which the Department has sought damages for a civil antitrust violation."

Should Google lose this lawsuit, in addition to fines, the remedy could be anything from having to modify its business practices to -- in the worst-case scenario -- the government forcing it to divest parts of its online ad business.

Regardless of the outcome, this lawsuit is terrible news for Google. During The Trade Desk's fourth-quarter 2022 earnings call, CEO Jeff Green said that nothing good would come from the lawsuit for Google:

There is lots of people that are talking about breaking it up. There is lots of other potential outcomes. But I do believe that in any case, this will slow down Google. There is a 100% chance of that. 

The Trade Desk competes against Google in online advertising, and Green believes the lawsuit's eventual resolution will be a boon for his company and other online ad companies.

Alphabet shareholders should carefully follow this lawsuit. An adverse result could reduce Google's competitiveness and profitability in advertising.

3. Amazon's ad business is taking market share

In December 2022, Axios published an article that cited statistics from Insider Intelligence showing that Google's and Meta Platforms' (NASDAQ: META) market share added up to less than 50% for the first time in eight years. Both companies are losing market share to Amazon. The worst part is that analysts predict Amazon will keep taking market share from both companies.

Google might have a tough battle against Amazon in advertising, as an e-commerce marketplace is a natural vantage point for gaining first-party information about consumers' immediate buying needs. 

Third-party information has declined in importance because of Apple's iOS privacy initiatives, the prevalence of cookie blockers, and Google's initiative to phase out the cookies in Chrome by 2024. So first-party information has become exceedingly valuable.

And Amazon owns the most important and best first-party information: a data base filled with information about buyer intent. That's essential, since it eliminates guessing about which ads to show consumers, and it shows them only to people most likely to buy, yielding better results for advertisers.

Amazon ads cost less, too. For instance, e-commerce analytics firm Sellics released a report saying that Amazon ads cost 68% less than Google ads, 44% less than Facebook's ads, 79% less than Instagram's, and 13% less than Walmart's.

So in the long term, Amazon looks like a definite threat to breach Google's advertising moat and reduce margins in its valuable business.

Take a deep breath before buying

In the past, Alphabet was a no-brainer investment because it had built an unbreachable wall around its advertising profit margins -- even Warren Buffett has admired the success of its walled-garden approach. However, today cracks are forming in those walls.

If you are considering investing in the company today, it's time to take a deep breath and thoroughly research Alphabet's risks before putting hard-earned money into the stock.