
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
A high-performance JavaScript library for bit-level data manipulation with zero dependencies. Perfect for binary protocols, file formats, and low-level data operations.
BitPackedBuffer provides precise control over bit-level operations in JavaScript, supporting both big-endian and little-endian byte orders. Whether you're implementing a binary protocol, working with file formats, or handling low-level data, BitPackedBuffer is designed to meet your needs.
npm install bitpacked
import { BitPackedBuffer } from "bitpacked";
// Write mixed-width values
const buffer = new BitPackedBuffer()
.write.bits(5, 3) // Write value 5 using 3 bits
.write.bits(10, 4) // Write value 10 using 4 bits
.write.string("Hi") // Write a string
.alignToByte(); // Align to byte boundary
// Read them back
buffer.seek(0);
console.log(buffer.read.bits(3)); // → 5
console.log(buffer.read.bits(4)); // → 10
console.log(buffer.read.string(2)); // → "Hi"
// Create a little-endian buffer
const buffer = new BitPackedBuffer(null, "little");
// Write a 16-bit value
buffer.write.bits(1000, 16);
// Read it back
buffer.seek(0);
console.log(buffer.read.bits(16)); // → 1000
new BitPackedBuffer(
contents?: Uint8Array | Buffer,
endian?: 'big' | 'little'
)
Method | Description | Example |
---|---|---|
read.bits(count) | Read 1-32 bits | buffer.read.bits(5) |
read.bytes(count) | Read multiple bytes | buffer.read.bytes(4) |
read.string(length) | Read fixed-length string | buffer.read.string(10) |
read.cString() | Read null-terminated string | buffer.read.cString() |
read.int(bitCount) | Read signed integer | buffer.read.int(16) |
read.uint(bitCount) | Read unsigned integer | buffer.read.uint(16) |
Method | Description | Example |
---|---|---|
write.bits(value, count) | Write 1-32 bits | buffer.write.bits(42, 7) |
write.bytes(data) | Write byte array | buffer.write.bytes(bytes) |
write.string(str) | Write string | buffer.write.string("hello") |
write.cString(str) | Write null-terminated string | buffer.write.cString("hello") |
write.int(value, bitCount) | Write signed integer | buffer.write.int(-42, 16) |
write.uint(value, bitCount) | Write unsigned integer | buffer.write.uint(42, 16) |
Method | Description |
---|---|
seek(position) | Move to byte position |
skip(bytes) | Skip ahead bytes |
mark(name?) | Mark current position |
reset(name?) | Return to marked position |
alignToByte() | Align to byte boundary |
clear() | Reset buffer state |
getBuffer() | Get underlying buffer |
isComplete() | Check if all data read |
Peeking operations don't advance the buffer position. They contain the same methods as read
but return values without modifying the position.
Method | Description | Example |
---|---|---|
peek.bits(count) | Peek 1-32 bits | buffer.peek.bits(5) |
peek.bytes(count) | Peek multiple bytes | buffer.peek.bytes(4) |
peek.string(length) | Peek fixed-length string | buffer.peek.string(10) |
peek.cString() | Peek null-terminated string | buffer.peek.cString() |
peek.int(bitCount) | Peek signed integer | buffer.peek.int(16) |
peek.uint(bitCount) | Peek unsigned integer | buffer.peek.uint(16) |
BitPackedBuffer includes comprehensive error checking:
try {
buffer.read.bits(33); // Throws RangeError
} catch (error) {
console.error("Invalid bit count:", error.message);
}
mark()
/reset()
for temporary position changesContributions are welcome! Here's how you can help:
git checkout -b feature/amazing-feature
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
Please ensure your PR:
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by RedYetiDev
FAQs
A Bit-Packed Buffer
The npm package bitpacked receives a total of 0 weekly downloads. As such, bitpacked popularity was classified as not popular.
We found that bitpacked demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.