bcrypt: out-of-range rounds (Infinity, -Infinity, negative) pick a different cost than node bcrypt

Open Beginner friendly
#15,213 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, rust
Domain
security

Research direction

Start in crates/perry-ext-bcrypt/src/lib.rs at rounds_or_default, which every entry point (hash, hashSync, genSalt, genSaltSync) calls before generating a salt. Read how the current clamping turns out-of-range inputs into a cost, then compare with node [email protected]: Infinity and -Infinity should yield cost 4, and -5 should yield cost 31. Done when a salt generated from each input carries the same cost prefix as Node, checked with a test alongside the existing bcrypt tests.

Written by the indexing model from the issue text.

Description

area:stdlib effort:S impact:low parity type:bug

What happens

rounds_or_default in crates/perry-ext-bcrypt/src/lib.rs (shared by hash, hashSync, genSalt, genSaltSync) maps out-of-range cost values differently from node [email protected]:

rounds node [email protected] Perry
Infinity cost 4 cost 10
-Infinity cost 4 cost 10
-5 cost 31 cost 4

Expected

Perry derives the cost the same way node [email protected] does, so a salt generated from these inputs matches Node's cost prefix.

Found while fixing #15152 (PR #15205); measured against node [email protected].

Dominant language
Rust
Stars
4.9k
Forks
166
Avg merge
6h 59m
Merged PRs (30d)
955

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PerryTS/perry

All issues in PerryTS/perry

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.