Problem/Motivation
Right now, unattended updates are disabled in this module via config with no UI.
The reason for this is because we have been waiting for support for The Update Framework(TUF) to be rolled out on drupal.org's packaging pipeline and Composer facade. TUF support for Package Manager is a core requirement but requiring TUF support for cron updates in contrib does not have to be a requirement though.
When Automatic Updates gets added to Drupal core it will be used by many many more sites and sites will not be able to easily opt out of this functionality being enabled by a privileged user. For this reason once in core unattended updates provides a tempting attack if someone were to be able to comprise core itself or one of core's dependencies that would be updated during a critical security update. Once AutoUpdates is in core and a security release for Drupal is issued many sites will update without eyes on the site. This could be 10s of thousands of sites at once.
The situation is much different for this contrib module for a couple of reasons
- This module only has 160 sites using it. Hopefully the number will increase and more rapidly if we support cron updates. But still what TUF would protect us against is supply side attacks. Updating via composer directly still has these problems
- Any site that uses this module and eventually enables cron updates has to opt-in to this by choice, once by installing the module and once by enabling via the UI. This is very different than the code being shipped with Drupal core which is hard to opt out of
Currently many sites do not apply core security updates, even critical ones, in a timely manner.
I am not sure where to get historical but as example the 2 most recent security releases were 9.5.5 and 10.0.5 both released on March 15th
From https://www.drupal.org/project/usage/drupal as of March 18, 2023
Here are numbers for sites running secure and insecure versions:
Secure 9.5 70,489
Insecure 9.5 84,904
Secure 10.0 9511
Insecure 10.0 9,797
So in both case more sites are running insecure than secure versions of Drupal core. The usual caveats with the incomplete data about usage statistics . These are only sites with the Update module installed. But this also means 100% of these have the message that they are insecure versions of Drupal on their status report.
There are probably many reasons for this but a couple likely ones are
- Organizations with a Drupal site may not always have a drupal developer on staff that can perform the updates
- Even organizations with staff that can perform updates may be limited by developer time(money) especially if they have many sites. Those sites could be within 1 organization or a development agency that hosts many drupal sites
Because of the above sites choosing to install this module and enable cron updates will be solving an existing security issue, not being able to apply security updates in a timely manner. If this module already had TUF support we could offer an even better solution but depending on a site’s needs the current module’s functionality may still be a security improvement.
Security Enhancements
Although this module does not currently have TUF support it does have a few other security features over using Composer directly
- Package Manager does not work if Composer’s default setting for secure-http is overridden. This means Composer will always fetch it’s metadata and package files via https.
- Drupal’s default settings for update_fetch_with_http_fallback cannot be overridden. This means that requests for Update XML which the site will use to determine if there is an update to be applied will always be fetched with https
Current module status
8.x-2.0 first stable release of the Composer compatible version of this module was released on July 21, 2022. We have not had any security problems reported with this module since then. The CronUpdater class is pretty small and cron updates mostly use the same logic as form updates. Cron updates are even more restrictive though in that they will not allow updates if there will need to be database update and are limited to patch updates.
The cron updater will email the site owner if there is an update available but it cannot be applied and if an update has been successfully applied.
Proposed resolution
Fix all the remaining tasks, then add a UI for enabling unattended updates.
Unattended updates should be disabled by default but a message should be displayed when the user enables the module.
Here is the commit where remove the form alter that added the cron updates to the Update setting form https://git.drupalcode.org/project/automatic_updates/-/commit/a001dacffe...
It could be used as a starting point. We already have tests for cron update but we could update test coverage that form enables and disables cron updates
Remaining tasks
Must have's
- #3281340: [Plan] Send emails
- #3299612: Send an email when an unattended update fails
- #3285491: Send an email when a cron update succeeds
- #3293422: Don't allow cron updates if Xdebug is enabled
- #3293146: Don't run cron updates with PHP's built-in web server without an alternate port
- #3351895: Add Drush command to allow running cron updates via console and by a separate user, for defense-in-depth
- #3359727: Add new setting for how unattended updates will be run
- #3360763: Switch failure marker file from *.json to *.yml to prevent it from being readable from the web
Needed before alpha release with unattended updates but can be done after this issue is committed.
- #3360656: For web cron updates run each stage life cycle phase in a different request
- #3362695: Create documentation for using the auto-update terminal command
Follow-up issues for core inclusion
Issue fork automatic_updates-3284443
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
Comment #2
phenaproximaComment #3
tedbowComment #4
tedbowComment #5
tedbowComment #6
tedbowComment #7
tedbowI think #3316617: Add a validator to check that PHP-TUF's Composer integration is present and configured correctly is actionable then we will have to postpone this on drupa.org TUF support
Comment #8
wim leers#7 Are you saying this is on #3316617: Add a validator to check that PHP-TUF's Composer integration is present and configured correctly? It seems like a few words are missing from #7, so can't be entirely certain 🤔
Comment #9
wim leers@tedbow and @tim.plunkett discussed the plan for getting Automatic Updates, Project Browser and Package Manager into core. We're likely going to aim to land Package Manager first. So postponing this issue for now, until the dust settles on that.
Comment #10
wim leersComment #11
tedbowUnpostoning this. since we are not sure when we will get into core and when TUF drupal.org will be done I propose we should do this in contrib first with TUF.
I need to update the summary here to make a better case for this and then I will email security@drupal.org because initially the restriction on not having unattended updates in Contrib without TUF was from the security team. I talked to @xjm and @pwolanin about this at DrupalCamp NJ and they proposed this path
Comment #12
tedbowComment #13
tedbowHave to take a break but assigning to myself as I am in the middle of updating the summary, consider it unfinished for now
Comment #14
tedbowComment #15
tedbowComment #16
tedbowComment #17
tedbowI have just emailed the Drupal security team about this issue since the decision not to support cron updates in contrib was originally because of advice from the security team.
I think we can still work on the issue as even if we commit it will only be in the 3.0.x branch which does not have any releases. xjm advised me we should wait 2 weeks for the security team to respond. At that point we could make a release with this issue completed, though practically we are planning on making 3.0.x releases that soon anyways.
Since we have the disabled code to do cron updates it will mostly just be adding the form.
Comment #18
tedbowComment #19
pwolanin commentedBefore enabling this, I think there needs to be a way to leave update off during the normal Drupal cron and include drush and drupal console commands to just run the updates (and for the core patch include a stand-alone script) + documentation on how to run these in a more secure mode where a system user other than the webserver user can write to the code and the command is executed by that user on an externally driven time (e.g. *nix crontab).
Comment #20
tedbowJust adding sample usage numbers for now
Comment #21
tedbowComment #22
phenaproxima@pwolanin, do we really need a whole separate command for this?
Unattended updates are run during cron. This means that
drush cronwould do the trick. Why do we need to write a whole separate command for that?Obviously, core cannot rely on Drush, but for now, surely it's okay to document that, for the contrib module, you can run updates with
drush cron. Would core consider adding a console command to run cron? That would pretty much take care of this, and probably be very useful to everyone.Comment #23
tedbowI think we can start to work on the UI parts of this while we figure out the answer to #22
Comment #24
tedbowadded remaining tasks and postponing on #3359727: Add new setting for how unattended updates will be run which will not do the UI part. We can do the UI for the new settings in this issue
Comment #25
tedbowadd #3360763: Switch failure marker file from *.json to *.yml to prevent it from being readable from the web
Comment #26
wim leers#3360763: Switch failure marker file from *.json to *.yml to prevent it from being readable from the web landed.
Comment #27
tedbowComment #28
tedbowComment #29
tedbowComment #31
phenaproximaComment #32
tedbowGreat!
Comment #34
phenaproxima