The U.S. government is warning to disable UPnP, a common networking feature, after bugs have left millions of hardware devices vulnerable to attacks by hackers and malware.

The Department of Homeland Security urged computer users on Tuesday to disable Universal Plug and Play (UPnP), a set of network protocols designed to support automatic discovery and service configuration.

The security bugs were initially brought to the attention of the government by computer security company Rapid7, in Boston, which released a report on the problem on Tuesday. The company said it discovered between 40 million and 50 million devices that were vulnerable to attack due to problems that the firm's researchers have identified with the UPnP standard.

According to Rapid7, the two most commonly used UPnP software libraries both contained remotely exploitable vulnerabilities. In the case of the Portable UPnP SDK, over 23 million IPs are vulnerable to remote code execution through a single UDP packet. The company identified over 6,900 product versions that were vulnerable through UPnP. This list encompasses over 1,500 vendors.

The vulnerabilities Rapid7 identified in the Portable UPnP SDK have been fixed as of version 1.6.18 (released today), but it will take a long time before each of the application and device vendors incorporate this patch into their products.

The flaws could allow hackers to access files, steal passwords, take full control over PCs as well as remotely access devices such as webcams, printers and security systems.

Rapid7 has released a free tool that can identify exposed UPnP endpoints in your network and flag which of those may remotely exploitable through recently discovered vulnerabilities.