Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
omi-gitlab.e-technik.uni-ulm.de/bwnetflow/ip_prefix_trie
This module is intended for matching IP addresses to arbitrary prefix networks. This is done using a classic prefix tree (or trie) which stores data at all nodes within an existing IP network prefix. This module supports both, IPv6 and legacy IPv4. Separate trees have to be kept for each protocol, of course. See the following example using an integer, which might represent a customer ID:
v6_trie.Insert(123, []string{"2001:db8:1234::/48"})
ip, _, _ := net.ParseCIDR("2001:db8:1234::7/64")
matched_id := v6_trie.Lookup(ip)
More examples can be seen in the test cases. This is currently in use to match Netflow data to customer IDs which are used for billing on a specific upstream link.
This module implements a standard trie, which operates on 0 and 1 for branching. Some care is taken to implement longest prefix matching (i.e. matching the most specific network) correctly. The Lookup method remembers the current most specific prefix while descending. The code is thoroughly commented, go take a look.
Wikipedia has some more details on tries in general.
Benchmark results from my Laptop, so you don't have to run them yourself:
> go test -bench=. -test.benchtime=10s
goos: linux
goarch: amd64
pkg: ip_prefix_trie
BenchmarkIPv4LookupHit-8 200000000 81.1 ns/op
BenchmarkIPv6LookupHit-8 100000000 140 ns/op
BenchmarkIPv4LookupPropableMiss-8 200000000 65.1 ns/op
BenchmarkIPv6LookupPropableMiss-8 100000000 107 ns/op
PASS
ok ip_prefix_trie 68.719s
In a real environment looking up customer IDs, you can expect lookups within 1us (99th percentile) at about 10k lookups per second using two trees (v6 and v4) simultaneously. They'll take 600ns on average. Perhaps above benchmark setup is not very realistic.
FAQs
Unknown package
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.