Last March, in a speech he delivered at a gathering orchestrated by In-Q-Tel, the venture-capital incubator of the Central Intelligence Agency, David Petraeus, the Agency’s director, had occasion to ruminate on “the utter transparency of the digital world.” Contemporary spooks faced both challenges and opportunities in a universe of “big data,” but he had faith in the “diabolical creativity” of the wizards at Langley: “Our technical capabilities often exceed what you see in Tom Cruise movies.” In the digital environment of the twenty-first century, Petraeus announced, “We have to rethink our notions of identity and secrecy.”

For those of us who have been less bullish about the prospects of radical transparency, the serialized revelations that have unfolded since Friday—when Petraeus, who left the military as a four-star general, resigned from the C.I.A. because of an affair—are, to say the least, honeyed with irony. In the decade following September 11, 2001, the national-security establishment in this country devised a surveillance apparatus of genuinely diabolical creativity—a cross-hatch of legal and technical innovations that (in theory, at any rate) could furnish law enforcement and intelligence with a high-definition early-warning system on potential terror events. What it’s delivered, instead, is the tawdry, dismaying, and wildly entertaining spectacle that ensues when the national-security establishment inadvertently turns that surveillance apparatus on itself.

Of course, right now, the events and personages joined in a scandal that has already achieved an indelible Twitter moniker—#LovePentagon—are anything but transparent: we don’t yet know the name of the zealous, shirtless F.B.I. agent, or whether General John Allen sent thirty thousand pages of “inappropriate” e-mails to unpaid social liaison Jill Kelley, or merely several hundred “flirtatious” ones. But all this sordid laundry will come out soon enough, in part because of the Rottweiler tenacity of those of us in the press corps, but in part, also, because that is the nature of private affairs in a digital age. Eventually, they out—or, as Petraeus observed at the In-Q-Tel summit, “Every byte left behind reveals information.”

It would appear that Petraeus and his hagiographer-turned-running-mate-turned-mistress, Paula Broadwell, took precautions to avoid discovery of their relationship. They maintained multiple “alias” e-mail accounts and, according to the Associated Press, may have borrowed a bit of tradecraft from the Al Qaeda playbook—sharing an e-mail account, and saving messages for one another in a Draft folder, rather than running the risk of sending bytes across the ether.

But if we know that kind of subterfuge is being used by terrorists, then it’s almost axiomatically an inadequate counter-surveillance option. It’s not yet clear on precisely what legal authority the F.B.I. obtained access to Broadwell’s e-mail, but under the relevant federal statute, the Electronic Communications Privacy Act, the government need do little more than ask. Originally passed in 1986, the law is notoriously outdated, and considers any e-mail that is over a hundred and eighty days old to be “abandoned,” meaning that the author of the e-mail no longer has any reasonable expectation that it would remain private. So to obtain access to this e-mail, the F.B.I. doesn’t need a court order; it just needs to ask your e-mail provider. (To obtain more recent e-mail, authorities do need a warrant from a judge.) There is ample evidence that, in practice, this kind of broad authority has been abused. In a series of reports between 2007 and 2010, the F.B.I.’s inspector general has found that in seeking information from private communications providers, agents have often violated their own internal rules and guidelines, and have ensnared civilians who are only peripheral to their searches.

In this instance, the peripheral civilian was the director of the C.I.A. The picture of the F.B.I.’s investigation that emerges is one of a potential abuse of authority and conflict of interest, but also of a concept that would be quite familiar to Petraeus—mission creep. What began as a cyber-crime investigation, initiated at the behest of an F.B.I. agent who was a friend of Jill Kelley, morphs into a national-security investigation when it is discovered that Broadwell is the one sending menacing e-mails, and that she also happens to be consorting, sub-rosa, with America’s top spy. When the search moves on to Broadwell’s computer, what had become a national-security investigation regarding the security of Petraeus’s e-mail morphs once again, into an inquiry on the possible leaking of classified material. Meanwhile, just as the all-seeing eye of the national-security bureaucracy bore into Petraeus’s private affairs and turned up tawdry material, that same eye turns back on the F.B.I. agent who initiated the investigation and finds that he, too, is not without sin; that he has been sending photos of himself to Kelley; that he is reportedly “infatuated” with her and “obsessed” with the case.

One day in the summer of 2011, I logged on to Facebook to discover a little algorithmic suggestion that I become friends with Michael Hayden. This struck me as funny, because several years earlier I had written a book about the National Security Agency during Hayden’s tenure as its director, and his office had stonewalled my repeated requests for an interview. I clicked on his profile to see what was there, and found, to my surprise and delight, that Mike Hayden, former head of the N.S.A. and C.I.A., retired four-star Air Force general, had fallen behind on Facebook’s ever-shifting privacy settings, and that his Wall, his friends, and his photos were all sitting there for public examination. (Don’t bother looking—sometime between that day and when I checked this morning, Hayden seems to have gotten wise and hidden or taken down the page.)

“Machines in the nineteenth century learned to do, and those in the twentieth century learned to think at a rudimentary level,” Petraeus told the attendees at the In-Q-Tel event. “In the twenty-first century, they are learning to perceive—to actually sense and respond.” When all the lurid particulars have finally been extracted, the Love Pentagon scandal will be memorialized in Washington by “lessons learned” postmortems and “after action reports.” (This story is a mine-field of double-entendres.) Our bureaucrats will ponder the threshold at which the F.B.I. should inform Congress about the national-security implications of an investigation, the perils of the more extreme forms of access journalism, perhaps even the efficacy of the Vow of Monogamy enshrined in the Uniform Code of Military Justice. But our spymasters should give some thought as well to how it feels to be thoroughly and mercilessly laid bare at the hands of a legal and technological surveillance apparatus that is their own creation.

Photograph by Adam Ferguson/The New York Times/Redux.