CBP are law enforcement officers with their power given to them by the Department of Homeland Security. They are legally allowed to do normal business to defend America's borders by policing territory within one hundred miles of America's border.
"A U.S. Customs and Border Protection (CBP) officer's border search authority is derived from federal statutes and regulations, including 19 C.F.R. 162.6, which states that, "All persons, baggage and merchandise arriving in the Customs territory of the United States from places outside thereof are liable to inspection by a CBP officer." Unless exempt by diplomatic status, all persons entering the United States, including U.S. citizens, are subject to examination and search by CBP officers."
However, it is weird to see Portland, Oregon have members of the CBP since that should be outside of their jurisdiction. In fact, Politico questions the constitutionality of the CBP being able to fly a drone to spot protestors around Minneapolis-St. Paul in May-June 2020:
"A few days earlier, on May 29, a CBP Predator Drone mysteriously appeared in the skies over Minneapolis-St. Paul to monitor protests in the Twin Cities."
"Once the government allows the establishment of a broad zone where constitutional protections do not apply, any meaningful distinction between the homeland and the borderland erodes, as recent events in Washington demonstrate. Minneapolis-St. Paul is located some 250 miles from the closest international border, yet somehow the CBP was able to position a drone above the city, in violation of the Justice Department’s 100-mile rule, with no apparent consequences."
However, that only applies to mostly landlocked city. Portland is a coastal city, so it would be within a 100 miles of international waters and still count as CBP territory. Also, the rules governing immigration officers are pretty vague under 8 U.S. Code § 1357 - Powers of immigration officers and employees:
§1357. Powers of immigration officers and employees
(a) Powers without warrant
Any officer or employee of the Service authorized under regulations prescribed by the Attorney General shall have power without warrant—
(1) to interrogate any alien or person believed to be an alien as to his right to be or to remain in the United States;
(2) to arrest any alien who in his presence or view is entering or attempting to enter the United States in violation of any law or regulation made in pursuance of law regulating the admission, exclusion, expulsion, or removal of aliens, or to arrest any alien in the United States, if he has reason to believe that the alien so arrested is in the United States in violation of any such law or regulation and is likely to escape before a warrant can be obtained for his arrest, but the alien arrested shall be taken without unnecessary delay for examination before an officer of the Service having authority to examine aliens as to their right to enter or remain in the United States;
(3) within a reasonable distance from any external boundary of the United States, to board and search for aliens any vessel within the territorial waters of the United States and any railway car, aircraft, conveyance, or vehicle, and within a distance of twenty-five miles from any such external boundary to have access to private lands, but not dwellings, for the purpose of patrolling the border to prevent the illegal entry of aliens into the United States;
(4) to make arrests for felonies which have been committed and which are cognizable under any law of the United States regulating the admission, exclusion, expulsion, or removal of aliens, if he has reason to believe that the person so arrested is guilty of such felony and if there is likelihood of the person escaping before a warrant can be obtained for his arrest, but the person arrested shall be taken without unnecessary delay before the nearest available officer empowered to commit persons charged with offenses against the laws of the United States; and
(5) to make arrests—
(A) for any offense against the United States, if the offense is committed in the officer's or employee's presence, or
(B) for any felony cognizable under the laws of the United States, if the officer or employee has reasonable grounds to believe that the person to be arrested has committed or is committing such a felony,
tl;dr: The law gives the CBP the right to police and arrest people within 100 miles of Canada's border or Mexico's border or any international border with the United States. This does apply to Portland, OR as a port city and is a good general fact to know. Based around the laws that give power to immigration officers, the Trump administration might be able to justify its actions by also claiming that the people they are arresting in the protest are likely to commit a crime and escape "before a warrant can be obtained for his [their] arrest". There can also be jusification if the regulation to arrest people in Portland was done under order by the Attorney General on behalf of the United States.
Under regulations prescribed by the Attorney General, an officer or employee of the Service may carry a firearm and may execute and serve any order, warrant, subpoena, summons, or other process issued under the authority of the United States. -8 U.S. Code § 1357
To clarify, I know that federal agents have the right to arrest a person anywhere, especially if they think a criminal will escape before the regular police get a warrant. This applies to the CBP. However, the 100 mile rule and/or an order from the Attorney General makes this an open and shut case: the CBP will be able to claim they were well within their rights to police Portland and utilize their full authority as both federal agents & customs officers.