Security contractors recently discovered pre-installed software in some Android phones that secretly sends all the user's text messages to China every 72 hours, The New York Times reported.

Kryptowire, the security firm that discovered the clandestine feature, said the software was written by the China's Shanghai Adups Technology Company. The software monitors where users go, whom they talk to and what they write in text messages, as well as transmitting the full contents of contact lists and other data.

It is unclear if this was done as an attempt to gain information for advertising purposes or a Chinese government effort to collect intelligence.

However, it was apparently carried out by design and was not a bug, and offers a frightening example of how companies can manipulate technology to compromise privacy and monitor cellphone behavior, The Times reported.

It is not clear how users can determine whether their phones are vulnerable, as Adups has not published a list of affected phones.

Kryptowire, which says it discovered the problem through a combination of chance and curiosity, informed the U.S. government of its findings.

The Department of Homeland Security said it was recently made aware of the matter and "is working with our public and private sector partners to identify appropriate mitigation strategies."

During the election campaign, President-elect Donald Trump cited cyberattacks from foreign governments such as China as one of the U.S.'s most critical national security concerns, saying the Chinese are clandestinely learning everything about America.

China has long said it has the right to control and censor online content, the Daily Mail reported, noting that earlier this month, Beijing passed a controversial cybersecurity bill, tightening restrictions on online freedom of speech.

The legislation also imposes new rules on online service providers, raising concerns that China is further insulating its heavily controlled internet.