anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit 22089cd6a77323e95733da90d6e515e26a61cba1
parent ad00e002917b616326a198e2516d5dee2e6b4a03
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 29 Jul 2026 18:43:20 +0200

only let the newest challenge code be answered

Diffstat:
Msrc/stasis/do_verify_challenge_code.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/stasis/do_verify_challenge_code.c b/src/stasis/do_verify_challenge_code.c @@ -179,6 +179,11 @@ ANASTASIS_DB_do_verify_challenge_code ( " WHERE truth_uuid=$1" " AND code=$2" " AND retry_counter != 0;"); + /* Only the newest code is answerable. A truth can have several unexpired + codes at once, and without the LIMIT every one of them that does not + match burns a retry -- so a single wrong guess could exhaust the counter, + and even a correct answer cost retries for its siblings. This matches + what insert_challenge_code.c already assumes when it issues a code. */ PREPARE ("do_verify_challenge_code_select", "SELECT " " code" @@ -186,7 +191,9 @@ ANASTASIS_DB_do_verify_challenge_code ( " FROM anastasis_challengecode" " WHERE truth_uuid=$1" " AND expiration_date > $2" - " AND retry_counter != 0;"); + " AND retry_counter != 0" + " ORDER BY creation_date DESC" + " LIMIT 1;"); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, "do_verify_challenge_code_select", params,