Elon Musk's controversial tweets about one of the Thai youth soccer team rescuers may have him in legal hot water.

Vernon Unsworth, a British cave explorer who was assisting in the rescue of a Thai youth soccer team trapped in a cave in July, is preparing a civil complaint for libel against Musk, according to a letter to Musk from Unsworth's attorney sent to CNBC. The letter is dated Aug. 6.

Musk blasted Unsworth on Twitter, calling him a "pedo guy" among other disparaging words, after Unsworth criticized his mini-submarine plan to help rescue the trapped team. The cave explorer told CNN in July that the mini-submarine Musk was constructing "had absolutely no chance of working."