Donald Trump’s administration has purchased access to a commercial database which it is using to detect undocumented immigrants and others entering the country illegally by tracking phone locations, according to a new report.

Federal agencies, including the Department of Homeland Security, Immigration and Customs Enforcement and Customs and Border Protection, bought access to the data which has the capability of tracking the movement of millions of Americans, the Wall Street Journal reported on Friday.

The agencies were reportedly using the data as part of their wider efforts to implement the administration’s border and immigration policies — a move with potentially long-term consequences as officials increasingly modernise law enforcement systems across the country.

Sources told the newspaper that the data trove had been used both as an aid by DHS to identify immigrants who were arrested within the country and by CBP to monitor cellphone activity in suspicious locations across the US-Mexico border.

In one instance, officials reportedly used the data to track cellphones going through a secretive tunnel between the US and Mexico that was used by drug smugglers.

That tunnel, which was later discovered by immigration officials, ended inside a closed KFC restaurant located near San Luis, Arizona, according to the report.

The newspaper reported that federal agencies can legally purchase access to the coveted data since it comes from a commercial vendor, the same way an advertising firm could buy access for business purposes.

It was acquired from apps which regularly track and store users' locations and are typically installed on many smart phones, including everything from games and weather to e-shopping apps.

Cellphone users must share their locations and give permission for those apps to use their data and include it in the commercial system. However, analysts say many users agree to those prerequisites while downloading an app without fully understanding how private companies can use their information.

The latest reporting was not the first to reveal federal officials using controversial tactics with technology to pursue the administration’s agenda.

A 2017 report published by The Detroit News showed local agents had been using a cell-site simulator known as a Stingray to surveil undocumented immigrants in the Detroit area.

ICE officials used the Stingray device to track down a local restaurant worker from El Salvador who lacked residential status in the US.

According to a congressional report, the Department of Homeland Security operates nearly 124 Stingray devices in total, and used an agency-wide search warrant in 2015 to begin deploying the devices.