Skip to content

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Jun 27, 2024

Summary

The v3 ciphertext format (added in #23496) has never worked with an empty secret/password. However, the v3 implementation was added prior to the existence of the empty secret fallback code added in #31499.

While looking into #34012 I noted that the only reason the hash_hkdf() PHP ValueError is occurring is because the fallback is being attempted not only anytime the initial decrypt attempt fails, but also against newer ciphertext versions (where the fallback isn't relevant).

This PR adjusts the fallback logic to only run against <=2 versioned or non-versioned (which is even older) ciphertext.

Note: This does not fix the underlying cause of #34012 (which is probably in at least most cases a configuration problem), but it does:

  • clean-up the logic to avoid the PHP error
  • avoids doing the fallback on newer ciphertext where it's pointless (and most ciphertext is probably v3 at this point)

References:

TODO

  • Adjust the tests (since I also change one of the Exception strings)
  • Add a test (for the fallback; I don't believe there is one but need to double-check again)

Checklist

@joshtrichards
Copy link
Member Author

/backport to stable29

@joshtrichards
Copy link
Member Author

/backport to stable28

@joshtrichards joshtrichards added this to the Nextcloud 30 milestone Jun 27, 2024
$version = $parts[3];
}

if ((!empty($version) && $version <= '2') || empty($version)) { // only <3 versioned or old non-versioned ciphertext ever supported empty secrets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((!empty($version) && $version <= '2') || empty($version)) { // only <3 versioned or old non-versioned ciphertext ever supported empty secrets
if (empty($version) || $version <= '2') { // only <3 versioned or old non-versioned ciphertext ever supported empty secrets

Comment on lines -113 to -115
if ($partCount < 3 || $partCount > 4) {
throw new Exception('Authenticated ciphertext could not be decoded.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?
Should be added back.

This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv modified the milestones: Nextcloud 30, Nextcloud 31 Aug 14, 2024
@blizzz blizzz mentioned this pull request Jan 8, 2025
This was referenced Jan 14, 2025
This was referenced Jan 21, 2025
@blizzz blizzz mentioned this pull request Jan 29, 2025
1 task
@blizzz blizzz removed this from the Nextcloud 31 milestone Jan 29, 2025
@blizzz blizzz added this to the Nextcloud 32 milestone Jan 29, 2025
This was referenced Aug 22, 2025
This was referenced Sep 2, 2025
This was referenced Sep 25, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants