A Chinese soldier stands guard in front of Tiananmen Gate outside the Forbidden City in Beijing.

A possible trade war between China and the U.S. represents the biggest risk to the stock market's record rally, CNBC's Jim Cramer said Tuesday.

Cramer was commenting on a Wall Street Journal report published Tuesday that looked at the potential consequences of a U.S.-China trade war. The report also said global markets seemed unprepared for a U.S.-China clash and a battle could be a major 2018 spoiler.

President Donald Trump has suggested he would be more open to going easy on China if it were more aggressive in reining in North Korea.

The Journal notes that China's record annual trade surplus with the U.S. announced last week could be a catalyst for hostilities.

A trade war with China is "the number 1 risk and also the number 2 and number 3 risk" to the bull market, Cramer said on "Squawk on the Street." "It's very big because it affects everybody."

"Everybody has to cut numbers," Cramer added.

U.S. stocks have managed to produce strong gains since the start of the year. The Dow, S&P 500, and Nasdaq closed at all-time highs Friday. The Dow opened up more than 200 points higher Tuesday, breaking above 26,000 for the first time ever.