Skip to content

onionreq: reject truncated XChaCha20 ciphertexts - #140

Open
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-onionreq-short-xchacha-ciphertext
Open

onionreq: reject truncated XChaCha20 ciphertexts#140
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-onionreq-short-xchacha-ciphertext

Conversation

@Ap4sh

@Ap4sh Ap4sh commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

summary

HopEncryption::decrypt_xchacha20() currently extracts the 24-byte nonce before checking the ciphertext length, while the existing check only requires the 16-byte authentication tag

inputs shorter than the nonce violate the std::span::subspan() precondition, and inputs between 24 and 39 bytes underflow the plaintext size

this validates the full nonce + tag minimum before slicing and keeps the legacy AES response fallback unchanged

tests

  • ./Build/tests/testAll "[onionreq]" --colour-mode none
  • valgrind --quiet --error-exitcode=99 --leak-check=full ./Build/tests/testAll "Onion request encryption" --colour-mode none
  • ./Build/tests/testAll --colour-mode none
  • ./Build/tests/testLogging --colour-mode none
  • ./utils/format.sh verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant