U.S. customs officials must have a reasonable justification before snatching your laptop at the border and scanning through all your files for incriminating data, a federal appeals court ruled today.

The Ninth Circuit Court of Appeals ruled that Homeland Security's border agents must have "reasonable suspicion" before they can legally conduct a forensics examination of laptops, mobile phones, camera memory cards, and so on.

Today's opinion (PDF) is a limited -- but hardly complete -- rejection of the Obama administration's claim that any American entering the country may have his or her electronic files minutely examined for evidence of criminal activity. Homeland Security has said the electronic border searches could detect terrorists, drug smugglers, and people violating "copyright or trademark laws."

CBS News

It's only a limited rejection because certain warrantless searches at the border remain permissible: The judges said that "a quick look" or "unintrusive search" of a laptop, such as asking its owner to turn it on and peruse open windows, is perfectly OK. In addition, the court indicated that previous criminal history qualifies as "reasonable suspicion" that justifies a complete forensics analysis.

In 2009, Homeland Security reiterated its view that it should have unchecked authority to seize electronic devices indefinitely, though supervisory approval is required if they're held for more than 15 days. The Justice Department defended this view in legal briefs before the Ninth Circuit, saying that the Fourth Amendment's privacy protections are so limited at the border that "reasonable suspicion" is unnecessary.

Here's an excerpt from the Ninth Circuit's en banc ruling:

The amount of private information carried by international travelers was traditionally circumscribed by the size of the traveler's luggage or automobile. That is no longer the case. Electronic devices are capable of storing warehouses full of information. The average 400-gigabyte laptop hard drive can store over 200 million pages -- the equivalent of five floors of a typical academic library. Even a car full of packed suitcases with sensitive documents cannot hold a candle to the sheer, and ever-increasing, capacity of digital storage. The nature of the contents of electronic devices differs from that of luggage as well. Laptop computers, iPads and the like are simultaneously offices and personal diaries. They contain the most intimate details of our lives: financial records, confidential business documents, medical records and private emails. This type of material implicates the Fourth Amendment's specific guarantee of the people's right to be secure in their "papers..." Electronic devices often retain sensitive and confidential information far beyond the perceived point of erasure, notably in the form of browsing histories and records of deleted files. This quality makes it impractical, if not impossible, for individuals to make meaningful decisions regarding what digital content to expose to the scrutiny that accompanies international travel. A person's digital life ought not be hijacked simply by crossing a border. When packing traditional luggage, one is accustomed to deciding what papers to take and what to leave behind. When carrying a laptop, tablet or other device, however, removing files unnecessary to an impending trip is an impractical solution given the volume and often intermingled nature of the files. It is also a time-consuming task that may not even effectively erase the files. International travelers certainly expect that their property will be searched at the border. What they do not expect is that, absent some particularized suspicion, agents will mine every last piece of data on their devices or deprive them of their most personal property for days (or perhaps weeks or even months, depending on how long the search takes). Such a thorough and detailed search of the most intimate details of one's life is a substantial intrusion upon personal privacy and dignity. We therefore hold that [a forensics exam requires] a showing of reasonable suspicion, a modest requirement in light of the Fourth Amendment.

Led by Judge Consuelo Callahan, some judges dissented, saying that the government should "be mostly free from the Fourth Amendment" and that the majority opinion creates an unworkable rule.

A second dissent written by Judge Milan Smith argues that flagging a traveler merely based on a decades-old conviction does not amount to "reasonable suspicion," saying: "The bottom line is that thousands of individuals -- many with decades-old convictions -- will now be forced to reconsider traveling to entire countries or even continents, or will need to leave all their electronic equipment behind, to avoid arousing a 'reasonable' suspicion."

Sen. Russ Feingold, a Wisconsin Democrat who lost his re-election bid, had introduced legislation that would require Homeland Security to demonstrate that it had reasonable suspicion of illegal activity before searching electronic devices carried by U.S. residents. To hold devices more than 24 hours, border agents would be required to prove probable cause and secure a warrant or court order.

In 2006, the Ninth Circuit Court of Appeals effectively blessed Homeland Security's practice, saying in a 3-0 ruling that border police may conduct random searches of laptops -- including extensive forensic analysis using the EnCase software -- without search warrants or probable cause. "Under the border search exception, the government may conduct routine searches of persons entering the United States without probable cause, reasonable suspicion, or a warrant," the three-judge panel ruled.

The current case arose out of an examination of a laptop owned by Howard Cotterman, who was driving home with his wife from a trip to Mexico. Customs agents performed a full forensics analysis of his laptop not because anything seemed amiss -- only because his name appeared in a database of sex offenders -- and found what they claimed was child pornography.