Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@exodus/bintoken
Advanced tools
Readme
A bintoken is an encoded binary message of a fixed length, meant to serve as a message which can be signed. Depending on the type byte, and who signed the bintoken, the message may hold different meanings.
For example, if the type indicates the message is an authentication token, and the bintoken is signed by a server's private key, this might provide a guarantee that the server verified some information at the time indicated in the bintoken.
The encoding format of the token is specified in-advance by instantiating the BintokenEncoding
class exported by this package. The encoding is specified with property names and lengths for each property. The key names are sorted alphabetically when encoding and decoding bintokens.
The deterministic binary format simplifies signature verification. Its fixed length simplifies decoding & validation, and thus reduces the chance for malicious exploitation. Unlike with other formats such as JSON, there is only one way to encode a message within a bintoken encoding scheme.
Here is the generic serialization format of any bintoken encoding:
Here is an example of a bintoken encoding which encodes only a 32-byte public key as the payload:
const BintokenEncoding = require('@exodus/bintoken')
const tokenEncoding = new BintokenEncoding({ publicKey: 32, hash: 20 })
const token = tokenEncoding.toBuffer({
type: 1,
publicKey: randomBytes(32),
hash: randomBytes(20),
})
/*
// Erroneous use
const token = tokenEncoding.toBuffer({ type: 1, publicKey: randomBytes(32), hash: randomBytes(20), otherProp: Buffer.alloc(0) })
const token = tokenEncoding.toBuffer({ type: 1, publicKey: randomBytes(31), hash: randomBytes(20) })
const token = tokenEncoding.toBuffer({ type: 1, publicKey: 'foo', hash: randomBytes(20) })
const token = tokenEncoding.toBuffer({ type: 1 })
*/
const { type, time, publicKey, hash } = tokenEncoding.fromBuffer(token)
/*
// Error, wrong length
const { type, time, publicKey } = tokenEncoding.fromBuffer(
Buffer.concat([token, Buffer.alloc(1)])
)
*/
In this example, the serialization format is:
Notice that hash
is written before publicKey
in the payload, as the properties are sorted alphabetically before being written to, or read from, a bintoken. This means the keys you choose for your message must be the same for different applications using the same bintokens.
FAQs
Binary encoding of named fixed-length buffers.
The npm package @exodus/bintoken receives a total of 100 weekly downloads. As such, @exodus/bintoken popularity was classified as not popular.
We found that @exodus/bintoken demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 85 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.