rs / rs/node-netmask

Improper Input Validation

Open
#50 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
253
Forks
43
PR merge metrics
No merged PRs in 30d

Description

  1. In the latest 2.0.2 there was a rewrite of the IP validation. Effectively, in version 2.0.2 the sanity check that IP components are < 0xFFFFFFFF has been removed, because >>> 0 always converts them to a 32-bit unsigned long.
    This can cause trouble, for example this "IP" actually checks out as belonging to the localhost block: "4294967423.0.0.1" (because mod 2^32 it is equal to 127.0.0.1).
    Although it's obviously an invalid IP, this has the potential to create shenanigans, because other libraries probably are not making the exact same mistake.

  2. Another input validation issue is the use of the ParseInt function for the mask parameter. For example two possible inputs that generate a nonsensical state:
    (a) Try weird = new Netmask('1.2.3.4', -1) , and then the state of the netmask object includes a bitmask <0, and size > 2^32 among other oddities. The next() operation has an uncaught error in this case.
    (b) Try weird2 = new Netmask('1.2.3.4', 0.1). The constructor succeeds, but the state is similarly funky.

Best regards,
Alon Navon,
Seal Security

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Netmask constructor and the next() operation described in the report, then trace the IP component and mask parsing paths. Use the reported oversized, negative, and fractional inputs as regression cases; done means these inputs are rejected or otherwise cannot leave the object in the invalid states described.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
networking, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.