A crash while softhsm2-util --import rewrites token.object leaves it empty, and the token with every key in it unreadable
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 56/100
Línea de trabajo
Start in src/lib/object_store/ObjectFile.cpp at ObjectFile::writeAttributes and trace how file-backend writes persist token.object; the report reproduces the failure by killing the write after truncation. Check existing tests for object-store writes and add coverage showing an interrupted rewrite leaves either the old or new content intact. Done when the token remains readable after an interrupted softhsm2-util --import rewrite.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
With the file backend, ObjectFile::writeAttributes truncates an object file and then writes it (src/lib/object_store/ObjectFile.cpp, unchanged on main at 9ad87341c9). softhsm2-util --import rewrites the token's own token.object this way. If the process is killed between the truncation and the write, token.object is left at 0 bytes, and the token disappears from its slot. The keys already in it are lost with it: their object files are still on disk, but token.object held the SO and user PIN blobs SoftHSM unwraps their key from.
To reproduce (SoftHSM 2.6.1, Debian 13 arm64):
export SOFTHSM2_CONF=$PWD/softhsm2.conf
mkdir tokens
printf 'directories.tokendir = %s/tokens\nobjectstore.backend = file\n' "$PWD" > softhsm2.conf
softhsm2-util --init-token --free --label t --pin 1234 --so-pin 5678
openssl genpkey -algorithm RSA -out k1.pem; openssl genpkey -algorithm RSA -out k2.pem
softhsm2-util --import k1.pem --token t --pin 1234 --label k1 --id 01
tok=$(ls -d tokens/*/)
strace -f -qq -P "$PWD/${tok}token.object" -e inject=write:signal=KILL \
softhsm2-util --import k2.pem --token t --pin 1234 --label k2 --id 02
ls -l "$tok"; softhsm2-util --show-slots
strace shows ftruncate(3, 0) on token.object and the kill at the write that follows. Afterwards token.object is 0 bytes, --show-slots lists the slot with an empty label, and pkcs11-tool --token-label t --login --pin 1234 --list-objects answers No slot with token named "t" found, while k1's object file is still in the directory.
Expected: token.object holds its old content or its new content.
Found with Sideeye, a personal open-source tool, no commercial interest; say if you would rather not have such reports. Not measured: power loss, the database backend, and which other operations rewrite token.object.
- Lenguaje dominante
- C++
- Estrellas
- 1.1k
- Forks
- 434
- Merge medio
- 12 d 14 h
- PR fusionados (30 d)
- 2
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 softhsm/SoftHSMv2
-
C_DigestKey digests a sensitive EC private key's CKA_VALUE: no check that the object is a secret keyAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 57/100
Todos los issues de softhsm/SoftHSMv2
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
ROCm/rocm-systems#15475 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
Sendspin/sendspin-cpp#257 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
pocoproject/poco#5664 ·
Los mantenedores suelen responder en 2 días
-
community:good-first-issue kind:bug kind:test scope:control status:needs-triage vehicle:rover
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
PX4/PX4-Autopilot#29727 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día