Skip to content

Commit 69250b6

Browse files
fix: allow booking submission from the booking page when embedded in an iframe
Booking::register ran a custom CSRF check that compared the submitted csrf_token field against the csrf_cookie value read from the request cookies. When the booking page is embedded in a cross-origin iframe, browsers do not send that cookie along with the POST (SameSite / third-party cookie restrictions), so the check failed with 'Security validation failed. Please refresh the page and try again.'. The booking/* URI is already excluded from the global CSRF protection, and Booking::register has its own rate limiting, CAPTCHA / ALTCHA verification (when enabled) and strict input validation, so the duplicate cookie-based check provided no additional security while breaking iframe embedding. Removed it.
1 parent 087e0b8 commit 69250b6

2 files changed

Lines changed: 1 addition & 19 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ developers to maintain and readjust their custom modifications on the main proje
77

88
### Fixed
99

10+
- Submitting a booking from the public booking page no longer fails with "Security validation failed. Please refresh the page and try again." when the booking page is embedded in a cross-origin iframe
1011
- Changing the language from the public booking page no longer fails with "The action you have requested is not allowed" when the booking page is embedded in a cross-origin iframe
1112
- Public booking flow endpoints (registration, available hours, unavailable dates, booking confirmation, booking cancellation, CAPTCHA image, ALTCHA challenge, personal information deletion) now allow being embedded in an iframe, so the booking page works correctly on third-party websites
1213

application/controllers/Booking.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,6 @@ public function __construct()
8282
$this->load->library('jitsi_client');
8383
}
8484

85-
/**
86-
* Verify CSRF token for booking submissions.
87-
*
88-
* @throws RuntimeException If CSRF token is invalid.
89-
*/
90-
private function verify_csrf_token(): void
91-
{
92-
$csrf_token = request('csrf_token') ?? $this->input->get_request_header('X-CSRF');
93-
$csrf_cookie = $this->input->cookie('csrf_cookie');
94-
95-
if (empty($csrf_token) || empty($csrf_cookie) || !hash_equals($csrf_cookie, $csrf_token)) {
96-
log_message('error', 'Invalid CSRF token in booking request from IP: ' . $this->input->ip_address());
97-
throw new RuntimeException('Security validation failed. Please refresh the page and try again.');
98-
}
99-
}
100-
10185
/**
10286
* Render the booking page and display the selected appointment.
10387
*
@@ -374,9 +358,6 @@ public function register(): void
374358

375359
allow_iframe_embedding(); // Reached from the booking page which may be embedded in an iframe.
376360

377-
// Verify CSRF token for booking submissions
378-
$this->verify_csrf_token();
379-
380361
$disable_booking = setting('disable_booking');
381362

382363
if ($disable_booking) {

0 commit comments

Comments
 (0)