There is law that at least the ACLU doesn't much like that gives the Border Patrol additional powers within 100 miles of the border.

Here's the C & BP take on it https://help.cbp.gov/app/answers/det...-border-patrol

And here's the ACLU's https://www.aclu.org/other/constitut...le-border-zone