commit 9d36faaae6a8b1bcecc36686bbbacaedd532172c
parent 9969a86845d9706c80f8faa2f7a16836425fd5e7
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 29 Jul 2026 18:50:56 +0200
reject a policy lookup answered with a different version than requested
Diffstat:
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/src/restclient/anastasis_api_policy_lookup.c b/src/restclient/anastasis_api_policy_lookup.c
@@ -76,10 +76,22 @@ struct ANASTASIS_PolicyLookupOperation
struct ANASTASIS_AccountSignatureP account_sig;
/**
- * Version of the policy.
+ * Version of the policy, as claimed by the provider in the
+ * #ANASTASIS_HTTP_HEADER_POLICY_VERSION header.
*/
unsigned int version;
+ /**
+ * Version we asked for, or 0 if we asked for the latest one.
+ */
+ unsigned int requested_version;
+
+ /**
+ * True if we asked for a specific version, so that @e requested_version
+ * must match what the provider returns.
+ */
+ bool version_requested;
+
};
@@ -139,6 +151,21 @@ handle_policy_lookup_finished (void *cls,
dd.ec = -1; // FIXME: needs new code in Gana!
break;
}
+ if ( (plo->version_requested) &&
+ (plo->version != plo->requested_version) )
+ {
+ /* The version header is not covered by any signature, so a provider
+ can put whatever it likes there. We can at least insist that a
+ lookup for a specific version is answered with that version. */
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Provider claims version %u for a lookup of version %u\n",
+ plo->version,
+ plo->requested_version);
+ dd.http_status = 0;
+ dd.ec = -1; // FIXME: needs new code in Gana!
+ break;
+ }
/* Success, call callback with all details! */
dd.details.ok.sig = plo->account_sig;
dd.details.ok.curr_policy_hash = usp.new_recovery_data_hash;
@@ -332,6 +359,8 @@ ANASTASIS_policy_lookup_version (
"policy/%s",
acc_pub_str);
GNUNET_free (acc_pub_str);
+ plo->requested_version = version;
+ plo->version_requested = true;
GNUNET_snprintf (version_s,
sizeof (version_s),
"%u",