If you want to know how Jessica Cooke ended up on her back, screaming in pain as the barbs from a stun gun delivered incapacitating electricity into her body, there are several possible answers. You could say this indignity was caused by her own stubbornness, her refusal to comply with the seemingly arbitrary dictates of a Border Patrol agent who was detaining her for no apparent reason at an internal immigration checkpoint in upstate New York. Or you could blame the agent's insistence on obeisance to his authority, which led him to assault an unarmed 21-year-old woman who posed no threat to anyone. But the ultimate responsibility lies with the Supreme Court, which has invited this sort of confrontation by carving out a disturbing and dangerous exception to the Fourth Amendment.

On May 7, two days before she graduated from SUNY Canton with a degree in law enforcement leadership, Cooke was driving from Norfolk to her boyfriend's house in Ogdensburg when she was stopped by the Border Patrol on Route 37 in Waddington. That town sits just across the St. Lawrence River from Canada. Although Cooke had not crossed the border and did not plan to do so, she became subject to the Border Patrol's authority merely by driving on Route 37, thanks to a 1976 decision in which the Supreme Court said the government may randomly stop cars on "important roads leading away from the border" in an effort to catch illegal immigrants. In U.S. v. Martinez-Fuerte, the Court deemed this imposition "minimal," saying "all that is required of the vehicle's occupants is a response to a brief question or two and possibly the production of a document evidencing a right to be in the United States.'"

Cooke's experience, which she recorded with her cellphone, was rather different. After she was directed to a "secondary inspection area," a male agent who identified himself as a supervisor told her she would have to wait "a couple of minutes," because "we've got a K-9 coming." When she asked why she was being detained, he had no answer. Later the female Border Patrol agent who first interacted with her said Cooke seemed nervous—an all-purpose excuse for detaining someone, since people tend to be nervous when confronted by armed government agents. At this point Cooke had already identified herself as a U.S. citizen and presented her driver's license (which is the only form of ID that motorists are legally required to carry), so there was no rationale for holding her that had anything to do with immigration control.

That did not sit right with Cooke, who had studied law enforcement in college and had already applied for a job with the very agency that was now detaining her on mysterious grounds. "You guys have no reason to be holding me," she said. "Why am I being held?…You guys are holding me here against my will." Recognizing that the only point of summoning a K-9 was to justify searching her car, she asked, "Why do you want to get in my trunk when you have no right to?"

For a cop who wants to look in someone's trunk but is stymied by the Fourth Amendment's ban on "unreasonable searches and seizures," a dog can be very handy. A decade ago, the Supreme Court said police may walk drug-sniffing dogs around cars during routine traffic stops without any evidence of criminal activity. Last year the Court ruled that an alert by a drug-sniffing dog is enough by itself to provide probable cause for a vehicle search, even though there are lots of reasons (including a handler's deliberate or subconscious cues) why a dog might alert to a car that contains no contraband.

Last month the Court made this dog trick a little harder by ruling that police may not extend a traffic stop to facilitate a canine inspection in the absence of "reasonable suspicion" that the driver is involved in criminal activity. Perhaps cognizant of that decision, the male Border Patrol agent, who initially told Cooke "you're being detained," later said she was free to go, but she could not take her car. "You can leave," he said. "You can walk down the road right now….Your car's not going anywhere….I'll spike the tires."

Cooke understandably did not want to abandon her car and set off on foot, so she stuck around. The interaction escalated when she refused to comply with the agent's command to "stand over there":

Agent: I'm going to tell you one more time, and then I'm going to move you. Cooke: If you touch me, I will sue your ass. Do you understand me? Agent: Go for it. Cooke: Touch me then. Agent: Move over there. Cooke: Go ahead. Touch me. Agent: I'm telling you to move over there.

At this point the agent apparently grabbed Cooke, and soon she was lying on the ground, screaming. U.S. Customs and Border Protection (CBP), the Department of Homeland Security division that includes the Border Patrol, says the agent "deployed an electronic control device during the altercation."

While Cooke was rolling around on the ground, the agent repeatedly ordered her to "get on your stomach." Her response: "What the fuck is wrong with you?" Also this: "Are you fucking retarded?" And this: "You fucking Tased me, you asshole!" These rejoinders do not have quite the same emotional impact as "I can't breathe," especially since Cooke survived the incident. Still, she asks good questions.

Without speculating about what might be wrong with this particular agent, it seems safe to say there is something wrong with the situation in which he works. He has been empowered to stop cars at will, supposedly to enforce the immigration laws in the general vicinity of the border. But while he's at it, he is also enforcing the drug laws. "It's an immigration checkpoint," SUNY Buffalo law professor Rick Su noted in an interview with the local NPR station. "It really should be relatively nonintrusive. Ask questions about identification, about residency, and, as long as they are satisfied that there is no reasonable suspicion that there is an immigration violation, most people should be waved through. It should be a relatively quick check."

Except when, for whatever reason, an agent suspects a driver may have drugs in the car. As Su observed, Cooke's experience shows how CBP is "starting to use these checkpoints beyond their intended goal." This additional function of so-called immigration checkpoints is especially troubling in light of a 2000 decision in which the Supreme Court rejected drug interdiction as a rationale for randomly stopping cars. In City of Indianapolis v. Edmond, the Court said that city's police violated the Fourth Amendment when they set up checkpoints aimed at catching drug traffickers. "We have never approved a checkpoint program whose primary purpose was to detect evidence of ordinary criminal wrongdoing," the Court said. "Because the primary purpose of the Indianapolis narcotics checkpoint program is to uncover evidence of ordinary criminal wrongdoing, the program contravenes the Fourth Amendment."

But as long CBP says its main goal is intercepting illegal aliens rather than drugs, it can do essentially the same thing that the Court deemed unconstitutional in Indianapolis. CBP says "checkpoints deny major travel routes from the borders to smugglers intent on delivering people, drugs and other contraband to the interior of the United States and allow the Border Patrol to establish an important second layer of defense." Judging from the checkpoints' track record, finding drugs is, if anything, their main function, while immigration control is a secondary concern. In fiscal year 2013, The New York Times reports, the checkpoints accounted for 14 percent of marijuana seized near the borders with Mexico and Canada but only 2 percent of unauthorized immigrants apprehended.

The reach of this drug dragnet is vast. According to the American Civil Liberties Union, the Border Patrol "operates approximately 170 interior checkpoints throughout the country." Under current regulations, those checkpoints can be located anywhere within 100 miles of an "external boundary"—a zone that includes about two-thirds of the U.S. population.

Last fall, in a story about a "temporary" Border Patrol checkpoint near Arivaca, Arizona, that has been operating for more than seven years and is notorious for hassling local residents, The Arizona Republic noted complaints that agents "routinely expand the scope of their questions and searches far beyond what [the Supreme Court] envisioned." The ACLU argues that Border Patrol agents "routinely ignore or misunderstand the limits of their legal authority in the course of individual stops, resulting in violations of the constitutional rights of innocent people."

Although the rules governing searches and seizures are relaxed at Border Patrol checkpoints, certain restrictions still apply. In the absence of reasonable suspicion, drivers should be free to go once the reason for stopping them has been addressed. That is the rule for other kinds of traffic stops, and there is no obvious reason why a stop at a Border Patrol checkpoint should be any different in that respect. In fact, the Supreme Court in U.S. v. Martinez-Fuerte suggested a higher standard, saying "any further detention" beyond the time necessary to resolve immigration questions "must be based on consent or probable cause."

But courts are not necessarily prepared to enforce limits on the length of checkpoint stops. In February the U.S. Court of Appeals for the 5th Circuit passed up an opportunity to do so, declining to say whether detaining a driver for half an hour after he presented evidence of his citizenship violated the Fourth Amendment. That driver, like Cooke, antagonized Border Patrol agents by knowing and asserting his constitutional rights.

In any event, it is clear that "checkpoint searches are constitutional only if justified by consent or probable cause to search," as the Court reiterated in Martinez-Fuerte. Although the video of Cooke's encounter with the Border Patrol ends after her Tasing, she told the Watertown Daily Times that when the drug-sniffing dog finally arrived, it did not alert to her car. She said the agents looked in her trunk anyway. They found no contraband.

If Cooke's account is accurate, it is hard to see how the search could have been legal. But it is easy enough to claim a dog alerted even if it didn't, especially if there is no video record. And thanks to the Supreme Court, that claim is enough for a search to pass muster.

What about the use of force against Cooke, which certainly seems excessive given the circumstances? According to the Times, the government is considering assault charges—against her.

The is article originally appeared at Forbes.com.