President Barack Obama seems to be of two minds when it comes to freedom of information and the role of the press. On his first day in office, he committed his administration to “creating an unprecedented level of openness in government,” and he proclaimed in a recent address that a free press is essential to democracy.

At the same time, Obama’s administration has conducted the most far-reaching campaign against leaks in recent memory, with twice as many prosecutions as in all previous administrations combined. While both of these ideas may be strongly held by the president, they are coming into conflict.

There has always been a delicate balance between secrecy and the public’s need to know what the government is doing and how decisions are reached. The volume of classified information has exploded in the digital age, and so has the number of people authorized to access it. The urge of government officials to talk about such matters — out of dissent, or just a desire to spin — remains undiminished. We are firm believers in maintaining this balance between secrecy and openness, but we worry that, in all the hysteria over leaks, it may tip too much to one side.

A discouraging sign came in the July 19 decision of the U.S. Court of Appeals for the 4th Circuit, which held that New York Times reporter James Risen had no privilege under the First Amendment that would allow him to refuse to testify about a confidential source in a leak investigation. Risen’s argument that he should not be compelled to testify in a case involving a former CIA official was supported by many news media organizations, including The Washington Post, and he has vowed to appeal the ruling.

If allowed to stand, the ruling could jeopardize the ability of reporters to protect the identity of sources, a vital tool for journalistic inquiry. As Judge Roger Gregory wrote in a dissent, “The public, of course, does not have a right to see all classified information held by our government. But public debate on American military and intelligence methods is a critical element of public oversight of our government. Protecting the reporters’ privilege ensures the informed public discussion of important moral, legal and strategic issues.”

The Risen case underscores the need to write into federal law a shield for the news media. Some 49 states and the District of Columbia have established media shield laws or recognized such privileges in court. A good place to start on the federal level is with legislation recently introduced by Sens. Charles E. Schumer, D-N.Y., and Lindsey O. Graham, R-S.C. While the proposed law would not offer absolute protection, it would introduce a “balancing test” for a court to use before compelling disclosure from a reporter. The test would take into account the public interest in the disclosure and in maintaining the free flow of information. This should restrain overzealous prosecutors from roping journalists into leak prosecutions and sustain the uneasy but essential balance between secrecy and openness.

The Washington Post (July 23)