Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@hookun/vlq
Advanced tools
A tool to encode/decode arbitrary unsigned integers using predefined-length chunk of bits.
A tool to encode/decode arbitrary unsigned integers using predefined-length chunk of bits.
import {encodeToArrayBuffer, decodeToArray} from '@hookhookun/vlq';
const data = [1, 2, 3, 4];
const encoded1 = encodeToArrayBuffer(data, 1);
console.info(Buffer.from(encoded1).toString('hex'));
// 073788
console.info(Buffer.from(encoded1).toString('base64url'));
// BzeI
console.info(decodeToArray(encoded1));
// [ 1, 2, 3, 4 ]
const encoded2 = encodeToArrayBuffer(data, 2);
console.info(Buffer.from(encoded1).toString('hex'));
// 129d10
console.info(Buffer.from(encoded1).toString('base64url'));
// Ep0Q
console.info(decodeToArray(encoded1));
// [ 1, 2, 3, 4 ]
npm install @hookun/vlq
Encoded = ChunkSize -> Data -> EndOfChunks
ChunkSize = Value(3,C-1)
Data = *Value(C,x)
EndOfChunks = SB(C,0)
Value(n,x) = *SB(n,x1) -> LSB(n,x0)
SB(n,x) = 1xxxxxxxxxxx
| <- n -> |
LSB(n,y) = 0yyyyyyyyyyy
The binary representation of ChunkSize
is 1 less than the actual value.
Value(1+n)
and EndOfChunks
(EOC
)Assume that ChunkSize is 1.
x | Value(1,x) |
---|---|
0 | 00 |
1 | 01 |
2 | 11 00 |
3 | 11 01 |
4 | 11 10 00 |
5 | 11 10 01 |
8 | 11 10 10 00 |
16 | 11 10 10 10 00 |
EOC | 10 |
Assume that ChunkSize is 2.
x | Value(2,x) |
---|---|
0 | 000 |
1 | 001 |
2 | 010 |
3 | 011 |
4 | 101 000 |
5 | 101 001 |
8 | 110 000 |
16 | 101 100 000 |
32 | 110 100 000 |
64 | 101 100 100 000 |
EOC | 100 |
Assume that ChunkSize is 3.
x | Value(3,x) |
---|---|
0 | 0000 |
1 | 0001 |
2 | 0010 |
3 | 0011 |
4 | 0100 |
8 | 1001 0000 |
16 | 1010 0000 |
32 | 1100 0000 |
64 | 1001 1000 0000 |
EOC | 1000 |
Encoded
Assume that Data is [1, 2, 3, 4]
ChunkSize is 1.
EndOfChunks = 10
Data = 01 11 00 11 01 11 10 00
ChunkSize = 0000
Encoded = 0000 01 11 00 11 01 11 10 00 10
= ChunkSize -> Data -> EndOfChunks
= 0000011100110111100010
= 0000 0111 0011 0111 1000 10(00)
= 0 7 3 7 8 8
= 0x073788
Assume that Data is [1, 2, 3, 4]
ChunkSize is 2.
EndOfChunks = 100
Data = 001 010 011 101 000
ChunkSize = 0001
Encoded = 0001 001 010 011 101 000 100
= ChunkSize -> Data -> EndOfChunks
= 0001001010011101000100
= 0001 0010 1001 1101 0001 00(00)
= 1 2 9 d 1 0
= 0x129d10
0x51450f2880
Encoded = 5 1 4 5 0 f 2 8 8 0
= 0101000101000101000011110010100010000000
^^^^| <- Data -> |
Since ChunkSize
is 5, divide Data
into (5+offset+flag bit)=(5+1+1)=7 bits each.
Data = 0001010 0010100 0011110 0101000 1000000 0
= 10 20 30 40 EOC
= [10, 20, 30, 40]
FAQs
A tool to encode/decode arbitrary unsigned integers using predefined-length chunk of bits.
The npm package @hookun/vlq receives a total of 2 weekly downloads. As such, @hookun/vlq popularity was classified as not popular.
We found that @hookun/vlq 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.