Skip to content

fix(federation): replace strcmp token oracle with hash-based comparison in requestSharedSecret#41579

Open
DeepDiver1975 wants to merge 2 commits into
masterfrom
security/fix-federation-token-oracle
Open

fix(federation): replace strcmp token oracle with hash-based comparison in requestSharedSecret#41579
DeepDiver1975 wants to merge 2 commits into
masterfrom
security/fix-federation-token-oracle

Conversation

@DeepDiver1975
Copy link
Copy Markdown
Member

Summary

  • requestSharedSecret (@PublicPage, unauthenticated) used strcmp($localToken, $submitted) to decide 403 vs 200, leaking token ordering to any caller
  • Binary search converges on the exact 16-char stored token in ~96 requests; token can then be replayed to getSharedSecret to steal the federation shared secret
  • Fix: compare SHA-256 hashes instead — ordering is preserved (tiebreaking still works) but responses are now independent of the plaintext token

Security Impact

High — unauthenticated callers can recover federation shared secrets when they know a trusted server URL

Test plan

  • New regression test testRequestSharedSecretNoOracleLeakage uses a token pair where old strcmp returns 403 but hash-based returns 200; fails without fix
  • Existing dataTestRequestSharedSecret updated with hash-ordered token pairs
  • Run make test TEST_PHP_SUITE=apps/federation

🤖 Generated with Claude Code

The requestSharedSecret endpoint (@publicpage, unauthenticated) used
strcmp() to compare the caller-supplied token against the stored local
token, returning 403 when localToken > submitted_token and 200 otherwise.
This binary oracle allows an attacker to binary-search the stored token
in ~96 requests and then use it to obtain the federation shared secret.

Replace strcmp($a, $b) with strcmp(hash("sha256",$a), hash("sha256",$b)).
The deterministic tiebreaking property is preserved while the response
reveals nothing about the plaintext token value.

Signed-off-by: Thomas Müller <thomas.mueller@owncloud.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@update-docs
Copy link
Copy Markdown

update-docs Bot commented Jun 5, 2026

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
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