Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A DNS Forwarder, with some interesting features.
$ npm i fwdns -g
$ fwdns -h
Usage: fwdns [options]
Options:
-h, --help output usage information
-V, --version output the version number
-p, --port [6666] Port to bind
-l, --listen [127.0.0.1] Address to listen
-z, --zone [8.8.8.8] Default zone, use system by default
-t, --timeout [5000] Timeout forwarding requests
--renew-timeout [3600] Timeout of auto renewal
-f, --forward-zone [/path/to/forward/zone.json] Forward zone setting, {"hosts": ["8.8.8.8"], "names": ["google.com"]}
-s, --local-zone [/path/to/local/zone.json] Local zone setting, {"abc.com": "127.0.0.1"}
It's a very rare edge case for using a DNS forwarder when there is over thousands of forward-zone settings. There is a fork of dnsmasq solving the similar problems, both dnsmasq and unbound's CPU reach 100% over 10K of zones.
With a pre-indexed map, we can archive less then 1ms for the query over 10K zones search, the algorithm is the same as this fork although in JavaScript, the implementation is much more easier. (but slower)
Here is some benchmark result compare to regular loop, (code):
EndsWithLoop#hit x 758 ops/sec ±1.93% (81 runs sampled)
RegExpLoop#hit x 90.88 ops/sec ±1.84% (66 runs sampled)
ReverseIndex#hit x 719,606 ops/sec ±1.02% (83 runs sampled)
EndsWithLoop#miss x 365 ops/sec ±1.26% (77 runs sampled)
RegExpLoop#miss x 114 ops/sec ±1.12% (69 runs sampled)
ReverseIndex#miss x 560,464 ops/sec ±0.91% (83 runs sampled)
All records that get from backends, will be cache in the memory and expire regards to the TTL, via node-cache.
Additionally, a auto renewal policy is added for better performance. When the item is added to the cache, the timer start to renew the result in the right time if possible, right time means 0.8 of TTL, and when the query is not being seen for an hour, give up the next renewal.
Sometimes the backend zones can be busy or the network maybe unstable for a while, we can waste some network and CPU resources to duplicate the request to different servers, and take the first response, this can be easily archive by async's race function.
Might be slightly slower then others at the first time or both hit cache due to JavaScript's performance.
But I think with the auto renewal and race query, this maybe faster then others in the most daily usages, from client's aspect.
The libraries this project depends to, are not being maintained for a while, there are some performance tweaks can be done.
For example, the packing processes of DNS packet in dnsd, gets improved to 3x faster due to commit:
- Original x 4,172 ops/sec ±1.49% (82 runs sampled)
+ indexOf & substring x 11,699 ops/sec ±1.06% (84 runs sampled)
+ Buffer.from x 11,663 ops/sec ±1.17% (81 runs sampled)
+ Body Buffer x 12,691 ops/sec ±1.11% (84 runs sampled)
FAQs
A DNS Forwarder
The npm package fwdns receives a total of 3 weekly downloads. As such, fwdns popularity was classified as not popular.
We found that fwdns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.