Sitting comfortably? Then it's probably time to patch, as critical flaw uncovered in npm's netmask package

Are you local? Catastrophically local?

The widely used npm library netmask has a networking vulnerability arising from how it parses IP addresses with a leading zero, leaving an estimated 278,000 projects at risk.

Researchers Victor Viale, Sick Codes, Kelly Kaoudis, John Jackson, and Nick Sahler have disclosed a digital nasty, tracked as CVE-2021-28918, in the hugely widespread netmask npm package.

It's a handy bit of code used for parsing and comparing IP addresses, and the flaw lies in how it handles mixed-format IP addresses. Namely, what it does when there is a leading zero.

As an example, the IPv4 address is localhost. However, pop 0127.0.0.1 into a browser and that 0127 gets treated as octal and changed to its decimal equivalent, which is 87. Thus 0127.0.0.1 is actually

Unless one is using netmask, in which case the leading zero is simply stripped off and 0127 becomes 127, an address that, via netmask, looks like a private IP could be submitted, but is actually a public address (along with all the nefarious activity that might entail).

"Even worse, it goes the other way too!" exclaimed the researchers. Enter 0177.0.0.1 and, while a browser would treat it as an address in the 127 loopback range, netmask would again lose that leading zero and treat it as; a public rather than private address.

Everybody love pickles graphic

Trail of Bits security peeps emit tool to weaponize Python's insecure pickle files to hopefully now get everyone's attention


"For almost a decade," the researchers went on, "netmask has been incorrectly reading octal input data as a string; just stripping the 0 at the front and using the rest of the data as legitimate."

As for the vulnerability of those hundreds of thousands of projects, it depends on how netmask is being used.

The researchers estimated that the package is used in more than 278,000 projects and accounts for millions of downloads per week - although, to be fair, an awful lot of those will have been down to automated DevOps pipelines rather than actual humans clicking a button.

The node-netmask maintainer, Olivier Poitrey, was given kudos by the team for being "super responsive". The first patch arrived mere days after the 17 March notification date.

Affected users, and there are likely to be a lot, should upgrade to version 2.0.0 of the library.

The incident is a reminder that blithely relying on popular components is no guarantee that one will be immune from vulnerabilities.

Ax Sharma, security researcher at Sonatype, said such users "may not realise that they could be potentially vulnerable to anti-Server-Side Request Forgery (SSRF) bypasses or remote file inclusion (RFI) should they be purely relying on netmask for parsing IP addresses, without adding their own proper input sanitisation and normalisation checks.

"This highlights the need for proper input hygiene and never trusting input no matter the source. In this case, for example, the fixes... applied to netmask now take into account that IP addresses can also be provided in octal or hexadecimal formats, something users of netmask could also have implemented on their end as an extra precaution."

As the saying goes: Trust No One. ®

Similar topics

Other stories you might like

  • Experts: AI should be recognized as inventors in patent law
    Plus: Police release deepfake of murdered teen in cold case, and more

    In-brief Governments around the world should pass intellectual property laws that grant rights to AI systems, two academics at the University of New South Wales in Australia argued.

    Alexandra George, and Toby Walsh, professors of law and AI, respectively, believe failing to recognize machines as inventors could have long-lasting impacts on economies and societies. 

    "If courts and governments decide that AI-made inventions cannot be patented, the implications could be huge," they wrote in a comment article published in Nature. "Funders and businesses would be less incentivized to pursue useful research using AI inventors when a return on their investment could be limited. Society could miss out on the development of worthwhile and life-saving inventions."

    Continue reading
  • Declassified and released: More secret files on US govt's emergency doomsday powers
    Nuke incoming? Quick break out the plans for rationing, censorship, property seizures, and more

    More papers describing the orders and messages the US President can issue in the event of apocalyptic crises, such as a devastating nuclear attack, have been declassified and released for all to see.

    These government files are part of a larger collection of records that discuss the nature, reach, and use of secret Presidential Emergency Action Documents: these are executive orders, announcements, and statements to Congress that are all ready to sign and send out as soon as a doomsday scenario occurs. PEADs are supposed to give America's commander-in-chief immediate extraordinary powers to overcome extraordinary events.

    PEADs have never been declassified or revealed before. They remain hush-hush, and their exact details are not publicly known.

    Continue reading
  • Stolen university credentials up for sale by Russian crooks, FBI warns
    Forget dark-web souks, thousands of these are already being traded on public bazaars

    Russian crooks are selling network credentials and virtual private network access for a "multitude" of US universities and colleges on criminal marketplaces, according to the FBI.

    According to a warning issued on Thursday, these stolen credentials sell for thousands of dollars on both dark web and public internet forums, and could lead to subsequent cyberattacks against individual employees or the schools themselves.

    "The exposure of usernames and passwords can lead to brute force credential stuffing computer network attacks, whereby attackers attempt logins across various internet sites or exploit them for subsequent cyber attacks as criminal actors take advantage of users recycling the same credentials across multiple accounts, internet sites, and services," the Feds' alert [PDF] said.

    Continue reading

Biting the hand that feeds IT © 1998–2022