8000 Fix checkout privilege escalation and user authorization vulnerabilities by Somya-03-hub · Pull Request #40 · aelassas/movinin · GitHub
[go: up one dir, main page]

Skip to content

Fix checkout privilege escalation and user authorization vulnerabilities - #40

Merged
aelassas merged 1 commit into
aelassas:mainfrom
Somya-03-hub:fix/security-privilege-escalation
Oct 24, 2026
Merged

aelassas merged 1 commit into
aelassas:mainfrom
Somya-03-hub:fix/security-privilege-escalation

Conversation

@Somya-03-hub
Copy link
Copy Markdown
Contributor

🔒 Security Fix: Checkout Privilege Escalation & User Authorization

📌 Summary

This PR fixes privilege escalation and broken authorization in checkout and user-management endpoints.

Previously, unauthenticated checkout could create accounts from client-supplied renter data, including privileged account fields. In addition, password and profile updates did not consistently restrict access based on the authenticated user’s role and relationship to the target account.


🚨 Problems & Root Cause

  1. Checkout role mass assignment: Checkout passed the entire client-supplied renter object to the User model. A client could submit a privileged account type or other security-sensitive fields.
  2. Agency access to Admin accounts: The update and changePassword authorization checks did not explicitly deny Agency access to Admin targets.
  3. Self-service password bypass: changePassword trusted the client-provided strict flag, allowing a user to skip current-password verification by sending strict: false.
  4. Lower-privilege security-field updates: The update handler allowed blacklisted changes without restricting them to Admins.

🛡️ Solution & Implementation Details

  • Checkout field allowlist: Checkout now constructs new renter accounts using only fullName, email, phone, birthDate, and language.
  • Server-controlled account state: Checkout-created accounts are always normal User accounts, with verification and blacklist state set by the server. Client-supplied role, agency, password, and other unapproved fields are not persisted.
  • Explicit target authorization: Users can update or change passwords only for themselves. Agencies can manage themselves and users assigned to their agency, but cannot operate on Admin accounts or unrelated users.
  • Current-password enforcement: Self-service password changes always require the correct current password, regardless of the supplied strict value.
  • Privileged updates restricted: Only Admins can change user type or blacklist status. Existing Admin update and administrative password-reset behavior is preserved.

🧪 Regression Tests Added

Added regression coverage in backend/__tests__/booking.test.ts and backend/__tests__/user.test.ts verifying that:

  • Legitimate checkout registration still works with the allowed renter fields.
  • Checkout submissions specifying Admin or Agency roles create normal User accounts.
  • Client-supplied security-sensitive fields do not override server-controlled account values.
  • Agencies cannot update Admin accounts or change their passwords.
  • Agencies can still manage assigned users.
  • Users cannot update another user’s account or change another user’s password.
  • strict: false cannot bypass current-password verification for self-service changes.
  • Lower-privileged users cannot change account type or blacklist status.
  • Supported Admin password-reset and account-update operations continue to work.

🔍 Verification & Test Results

  • Build: npm.cmd run build — passed.
  • Lint: ESLint on the four changed files — passed.
  • Focused security regressions: 7 tests passed.
  • Broader test runs: Some integration tests could not pass in the local environment because of unavailable/placeholder Stripe configuration; the full user test run also had an SMTP timeout. These failures were outside the focused security tests.

Closes #38

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aelassas
aelassas merged commit 95c0961 into aelassas:main Oct 24, 2026
1 check passed
aelassas added a commit that referenced this pull request Oct 24, 2026
aelassas added a commit that referenced this pull request Oct 24, 2026
aelassas added a commit that referenced this pull request Oct 24, 2026
aelassas added a commit that referenced this pull request Oct 24, 2026
fix(frontend): non autenticated pay later checkout success page broken
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.

Security: Privilege Escalation Allows Admin Account Creation and Agency-to-Admin Account Takeover

2 participants

0