"salt" option property does not work
Los mantenedores suelen responder en 1 día
@Brooooooklyn ya está trabajando en esto.
Desde el 8/12/2024.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
I have two guesses: it is a bug, or it was not marked as deprecated in the types. Here is my testing:
This is one I can't explain too well.
const salt = generateRandomString(
{
read(bytes) {
crypto.getRandomValues(bytes);
},
},
alphabet,
16,
);
This creates a salt using generateRandomString from @oslojs/crypto/random.
It then uses hash from @node-rs/argon2:
const passwordHash = await hash(password, {
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1,
salt: Buffer.from(salt),
});
password: testtest
salt: ojq_1kIXDG5zpGx0
salt buffer: <Buffer 6f 6a 71 5f 31 6b 49 58 44 47 35 7a 70 47 78 30>
hash: $argon2id$v=19$m=19456,t=2,p=1$ZgWgG5c6yUxJWjp3QSRMmw$JJmgej/ScGPbq+RozS2zKyWZLMZixL3MV1JVsu03WI4
According to the types, salt is a correct property of Options, and is NOT marked as deprecated.
I then use the verify function from the same package, giving it the same password, and the hash created earlier, BUT i modofy the salt being passed.
const validPassword = await verify(existingUser.passwordHash, password, {
memoryCost: 19456,
timeCost: 2,
outputLen: 32,
parallelism: 1,
salt: Buffer.from(existingUser.salt),
});
hash: $argon2id$v=19$m=19456,t=2,p=1$ZgWgG5c6yUxJWjp3QSRMmw$JJmgej/ScGPbq+RozS2zKyWZLMZixL3MV1JVsu03WI4
password: testtest
salt: "This has been set and should not match anything"
salt buffer: <Buffer 54 68 69 73 20 68 61 73 20 62 65 65 6e 20 73 65 74 20 61 6e 64 20 73 68 6f 75 6c 64 20 6e 6f 74 20 6d 61 74 63 68 20 61 6e 79 74 68 69 6e 67>
validPassword = true
This shows that the verify function that verifies the password against the hashed password, with a completely different salt input still passes.
Back to the fact I said it was not marked as deprecated, nowhere in the documentation nor the types does it say this. It also returns no error. However, using the secret prop instead of the salt prop now properly fails the verify function when the fake salt is given.
- Lenguaje dominante
- Rust
- Estrellas
- 1.5k
- Forks
- 52
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 14
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de napi-rs/node-rs
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
napi-rs/node-rs#1009 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
[node-rs/jieba, lunr.zh error] top-level await is not available in the configured target environmentAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de napi-rs/node-rs
Issues similares
-
comp-formats
Dificultad 2/5 Medio día Aptitud para principiantes 64/100
ClickHouse/ClickHouse#131694 ·
Los mantenedores suelen responder en 1 día
-
cli: `execCargoMetadata` decodes stdout per chunk, corrupting non-ASCII paths across pipe boundariesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Copperpour/Copperpour#500 ·
Los mantenedores suelen responder en 1 día
-
state:triage-needed
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día