A NASA scientist heading home to the U.S. said he was detained in January at a Houston airport, where Customs and Border Protection officers pressured him for access to his work phone and its potentially sensitive contents.

Last month, CBP agents checked the identification of passengers leaving a domestic flight at New York’s John F. Kennedy Airport during a search for an immigrant with a deportation order.

And in October, border agents seized phones and other work-related material from a Canadian photojournalist. They blocked him from entering the U.S. after he refused to unlock the phones, citing his obligation to protect his sources.

These and other recent incidents have revived confusion and alarm over what powers border officials actually have and, perhaps more importantly, how to know when they are overstepping their authority.

The unsettling fact is that border officials have long had broad powers — many people just don’t know about them. Border officials, for instance, have search powers that extend 100 air miles inland from any external boundary of the U.S. That means border agents can stop and question people at fixed checkpoints dozens of miles from U.S. borders. They can also pull over motorists whom they suspect of a crime as part of “roving” border patrol operations.

Sowing even more uneasiness, ambiguity around the agency’s search powers — especially over electronic devices — has persisted for years as courts nationwide address legal challenges raised by travelers, privacy advocates and civil-rights groups.

We’ve dug out answers about the current state-of-play when it comes to border searches, along with links to more detailed resources.

Doesn’t the Fourth Amendment protect us from “unreasonable searches and seizures”?

Yes. The Fourth Amendment to the Constitution articulates the “right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures.” However, those protections are lessened when entering the country at international terminals at airports, other ports of entry and subsequently any location that falls within 100 air miles of an external U.S. boundary.

How broad is Customs and Border Protection’s search authority?

According to federal statutes, regulations and court decisions, CBP officers have the authority to inspect, without a warrant, any person trying to gain entry into the country and their belongings. CBP can also question individuals about their citizenship or immigration status and ask for documents that prove admissibility into the country.

This blanket authority for warrantless, routine searches at a port of entry ends when CBP decides to undertake a more invasive procedure, such as a body cavity search. For these kinds of actions, the CBP official needs to have some level of suspicion that a particular person is engaged in illicit activity, not simply that the individual is trying to enter the U.S.

Does CBP’s search authority cover electronic devices like smartphones and laptops?

Yes. CBP refers to several statutes and regulations in justifying its authority to examine “computers, disks, drives, tapes, mobile phones and other communication devices, cameras, music and other media players, and any other electronic or digital devices.”

According to current CBP policy, officials should search electronic devices with a supervisor in the room, when feasible, and also in front of the person being questioned “unless there are national security, law enforcement, or other operational considerations” that take priority. For instance, if allowing a traveler to witness the search would reveal sensitive law enforcement techniques or compromise an investigation, “it may not be appropriate to allow the individual to be aware of or participate in a border search,” according to a 2009 privacy impact assessment by the Department of Homeland Security.

CBP says it can conduct these searches “with or without” specific suspicion that the person who possesses the items is involved in a crime.

With a supervisor’s sign-off, CBP officers can also seize an electronic device — or a copy of the information on the device — “for a brief, reasonable period of time to perform a thorough border search.” Such seizures typically shouldn’t exceed five days, although officers can apply for extensions in up to one-week increments, according to CBP policy. If a review of the device and its contents does not turn up probable cause for seizing it, CBP says it will destroy the copied information and return the device to its owner.

Can CBP really search my electronic devices without any specific suspicion that I might have committed a crime?

The Supreme Court has not directly ruled on this issue. However, a 2013 decision from the U.S. Court of Appeals for the Ninth Circuit — one level below the Supreme Court — provides some guidance on potential limits to CBP’s search authority.

In a majority decision, the court affirmed that cursory searches of laptops — such as having travelers turn their devices on and then examining their contents — does not require any specific suspicions about the travelers to justify them.

The court, however, raised the bar for a “forensic examination” of the devices, such as using “computer software to analyze a hard drive.” For these more powerful, intrusive and comprehensive searches, which could provide access to deleted files and search histories, password-protected information and other private details, border officials must have a “reasonable suspicion” of criminal activity — not just a hunch.

As it stands, the 2013 appeals court decision legally applies only to the nine Western states in the Ninth Circuit, including California, Arizona, Nevada, Oregon and Washington. It’s not clear whether CBP has taken the 2013 decision into account more broadly: The last time the agency publicly updated its policy for searching electronic devices was in 2009. CBP is currently reviewing that policy and there is “no specific timeline” for when an updated version might be announced, according to the agency.

“Laptop computers, iPads and the like are simultaneously offices and personal diaries. They contain the most intimate details of our lives,” the court’s decision said. “It is little comfort to assume that the government — for now — does not have the time or resources to seize and search the millions of devices that accompany the millions of travelers who cross our borders. It is the potential unfettered dragnet effect that is troublesome.”

During the 2016 fiscal year, CBP officials conducted 23,877 electronic media searches, a five-fold increase from the previous year. In both the 2015 and 2016 fiscal years, the agency processed more than 380 million arriving travelers.

Am I legally required to disclose the password for my electronic device or social media, if CBP asks for it?

That’s still an unsettled question, according to Liza Goitein, co-director of the Liberty and National Security Program at the Brennan Center for Justice. “Until it becomes clear that it’s illegal to do that, they’re going to continue to ask,” she said.

The Fifth Amendment says that no one shall be made to serve as “a witness against himself” in a criminal case. Lower courts, however, have produced differing decisions on how exactly the Fifth Amendment applies to the disclosure of passwords to electronic devices.

Former ‘Border Czar’ Gives Real Facts About Immigration

Alan Bersin says a border wall won’t address the real challenges confronting the U.S. border enforcement system: hopelessly understaffed immigration courts and lawlessness and poverty in Central America. Read the story.

Trump Invites Bids to Build Wall, Cites Importance of ‘Aesthetics’

It’ll cost $20 billion or more. Mexico will pay for it, or it won’t. Amid uncertainty, Trump clearly seems intent on making the border wall handsome. Read the story.

Customs officers have the statutory authority “to demand the assistance of any person in making any arrest, search, or seizure authorized by any law enforced or administered by customs officers, if such assistance may be necessary.” That statute has traditionally been invoked by immigration agents to enlist the help of local, state and other federal law enforcement agencies, according to Nathan Wessler, a staff attorney with the ACLU’s Speech, Privacy and Technology Project. Whether the statute also compels individuals being interrogated by border officials to divulge their passwords has not been directly addressed by a court, Wessler said.

Even with this legal uncertainty, CBP officials have broad leverage to induce travelers to share password information, especially when someone just wants to catch their flight, get home to family or be allowed to enter the country. “Failure to provide information to assist CBP may result in the detention and/or seizure of the electronic device,” according to a statement provided by CBP.

Travelers who refuse to give up passwords could also be detained for longer periods and have their bags searched more intrusively. Foreign visitors could be turned away at the border, and green card holders could be questioned and challenged about their continued legal status.

“People need to think about their own risks when they are deciding what to do. US citizens may be comfortable doing things that non-citizens aren’t, because of how CBP may react,” Wessler said.

What is some practical advice for protecting my digital information?

Consider which devices you absolutely need to travel with, and which ones you can leave at home. Setting a strong password and encrypting your devices are helpful in protecting your data, but you may still lose access to your devices for undefined periods should border officials decide to seize and examine their contents.

Another option is to leave all of your devices behind and carry a travel-only phone free of most personal information. However, even this approach carries risks. “We also flag the reality that if you go to extreme measures to protect your data at the border, that itself may raise suspicion with border agents,” according to Sophia Cope, a staff attorney at the Electronic Frontier Foundation. “It’s so hard to tell what a single border agent is going to do.”

The EFF has released an updated guide to data protection options here.

Does CBP recognize any exceptions to what it can examine on electronic devices?

If CBP officials want to search legal documents, attorney work product or information protected by attorney-client privilege, they may have to follow “special handling procedures,” according to agency policy. If there’s suspicion that the information includes evidence of a crime or otherwise relates to “the jurisdiction of CBP,” the border official must consult the CBP associate/assistant chief counsel before undertaking the search.

As for medical records and journalists’ notes, CBP says its officers will follow relevant federal laws and agency policies in handling them. When asked for more information on these procedures, an agency spokesperson said that CBP has “specific provisions” for dealing with this kind of information, but did not elaborate further. Questions that arise regarding these potentially sensitive materials can be handled by the CBP associate/assistant chief counsel, according to CBP policy. The agency also says that it will protect business or commercial information from “unauthorized disclosure.”

Am I entitled to a lawyer if I’m detained for further questioning by CBP?

No. According to a statement provided by CBP, “All international travelers arriving to the U.S. are subject to CBP processing, and travelers bear the burden of proof to establish that they are clearly eligible to enter the United States. Travelers are not entitled to representation during CBP administrative processing, such as primary and secondary inspection.”

Even so, some immigration lawyers recommend that travelers carry with them the number for a legal aid hotline or a specific lawyer who will be able to help them, should they get detained for further questioning at a port of entry.

“It is good practice to ask to speak to a lawyer,” said Paromita Shah, associate director at the National Immigration Project of the National Lawyers Guild. “We always encourage people to have a number where their attorney can be reached, so they can explain what is happening and their attorney can try to intervene. It’s definitely true that they may not be able to get into the actual space, but they can certainly intervene.”

Lawyers who fill out this form on behalf of a traveler headed into the United States might be allowed to advocate for that individual, although local practices can vary, according to Shah.

Can I record my interaction with CBP officials?

Individuals on public land are allowed to record and photograph CBP operations so long as their actions do not hinder traffic, according to CBP. However, the agency prohibits recording and photography in locations with special security and privacy concerns, including some parts of international airports and other secure port areas.

Does CBP’s power to stop and question people extend beyond the border and ports of entry?

Yes. Federal statutes and regulations empower CBP to conduct warrantless searches for people travelling illegally from another country in any “railway car, aircraft, conveyance, or vehicle” within 100 air miles from “any external boundary” of the country. About two-thirds of the U.S. population live in this zone, including the residents of New York City, Los Angeles, Chicago, Philadelphia and Houston, according to the ACLU.

As a result, CBP currently operates 35 checkpoints, where they can stop and question motorists traveling in the U.S. about their immigration status and make “quick observations of what is in plain view” in the vehicle without a warrant, according to the agency. Even at a checkpoint, however, border officials cannot search a vehicle’s contents or its occupants unless they have probable cause of wrongdoing, the agency says. Failing that, CBP officials can ask motorists to allow them to conduct a search, but travelers are not obligated to give consent.

When asked how many people were stopped at CBP checkpoints in recent years, as well as the proportion of those individuals detained for further scrutiny, CBP said they didn’t have the data “on hand” but that the number of people referred for secondary questioning was “minimum.” At the same time, the agency says that checkpoints “have proven to be highly effective tools in halting the flow of illegal traffic into the United States.”

Within 25 miles of any external boundary, CBP has the additional patrol power to enter onto private land, not including dwellings, without a warrant.

Where can CBP set up checkpoints?

CBP chooses checkpoint locations within the 100-mile zone that help “maximize border enforcement while minimizing effects on legitimate traffic,” the agency says.

At airports that fall within the 100-mile zone, CBP can also set up checkpoints next to airport security to screen domestic passengers who are trying to board their flights, according to Chris Rickerd, a policy counsel at the ACLU’s National Political Advocacy Department.

“When you fly out of an airport in the southwestern border, say McAllen, Brownsville or El Paso, you have Border Patrol standing beside TSA when they’re doing the checks for security. They ask you the same questions as when you’re at a checkpoint. ‘Are you a US citizen?’ They’re essentially doing a brief immigration inquiry in the airport because it’s part of the 100-mile zone,” Rickerd said. “I haven’t seen this at the northern border.”

Can CBP do anything outside of the 100-mile zone?

Yes. Many of CBP’s law enforcement and patrol activities, such as questioning individuals, collecting evidence and making arrests, are not subject to the 100-mile rule, the agency says. For instance, the geographical limit does not apply to stops in which border agents pull a vehicle over as part of a “roving patrol” and not a fixed checkpoint, according to Rickerd of the ACLU. In these scenarios, border agents need reasonable suspicion that an immigration violation or crime has occurred to justify the stop, Rickerd said. For stops outside the 100-mile zone, CBP agents must have probable cause of wrongdoing, the agency said.

The ACLU has sued the government multiple times for data on roving patrol and checkpoint stops. Based on an analysis of records released in response to one of those lawsuits, the ACLU found that CBP officials in Arizona failed “to record any stops that do not lead to an arrest, even when the stop results in a lengthy detention, search, and/or property damage.”

The lack of detailed and easily accessible data poses a challenge to those seeking to hold CBP accountable to its duties.

“On the one hand, we fight so hard for reasonable suspicion to actually exist rather than just the whim of an officer to stop someone, but on the other hand, it’s not a standard with a lot of teeth,” Rickerd said. “The courts would scrutinize it to see if there’s anything impermissible about what’s going on. But if we don’t have data, how do you figure that out?”