While there are narrow exceptions, the general rule is that a member of the media who receives leaked material that the media member did not solicit is free of legal liability.
On June 30, 1971, the Supreme Court decided, 6–3, that the government
failed to meet the heavy burden of proof required for prior restraint
injunction. The nine justices wrote nine opinions disagreeing on
significant, substantive matters.
Only a free and unrestrained press can effectively expose deception in government. And paramount among the responsibilities of a free
press is the duty to prevent any part of the government from deceiving
the people and sending them off to distant lands to die of foreign
fevers and foreign shot and shell.
— Justice Black's opinion in New York Times Co. v. United
States, 403 U.S. 713 (1971) (a.k.a. the Pentagon Papers
case).
(via the Pentagon Papers link).
There is also a non-binding Justice Department policy of not prosecuting reporters in connection with leaks of government information and of not trying to obtain information in their cases from reporters except in a few narrow kinds of cases.
As user6726 notes in another answer, this immunity from liability isn't absolute.
But protections from liability for reporters who do published leaked confidential government information is also much broader even than in most countries that have strong protections for freedom of the press.
Very few members of the media have been prosecuted successfully for leaking confidential information since this landmark 1971 ruling, although many government officials and members of the U.S. military have been successfully prosecuted and convicted for leaking confidential information to members of the media in the same time period.
The Related Issue Of A Reporter's Privilege
Closely related to this question is the issue of whether there should be a reporter's privilege (a.k.a. "shield laws") allowing them to not disclose their confidential sources which is recognized in some, but not all, U.S. jurisdictions.
Many reporters have been incarcerated for contempt of court for refusing to disclose their confidential sources, despite being compelled to disclosure this pursuant to a valid subpoena, in various U.S. jurisdictions when courts determine that the reporter lack a reporter's privilege.

The image is from the "reporter's privilege" link.
The federal courts haven't reached a perfect consensus on the issue in the wake of an ambiguous ruling on the question by the U.S. Supreme Court known as the Branzburg case was decided in 1972 with a fractured ruling on an only partially related issue.
in the decades since Branzburg was decided, most federal appellate
courts have recognized some form of a qualified privilege for
journalistic materials. The U.S. Courts of Appeal for the Seventh and
Eighth Circuits are the only circuits that have not yet definitively
done so. But the First, Second, Third, Fourth, Fifth, Sixth, Ninth,
Tenth, Eleventh, and D.C. Circuits have recognized a privilege in at
least some cases, derived from the First Amendment. And at least the
Third Circuit has also described the privilege as arising from federal
common law.