WASHINGTON — Proponents of press freedom have praised a ruling last week by a federal judge who protected a writer from being forced to testify in court about his sources for a book on the Central Intelligence Agency. But her opinion included a little-noticed passage: a suggestion that many journalists could be charged with a felony.

In the opinion, released late on Wednesday, Judge Leonie M. Brinkema said prosecutors could not force the writer — James Risen, who is also a New York Times reporter — to testify about how he learned certain classified information for a book. But she also said that his unauthorized receipt of classified information might be a felony, an assertion that startled media law specialists.

Officials have sometimes threatened to prosecute journalists under the Espionage Act, the law Judge Brinkema cited. But there has never been a successful prosecution of a nongovernment employee for receiving and passing on government secrets, as opposed to leaking them.

Some legal scholars believe that it would be unconstitutional to apply the Espionage Act to reporters, although the Supreme Court has never ruled on the issue. The question also resonates with prosecutors’ exploration of whether it can prosecute the antisecrecy organization WikiLeaks for disseminating archives of leaked government documents.