President Donald Trump has called US intelligence agencies "naive" on Iran and also dismissed their assessment of the threat posed by North Korea.
"Be careful of Iran. Perhaps Intelligence should go back to school!" Mr Trump tweeted.
The testy response came after a US intelligence report said Iran was not making nuclear weapons.
It also said that North Korea remained "unlikely to give up" its weapons stockpiles and production abilities.
National intelligence director Dan Coats and other intelligence chiefs presented the Worldwide Threat Assessment report to the Senate on Tuesday.
Last year, the US pulled out of the 2015 Iran nuclear deal, triggering widespread criticism from Washington's allies.
Mr Trump also launched a diplomatic push to improve relations with North Korea, meeting the country's leader Kim Jong-un in Singapore last June to discuss denuclearisation of the Korean peninsula.
At the time, Mr Trump said this meeting had ended the North Korean nuclear threat — a claim questioned by a number of US politicians and experts.
The US intelligence report also warned that cyber threats from China and Russia were a growing concern, and both countries may be seeking to influence the 2020 US presidential elections.
TRUMP ON TEHRAN
In a series of tweets, Mr Trump said US intelligence officials "seem to be extremely passive and naive when it comes to the dangers of Iran. They are wrong!"
Iran, he continued, was "making trouble all over the Middle East, and beyond" in 2016, but had been "much different" since the US pullout from the "terrible" Iran nuclear deal.
However, Mr Trump warned that Tehran remained "a source of potential danger and conflict", referring to reported recent Iranian rocket tests.
At the Senate hearing, CIA director Gina Haspel said Iran was "technically... in compliance" with the nuclear deal, despite the US withdrawal and the imposition of stricter sanctions against Tehran.
However, the intelligence report warned that Iran's "regional ambitions and improved military capabilities" would probably threaten US interests in the future.
The president wrote that "time will tell what will happen with North Korea, but at the end of the previous administration, relationship was horrendous and very bad things were about to happen.
"Now a whole different story. I look forward to seeing Kim Jong Un shortly. Progress being made - big difference!"
The US intelligence report earlier concluded that North Korea was "unlikely to give up" its weapons stockpiles and production abilities while it tried to negotiate "partial denuclearisation steps to obtain key US and international concessions".
Having nuclear weapons was seen as "critical to regime survival", the report added.
In Singapore, Mr Trump and Mr Kim signed an agreement pledging to "work toward complete denuclearisation" - but there was no agreed pathway and little progress has been made since then on the issue.
It used to be that finding the tiniest gap between the statements of a political leader and his intelligence chiefs would make for front-page news.
Yet these days a gaping chasm between President Trump and the heads of his intelligence agencies has almost become a new normal.
The willingness of Donald Trump to attack intelligence assessments began after his election and before he took office, when the intelligence community at the tail end of the Obama administration produced an assessment that said Russia had interfered in the 2016 election.
Rather than see the legitimacy of his victory undermined, he targeted the credibility of the spies.
That trend has continued in office even with intelligence chiefs who now serve at his pleasure.
They have to tread a thorny path (easier walked together than alone) between being seen to maintain their integrity in telling "truth to power", and not risking the wrath of a president which in turn could undermine their work.
Is this the first time Trump has clashed with US intelligence bosses? No.
Last year, Mr Trump faced a barrage of criticism from both Democrats and Republicans after he defended Russia over claims it meddled in the 2016 US presidential elections.
US intelligence agencies concluded in 2016 that Russia was behind an effort to tip the scales of the US election against Hillary Clinton, with a state-authorised campaign of cyber attacks and fake news stories planted on social media.
But after face-to-face talks with Russian President Vladimir Putin in Helsinki in July 2018, Mr Trump said there had been no reason for Russia to interfere.
"President Putin says it's not Russia. I don't see any reason why it would be," Mr Trump told a news conference.
Just 24 hours later, the US president said he misspoke and should have said, "I don't see any reason why it wouldn't be" Russia.
US special counsel Robert Mueller is continuing his investigation into alleged Russian collusion in the 2016 US election.
President Trump has repeatedly described the investigation as a "witch-hunt".