Problem/Motivation

After much discussion and deliberation with the security team and core committers, it has been decided that TUF protection will be required for the use of Package Manager in virtually all cases.

Right now, packages.drupal.org is still in the process of rolling out TUF support. We need to be ready for that, by having the code in place to ensure that Package Manager operations will be protected by TUF.

Proposed resolution

We should add a validator that checks the following on create, require, and apply, in both the active and stage directories:

  1. The PHP-TUF Composer plugin is installed.
  2. And enabled in Composer's allow-plugins config.
  3. And configured to protect the packages.drupal.org repository, which must be defined in composer.json.

If any of these things aren't true, the validator will flag an error.

For now, this validator should be added as a service, but NOT tagged as an event subscriber. That will be done in a follow-up, when we add a hard dependency on PHP-TUF: #3358504: Require PHP-TUF's Composer integration plugin

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

tedbow created an issue. See original summary.

tedbow’s picture

Issue summary: View changes
tedbow’s picture

Issue summary: View changes

We could make a validator and test and but then disable this validator in our base tests until the integration is done.

So we could have 1 test covers our validators

phenaproxima’s picture

phenaproxima’s picture

Title: If unattended updates are enabled unensure PHP-TUF composer integration is present » If unattended updates are enabled, eensure PHP-TUF Composer integration is present
tedbow’s picture

Issue tags: +core-mvp
wim leers’s picture

Title: If unattended updates are enabled, eensure PHP-TUF Composer integration is present » If unattended updates are enabled, ensure PHP-TUF Composer integration is present

We are waiting on PHP-TUF integration on drupal.org until we enable unattended updates.

Is there an issue this can reference?

tedbow’s picture

Issue tags: +sprint
tedbow’s picture

Assigned: Unassigned » phenaproxima

Assigning to @phenaproxima
re chat and

Should we just add `php-tuf/composer-integration` to our composer.json and be done with it?

He said this not a good idea

also
@adam.hoenich
were you thinking that in core we would add php-tuf to the core composer.json?
because if we didn't AU would not work "out of the box" and depending on product decisions PB won't either if required TUF

phenaproxima’s picture

My current thinking is this:

  • Neither Automatic Updates nor Project Browser should have a hard dependency on PHP-TUF.
  • Package Manager should have a validator that checks for the presence of PHP-TUF (actually, the Composer plugin, which implies the presence of PHP-TUF). If it's not there, that should raise a warning in all status checks.
  • Automatic Updates should upgrade that warning to a full-fledged error when doing a status check for unattended updates. PHP-TUF should be a hard requirement for any unattended operation.

To me, this is the best of all worlds:

  • Sites stuck on PHP 7.4 can still take advantage of the UIs provided by Automatic Updates and Project Browser. The only feature they don't get is truly automatic, background updates. Even without that, there is still a ton of value for site builders in both modules.
  • Drupal 10 core already requires PHP 8.1, so it will be able to add PHP-TUF as a dependency with no trouble, and therefore provide fully automatic, unattended updates out of the box.
  • PHP-TUF itself need not take unnecessary security risks by supporting dead versions of PHP.
tedbow’s picture

Assigned: phenaproxima » wim leers

@phenaproxima thanks!

This sounds ok . I think the only downside is that people using AutoUpdates on 7.4 would not get Cron updates which is what most people want but that seems to be outweighed by

  1. It would allow us to develop php-tuf now for how we would it included as a dependency of Drupal core, using the 8.1+ features, we won't have to put this work of
  2. Requiring php-tuf because we think it is needed for extra security that cron updates require while at the same time allowing it to be run on php 7.4 we know will not get security updates seem like it would be giving sites a false sense of security

Assigning this to @Wim Leers to see if he sees any problem with this approach because I think as soon as we require 8.1 for php-tuf and start to use its features it would be a pain to downgrade.

tedbow’s picture

wim leers’s picture

Assigned: wim leers » Unassigned

Why not require a hard dependency? For the contrib project we shouldn't (agreed!), but for core we should? I think that's what the end of #10 implies?

I 100% agree that getting unattended updates working for ~116 sites of which some fraction is on PHP 7.4 is not worth our time. We need to think about the ecosystem impact first and foremost IMHO, which means not worrying about unsupported PHP versions, i.e. PHP 7.4.

So +1 for @phenaproxima's proposal from me 🤓

tedbow’s picture

I think for core yes should have php-tuf as a hard dependency because cron updates in the killer feature for core so having someone have to do another manual composer operation to get there seems not great.

We could also make it hard dependency of 3.x

phenaproxima’s picture

Why not require a hard dependency? For the contrib project we shouldn't (agreed!), but for core we should? I think that's what the end of #10 implies?

Yes, that's what I meant. Core should have the hard dependency, but the contrib module shouldn't.

wim leers’s picture

Sounds like we're on the same page! 🥳

phenaproxima’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated the IS with the proposed resolution.

phenaproxima’s picture

Issue summary: View changes
phenaproxima’s picture

Assigned: Unassigned » phenaproxima
phenaproxima’s picture

Assigned: phenaproxima » tedbow
Status: Active » Needs review
tedbow’s picture

Neither Automatic Updates nor Project Browser should have a hard dependency on PHP-TUF.

Core may require php-tuf when we merge in. @phenaproxima do you foresee and problems with this? I assuming we don't have any dependencies in php-tuf that core would not want to have an indirect dependency on, like we currently have in Au with composer/composer

tedbow’s picture

Assigned: tedbow » phenaproxima

Assigning to @phenaproxima for feedback on my idea in MR

tedbow’s picture

Status: Needs review » Needs work

Also setting to needs work because even if we don't decide to do any of the ideas I proposed I think at the very least we need to be clear in the messages the security implications. Probably also with @todo to follow-up issue that will provide a link to docs

phenaproxima’s picture

Assigned: phenaproxima » tedbow
Status: Needs work » Needs review
tedbow’s picture

Assigned: tedbow » phenaproxima
Status: Needs review » Needs work
tedbow’s picture

Version: 8.x-2.x-dev » 3.0.x-dev
wim leers’s picture

Title: If unattended updates are enabled, ensure PHP-TUF Composer integration is present » [PP-because-focus-on-PM] If unattended updates are enabled, ensure PHP-TUF Composer integration is present
Status: Needs work » Postponed

@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.

tedbow’s picture

Title: [PP-because-focus-on-PM] If unattended updates are enabled, ensure PHP-TUF Composer integration is present » If unattended updates are enabled, ensure PHP-TUF Composer integration is present
Status: Postponed » Needs work
Issue tags: +alpha

RE: #3349368: [policy, no patch] How much of The Update Framework integration is needed for alpha-level review/commit of Package Manager?

We need TUF for package manager to get into core at all.

from this issues summary

(since we don't need to require TUF for attended Package Manager operations).

We should confirm that with a question in #3349368. It may be the case that all package manager operations need TUF or at least AutoUpdates and Project Browser.

tedbow’s picture

Issue tags: -alpha +alpha target
tedbow’s picture

wim leers’s picture

Bumping to critical per #29. But … is this even actionable? Isn't this hard-blocked on #3325040: [Packaging Pipeline] Securely sign packages hosted on Drupal.org using the TUF framework and Rugged? 🧐

The current MR needs to be redone anyway, because it's still targeting 8.x-2.x.

P.S.: I think

We need TUF for package manager to get into core at all.

should be

We need TUF for package manager to get into core at all , after all.

😓

tedbow’s picture

re #3284443-11: Enable unattended updates I am removing unattended update blocker tag as I propose we don't block this in contrib only. But it is still an alpha target because we would need this in core for alpha

tedbow’s picture

Re the current action that is needed is to make a new MR against 3.0.x from the current 8.x-2.x MR

tedbow’s picture

I think we need "Needs issue summary update" before we do more work on this because of the changes made after

re

I would prefer 2) because it would mean that by default all stages would enforce TUF validation. you would have to override this to opt of validation. Otherwise every stage has to opt-in for actual TUF enforcement and not just a warning.

We need to get confirmation from core committers that it is ok for modules building UIs to opt out TUF protect for their use case.

The reason I think it should be ok is otherwise if we make it too difficult to opt-out then I could see developers trying to do this by just removing our validator service altogether. That would be very bad because it would turn off TUF for all use cases

tedbow’s picture

tedbow’s picture

Assigned: tedbow » Unassigned
phenaproxima’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work

First round of review! This is looking great already 😊

phenaproxima’s picture

Assigned: Unassigned » tedbow
tedbow’s picture

Assigned: tedbow » phenaproxima

re-assigning to @phenaproxima until tests pass

phenaproxima’s picture

Assigned: phenaproxima » tedbow
Status: Needs work » Needs review
wim leers’s picture

Title: If unattended updates are enabled, ensure PHP-TUF Composer integration is present » [PP-1] If unattended updates are enabled, ensure PHP-TUF Composer integration is present
Related issues: +#3358012: StageBase::stageDirectoryExists() breaks on PreCreate
wim leers’s picture

Detailed review posted. Chief concern: this should behave more like \Drupal\package_manager\Validator\ComposerPatchesValidator, at least the way it is implemented since #3252299: Reliably support cweagans/composer-patches in Package Manager & Automatic Updates: validate stage.

wim leers’s picture

Title: [PP-1] If unattended updates are enabled, ensure PHP-TUF Composer integration is present » If unattended updates are enabled, ensure PHP-TUF Composer integration is present
phenaproxima’s picture

Title: If unattended updates are enabled, ensure PHP-TUF Composer integration is present » Ensure PHP-TUF Composer integration is present

Changing title to reflect the reality that TUF is basically always required for use of Package Manager.

phenaproxima’s picture

Title: Ensure PHP-TUF Composer integration is present » Add a validator to check that PHP-TUF's Composer integration is present and configured correctly

Making the title a little more specific, since we're not (yet) adding a hard dependency on PHP-TUF.

phenaproxima’s picture

Assigned: phenaproxima » tedbow
Status: Needs work » Needs review
phenaproxima’s picture

tedbow’s picture

This looks good, but I will have to give it closer look. Didn't find anything I object to though

wim leers’s picture

Assigned: tedbow » Unassigned
Status: Needs review » Needs work

Thanks for opening #3358504: Require PHP-TUF's Composer integration plugin. Agreed with landing as much as possible NOW, before the d.o infrastructure side is complete 👍 I expanded the information in that issue.

I did still find a few things to be concerned about, but it's definitely closer now!

phenaproxima’s picture

Assigned: Unassigned » wim leers
Status: Needs work » Needs review
phenaproxima’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
wim leers’s picture

Assigned: wim leers » phenaproxima
Issue summary: View changes
Status: Needs review » Needs work

Excellent work here, and thanks for bearing with me as I scrutinize every line …

phenaproxima’s picture

Assigned: phenaproxima » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » tedbow
Status: Needs review » Reviewed & tested by the community

🚢

tedbow’s picture

Assigned: tedbow » phenaproxima
Status: Reviewed & tested by the community » Needs work

Just 1 suggestion for test coverage

phenaproxima’s picture

Assigned: phenaproxima » tedbow
Status: Needs work » Needs review
tedbow’s picture

Assigned: tedbow » Unassigned
Status: Needs review » Reviewed & tested by the community

Works for me

phenaproxima’s picture

  • phenaproxima committed 34a00b34 on 3.0.x
    Issue #3316617 by phenaproxima, tedbow, Wim Leers: Add a validator to...
phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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