Motivation

Automatic Updates currently asks admins to configure core files to be writable by the PHP user. While the update process itself is trustworthy, this enables vulnerabilities in Drupal, contributed projects, or dependencies to be exploited to modify core files. This is a serious problem in the real world that could negate the advantage of automatic updates.

Users who are comfortable with the command line can set up cron to run automatic updates as a user who has permission to modify core files. Yet if the command line is the only way to run updates securely, many vulnerable sites will never be fixed.

Proposed resolution

This problem was previously solved by the Update module. When updating contrib projects, if PHP did not have permission to change a contributed module, the Update module checked for file transfer backends. If one existed, authorize.php prompted for the user name and password of a user who had permission to write to the file system. No credentials were stored in Drupal, so an authorized user had to be present to modify files.

File transfer base class

Remaining tasks

  1. Add prompt for file system user credentials if file system is not writable and file transfer backend is available.
  2. Add script to run automatic updates from the command line as a user with permission to modify core files. DONE:
  3. Update messages and documentation to explain how to configure automatic updates without giving PHP write access to core files.

User interface changes

Changes notices and adds a prompt to the admin UI when user initiates automatic update.

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

Darren Oh created an issue. See original summary.

heddn’s picture

Status: Active » Postponed (maintainer needs more info)

Automated updates with a password stored-on-disk or in-a-script for ftp seems pretty in-secure too. At some level, updating the site is going to require some access to write to the disk. And the trigger for applying those updates can be a drush cron run as any system user via system cron. This approach would preclude the need for ftp credentials and work with the existing setup in this module.

There is a complicated set of issues around opcode cache if run via CLI and opcode is enabled, but there are some work arounds for that using https://github.com/gordalina/cachetool.

I'm inclined to close as works as designed, but let's see if I've mis-represented the problem in an overly simplified manner. For the mean time, moving to postponed.

darren oh’s picture

Status: Postponed (maintainer needs more info) » Active

Yes, you misrepresented the problem. As noted in the issue description, it has already been solved in the Update module which prompts for an SSH or FTP password and does not store it. The feature is probably rarely used, so I can understand how it was overlooked. If the update can be triggered from the web, this is the only secure way to do it.

darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
heddn’s picture

I was envisioning that automatic updates happened without human interaction. I'm confused if we require humans to enter a password; because if we require humans, I don't consider that to be automated updates any more. And the point of this effort is to remove the human element.

darren oh’s picture

There is an admin UI for manually triggering the update. And if the update depends on cron, that can be triggered by any visitor.

heddn’s picture

Long week with the virtual con... but if I understand your last comment, then you can do exactly that right now via drush and linux cron. There isn't a slick web UI to set things up, but that also helps with cross-platform compatibility as run-as on Windows vs Linux vs your platform of choice is going to be somewhat different.

For linux, just use its system cron to trigger drush cron-run as your privileged system user.

darren oh’s picture

Maybe you're trying to say that the option to trigger the update from the web should be removed. As the issue description states, this is partly a documentation problem. Instead of warning users to make core files writable, notices should recommend the steps required to make it work without doing so. We really need to try to get more people to protect core files from modification by the web server. Currently the automatic updates initiative encourages the opposite.

If you don't want to work on it, just leave this issue alone and it can be my contribution.

heddn’s picture

Thanks for keeping with your feedback. Yes, we need to improve the docs and best practices/guidance around how to use this module. Let's do that!

darren oh’s picture

Assigned: Unassigned » darren oh
darren oh’s picture

Assigned: darren oh » Unassigned
Status: Active » Needs work
StatusFileSize
new1.91 KB

Starting a patch to get input.

darren oh’s picture

Issue summary: View changes
darren oh’s picture

Version: 8.x-2.x-dev » 8.x-1.x-dev
darren oh’s picture

darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
darren oh’s picture

darren oh’s picture

Readiness checkers are updated. Started adding code for authorizing file operations. Need to determine exactly what can run at the authorize bootstrap level.

darren oh’s picture

Issue summary: View changes
darren oh’s picture

Title: Add support for file transfer backends » Prompt for temporary access when file system is not writable
darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
darren oh’s picture

Issue summary: View changes
dww’s picture

If you intend to rely on the FileTranfser classes to do this, and you actually think that could still work, you need to speak up (quickly?) in #3491731: [META] Remove the ability to update modules and themes via authorize.php. The current MR there completely removes that entire API (along with authorize.php and related methods from system.module). Everyone (so far) thinks it’s legacy cruft that no one could possibly care about anymore and doesn’t even deserve to be deprecated before removal. 😅

I’m extremely familiar with the goal of UI-based updates for sites configured in depth. I have championed that approach since D6, and wrote the bulk of this code in the first place. You don’t have to explain to me how it works or why in principle it’s a good idea.

However, I’m no longer convinced that any site with httpd running as another user than the one who owns the files will be maintained by someone who is CLI averse. It’s only wild speculation, but my sense is the intersection of those two sets is vanishingly small, and not worth bogging down core with technical debt to support.

It’s absolutely worth making the UI play nicely with a cron-driven “sudo” step. That’s already been done. But actually requiring manually logging in via FileTransfer directly as part of the UI seems unnecessary.

dww’s picture

Issue summary: View changes

Point 2 in remaining tasks is already done. Adding links.

dww’s picture

For clarity, the “cron-driven sudo” step that’s already supported is not via Drupal’s hook cron, which “might be triggered by any user”. I/we are talking about good ole *nix crontab, and specifically setting up the script completely outside of Drupal.