Problem/Motivation

It was reported that the route /calendar/all/import is not protected against CSRF attacks and this could lead into Denial of Service attacks if the user makes a lot of requests to this route because it will run the calendar import functionality again and again, possibly crashing the site.

Steps to reproduce

You can see this vulnerability by:
1. Enabling the module
2. Create a calendar
3. As an attacker, trick another user with the "administer search_api" permission to open this HTML:

<script>window.location = 'http://example.com/calendar/all/import';</script>

4. If the user opens the HTML, an import is triggered without any confirmation.

Proposed resolution

Add the _csrf_token as suggested here: https://www.drupal.org/docs/8/api/routing-system/access-checking-on-rout...

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

danrod created an issue. See original summary.

danrod credited prudloff.

danrod’s picture

danrod’s picture

Thanks a lot to @prudloff for reporting this issue.

danrod’s picture

Title: Protect google_calendar_service.import_controller route against against Denial of Service » Protect google_calendar_service.import_controller route against against CSRF/Denial of Service attacks
danrod’s picture

After some thinking, I've decided to just disable the importing of all the calendar events at /calendar/all/import and let the user to sync their own calendars at /admin/calendar, there's already a cron hook that imports all the events from all the calendars that can be run at midnight, and allowing the user to do it from /calendar/all/import it's an invitation for a potential DoS.

Now, all the requests to /calendar/all/import will go to /admin/calendar.

I still added CSRF tokens for importing single calendars, for example: http://example.com/admin/calendar/1/import?token=Pe1Mz72klJE5yeV9xMaksh32Xj_Kl8FYH_yOyLnbW40

Ready for review.

danrod’s picture

Status: Active » Needs review
danrod’s picture

I'll close this issue and mark it as "Fixed" for now, any anyone has any questions/concerns about this fix, please let me know and I'll re-open the task.

danrod’s picture

danrod’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.