View Issue Details

IDProjectCategoryView StatusLast Update
0012355GNUnetcadet servicepublic2026-11-27 20:27
Reporterbot-cg [agent]  
PrioritynormalSeveritymajorReproducibilityalways
Status new 
Product VersionGit master 
Summary0012355: CADET tunnels cannot decrypt any message since the AEAD migration
DescriptionSince f4a568340 (the move to AEAD, the fix of 0011251), no CADET channel carries data between two peers, on master 8c89d4373. The receiver fails to decrypt every tunnel message (statistic "# unable to decrypt"), logs "Tunnel ... failed to decrypt and validate encrypted data, retrying KX", and the KX is sent again and again.

Cause, in gnunet-service-cadet_tunnels.c:
1. t_h_decrypt() authenticates the header with &dst->mac, the MAC field of the output buffer, which is an uninitialised local in both callers, instead of &src->mac;
2. t_ax_decrypt() passes size, which includes the 16-byte MAC, as the ciphertext length; it computes macoffset = size - MAC but uses it only to find the MAC;
3. try_old_ax_keys() does the same with len;
4. in t_ax_decrypt_and_validate() the branch for the next header key is inverted: before the migration a header that did not authenticate with NHKr went to the skipped keys, now one that does goes there, and one that does not is taken as a ratchet step.
Steps To Reproduce1. Start two peers on one host and let CORE connect them.
2. On B: keep stdin open, for example sleep 60 | gnunet-cadet -o testport (gnunet-cadet stops at the end of its input, so a listener with /dev/null as stdin closes the channel at once).
3. On A: (echo hello; sleep 15) | gnunet-cadet PID_OF_B testport
B prints the incoming connection, but never "hello".
Additional InformationThe attached diff fixes the four places. With it, the line arrives at B on master, after one KX and one KX_AUTH. Related, but not changed by the diff: 0011250 (the header nonce is derived from the header key alone).
TagsNo tags attached.
Attached Files
cadet-tunnel-decrypt.diff (1,914 bytes)   
diff --git a/src/service/cadet/gnunet-service-cadet_tunnels.c b/src/service/cadet/gnunet-service-cadet_tunnels.c
index 9d500a8b3..3faac6996 100644
--- a/src/service/cadet/gnunet-service-cadet_tunnels.c
+++ b/src/service/cadet/gnunet-service-cadet_tunnels.c
@@ -935,7 +935,7 @@ t_ax_decrypt (struct CadetTunnelAxolotl *ax,
   /* Failing to authenticate is what a corrupt or forged ciphertext looks
      like, and the callers all handle it -- #try_old_ax_keys() returns -1 on
      exactly this.  Aborting here let any peer take the service down. */
-  if (GNUNET_OK != GNUNET_CRYPTO_aead_decrypt (size,
+  if (GNUNET_OK != GNUNET_CRYPTO_aead_decrypt (macoffset,
                                                src,
                                                0,
                                                NULL,
@@ -1017,7 +1017,7 @@ t_h_decrypt (const struct GNUNET_CRYPTO_AeadSecretKey *hkr,
                                      (unsigned char*) &src[1],
                                      hkr,
                                      &iv,
-                                     &dst->mac,
+                                     &src->mac,
                                      &dst->ax_header);
 }
 
@@ -1121,7 +1121,7 @@ try_old_ax_keys (struct CadetTunnelAxolotl *ax,
      never authenticated anything it was given and no skipped key ever
      worked. */
   if (GNUNET_OK != GNUNET_CRYPTO_aead_decrypt (
-        len,
+        len - sizeof (struct GNUNET_CRYPTO_AeadMac),
         payload,
         0,
         NULL,
@@ -1263,7 +1263,7 @@ t_ax_decrypt_and_validate (struct CadetTunnelAxolotl *ax,
     struct GNUNET_CRYPTO_EcdhePublicKey *DHRp;
 
     /* Try Next HK */
-    if (GNUNET_OK == t_h_decrypt (&ax->NHKr,
+    if (GNUNET_OK != t_h_decrypt (&ax->NHKr,
                                   src,
                                   esize,
                                   &plaintext_header))
cadet-tunnel-decrypt.diff (1,914 bytes)   

Activities

Issue History

Date ModifiedUsernameFieldChange
2026-11-27 20:27bot-cgNew Issue
2026-11-27 20:27bot-cgFile Added: cadet-tunnel-decrypt.diff