Repository navigation
Conversation
Since nextcloud#64582 the IApacheBackend login path calls completeLogin() with regenerateSessionId: false and binds the freshly created session token to the pre-authentication session id. This removed the only session id regeneration on this path, so a session id that existed before authentication survives into the authenticated session (session fixation). Regenerate the session id before creating the session token, so the token is bound to the fresh id and the login flow (token scope update, remember-me) keeps working unchanged. Signed-off-by: Jahn Kohlhas <jaykijay@users.noreply.github.com> Assisted-by: ClaudeCode:claude-mythos-5 Co-Authored-By: Claude Mythos 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The security-critical behavior lacks an automated regression test.
1 open finding
What changed in this PR
Prevents session fixation during Apache/SSO authentication by rotating the session ID before creating its authentication token.
Changes:
- Regenerates the pre-authentication session ID.
- Binds the new session token to the rotated ID.
| File | Description |
|---|---|
lib/private/legacy/OC_User.php |
Rotates the session ID before token creation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Regenerate the session id before binding the session token to it, so a | ||
| // pre-authentication session id cannot survive into the authenticated | ||
| // session (session fixation) | ||
| $userSession->getSession()->regenerateId(); |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |

Summary
Security-relevant fix (session fixation on the Apache/SSO login path).
Since #64582,
OC_User::loginWithApache()callscompleteLogin()withregenerateSessionId: falseand creates the session token beforecompleteLogin(), binding it to the pre-authentication session id. That removed the only session-id regeneration on theIApacheBackendpath: a session id that already existed before authentication (e.g. initialized by a prior visitor of the login page) survives into the authenticated session. Apache/SSO logins also skip 2FA by design, so a fixated session is fully authenticated.The reason #64582 disabled the regeneration is understandable: regenerating inside
completeLogin()would orphan the just-created session token (plainregenerateId()does not re-bind tokens). This PR instead regenerates the session id before the token is created, so the token is bound to the fresh id and the rest of the flow (token scope update for password-less backends, remember-me) is unaffected.How it was verified
IApacheBackendtest backend: a pre-authentication session id was re-emitted unchanged after SSO login and was authenticated when replayed.empty($password)token-scope update and remember-me cookie issuance keep working; repeated requests stay logged in.tests/lib/User/passes (143 tests, 716 assertions). No existing test coversloginWithApache(); happy to add a regression test if desired.Only master is affected (regression is not in stable33/34/35).
Checklist
Disclosure per the AI contribution policy: this change was prepared with AI assistance (Claude Code) and was reviewed, verified and submitted under the direction of the human contributor.
🤖 Generated with Claude Code