Skip to content

Hold UpdateFilter authentication state per session#6329

Merged
dkayiwa merged 1 commit into
openmrs:masterfrom
dkayiwa:security/updatefilter-per-session-auth
Jul 20, 2026
Merged

Hold UpdateFilter authentication state per session#6329
dkayiwa merged 1 commit into
openmrs:masterfrom
dkayiwa:security/updatefilter-per-session-auth

Conversation

@dkayiwa

@dkayiwa dkayiwa commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

UpdateFilter.authenticatedSuccessfully was a private volatile boolean instance field on the singleton filter. On the database-update wizard, step one sets it true after a super user authenticates, and step two (reviewchanges.vm, which launches the update) gates only on if (!authenticatedSuccessfully). Because the flag is global to the filter instance rather than per-session, once any super user authenticates, a concurrent unauthenticated request can POST directly to the review-changes step and run the pending schema updates on the strength of the other user's login.

The window is narrow (only while DB updates are pending after a platform upgrade), but it is a real global-authentication-state reuse.

Fix

Store the authenticated flag in the HttpSession (AUTHENTICATED_SUCCESSFULLY attribute) instead of on the filter instance, so each session must authenticate for itself. The shared update-in-progress state (isDatabaseUpdateInProgress, updateJob) stays global on purpose, so multiple authenticated super users can still watch a single running update.

Tests

  • Updated the E2E helpers to session scope and made resetRequest() carry the session forward (a follow-up request represents the same client).
  • Added reviewChangesPage_shouldNotReuseAnotherSessionsAuthentication: one session authenticates, a second unauthenticated session posting to review-changes is bounced back to the maintenance page. All 33 UpdateFilter tests pass.

Addresses GHSA-5cxm-f3p9-h63q.

UpdateFilter.authenticatedSuccessfully was an instance field on the
singleton filter, so once any super user authenticated at the first step
of the database-update wizard the flag stayed true for everyone. A
concurrent unauthenticated request could then POST straight to the
review-changes step and run the pending database updates on the strength
of another user's login.

Move the authenticated flag into the HttpSession so each session must
authenticate for itself. The shared update-in-progress state is left
global on purpose so multiple super users can still watch one running
update. Updates the E2E helpers to session scope, makes resetRequest carry
the session forward (a follow-up request is the same client), and adds a
regression test that a second session cannot reuse another session's
authentication.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.46%. Comparing base (d8fe136) to head (f0027d6).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6329      +/-   ##
============================================
- Coverage     59.47%   59.46%   -0.02%     
- Complexity     9541     9542       +1     
============================================
  Files           731      731              
  Lines         38323    38322       -1     
  Branches       5587     5587              
============================================
- Hits          22794    22788       -6     
- Misses        13489    13491       +2     
- Partials       2040     2043       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkayiwa
dkayiwa merged commit b13fb5e into openmrs:master Jul 20, 2026
12 checks passed
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.

3 participants