PRETTY MUCH everyone can agree that Customs and Border Protection (CBP) agents should be able to freely search travelers’ bags at the border. Their job is to stop everything from illegal weapons to illicit drugs to invasive species from entering the country. But searching through every last email on your cellphone? That’s much less defensible.

Even so, CBP has the legal authority to thumb through every personal detail on Americans’ electronic devices without meeting any standard of suspicion, as though practically bottomless digital storage devices were the same as under-seat suitcases. This permissive regime applies only at the border; once inside the country, the Fourth Amendment demands that law enforcement officers get warrants for intrusive electronic searches. Border crossings, then, serve as front doors to the country and back doors into Americans’ private lives. Customs agents can gather and transmit private information to the FBI and others — or simply hassle people, as a variety of anecdotal accounts suggests — with little independent oversight.

Border agents are exploiting the loophole more and more. CBP reported Tuesday that officers conducted 14,993 electronic-device searches across 189,594,422 international arrivals in the first six months of fiscal 2017, up from 8,383 searches across 186,376,118 arrivals in the same period the previous year. To be clear: The 2017 surge in searches began before President Trump, advocate of “extreme vetting,” entered office, suggesting that the numbers might continue to grow from here.

Meanwhile, the courts are increasingly recognizing the obvious: Searching a phone is a lot more invasive than searching a wallet or a bag. Law enforcement officers used to face relatively few restrictions examining materials they found in, say, the pockets of someone they arrested. But recognizing that “today many of the more than 90% of American adults who own cell phones keep on their person a digital record of nearly every aspect of their lives,” the Supreme Court ruled in 2013 that officers could not search an arrestee’s cellphone without a warrant.

In time, courts might take a similar tack on electronic devices at the border. But Congress should not make Americans wait for judges to place sensible privacy protections on CBP. A bipartisan group of lawmakers last week introduced a bill that would require border agents to obtain a warrant before searching through U.S. travelers’ electronic devices and to inform detained Americans of their privacy rights. Officials could hold a suspect’s device until they got a warrant to search it, and there would be an exception to the rules in case of emergency.

Earlier congressional attempts to raise standards on the border were not quite as restrictive, so lawmakers might eventually settle on a lower standard. What’s clear is that they cannot leave the current system in place.