Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Looks like the last composer release automatically do audits.

but these were not loaded, because they are affected by security advisories. To ignore the advisories, add ("PKSA-365x-2zjk-pt47") to the audit "ignore" config. To turn the feature off entirely, you can set "block-insecure" to false in your "audit" config.

This kind of breaks lot of CI's in my different open source projects. Where there is atleast one Job running on --prefer-lowest. Does it really make sense to audit on --prefer-lowest flag? Find it a nice feature for projects but for the libraries can be kind of annoying specially for the --prefer-lowest case.

You must be logged in to vote

The behavior of --prefer-lowest to skip installation of insecure versions is correct and should remain.

To explain why, imagine there is CVE reported against an old version of a library you depend on. This vulnerability allows remote code execution when the library code is autoloaded in a way that is triggerable in GitHub actions. The library authors marked the version insecure and published a safe new version. Now your CI system with --prefer-lowest would continue to install the old vulnerable version and effectively allow third parties to execute code in your GitHub action. The only safe default is to prevent installation of such insecure versions by default.

Preventing the installation…

Replies: 4 comments · 10 replies

Comment options

Do you have details? Link to build? The problem is due to #11956 which is not really an audit, it removes packages with vulnerabilities from the pool, so it should still be able to find a solution but I guess it gets stuck somewhere because some old packages have no vulnerabilities but depend on other old stuff which does have vulnerabilities and so is not visible to the solver.

I am not sure if we should skip this behavior for --prefer-lowest builds, or rather make people bump their requirements because that'd be preferable really.

You must be logged in to vote
1 reply
@alexander-schranz
Comment options

@Seldaek it appeared in sulu/sulu but think any symfony/http-foundation:^6.4 requiring packages when running composer update --prefer-lowest gets the same error.

Comment options

Just a note: cause here is that the optimizer groups insecure and secure package versions with identical deps. Then with prefer lowest it only leaves behind an insecure version, without it, it gets optimized to a secure version. Can be fixed in optimizer or by doing audit version removal before optimization.

You must be logged in to vote
3 replies
@naderman
Comment options

Sorry to clarify: that's the reason it fails rather than just picking more current versions. The overall behavior is a separate issue.

@Seldaek
Comment options

80503cb should fix it, please confirm with a composer self-update --snapshot that it can now resolve.

@alexander-schranz
Comment options

The composer self-update --snapshot && composer update --prefer-lowest does work!

Comment options

The behavior of --prefer-lowest to skip installation of insecure versions is correct and should remain.

To explain why, imagine there is CVE reported against an old version of a library you depend on. This vulnerability allows remote code execution when the library code is autoloaded in a way that is triggerable in GitHub actions. The library authors marked the version insecure and published a safe new version. Now your CI system with --prefer-lowest would continue to install the old vulnerable version and effectively allow third parties to execute code in your GitHub action. The only safe default is to prevent installation of such insecure versions by default.

Preventing the installation of these old versions should simply lead to a successful composer update that picks slightly newer versions, imitating what users of your library would end up with as well, since Composer would skip the insecure versions for them too. As per my other comment this behavior was broken in some cases, leading to errors rather than picking different versions, that should have been fixed in 80503cb.

The easiest solution generally would be to change your requirements to no longer accept the insecure versions.

That said, there may well be security vulnerabilities that would not be exploitable in the context of your library, and you may still want to perform tests against such versions in case users of yours still rely on these versions. So I think we should provide enough options for you to be able to explicitly allow specific CVEs/vuln ids to install as part of a --prefer-lowest command. Right now you can probably only accomplish this by using config audit ignore https://getcomposer.org/doc/06-config.md#abandoned which you could set temporarily with a config command before running the update prefer lowest. Maybe @Seldaek has ideas on how to make this particular scenario a bit easier to work with?

You must be logged in to vote
5 replies
@Seldaek
Comment options

Yeah I think configuring specific ignored CVEs if they don't apply and you absolutely want to test against those versions is the most sensible, or ignoring all advisories but that carries some risk for sure.

I'd think this can be committed to the composer.json of the project that's probably the easiest, it'd apply to all builds then but that shouldn't matter as regular builds would anyway prefer highest versions with fixes in.

@alexander-schranz
Comment options

To explain why, imagine there is CVE reported against an old version of a library you depend on. This vulnerability allows remote code execution when the library code is autoloaded in a way that is triggerable in GitHub actions. The library authors marked the version insecure and published a safe new version. Now your CI system with --prefer-lowest would continue to install the old vulnerable version and effectively allow third parties to execute code in your GitHub action. The only safe default is to prevent installation of such insecure versions by default.

Understand the point. How I can in the CI set that I still want allow the insecure versions I tried. composer config "audit.block-insecure" false but didn't work/failed.

@naderman
Comment options

That certainly should/should have worked.

@alexander-schranz
Comment options

Seems end in invalid argument. Should I open a more detailed issue?

  [InvalidArgumentException]
  Setting audit.block-insecure does not exist or is not supported by this command
@Seldaek
Comment options

Looks like we forgot to add support for these in config command :) Will PR a fix.

Answer selected by Seldaek
Comment options

For the --prefer-lowest CI case (I can relate, I have many of those too) one possible option might be to have a --prefer-lowest-no-dev.
Because usually what you want to achieve is to test if your production code also works on the lowest allowed versions but dev/CI stuff like CS fixers, linters, phpunit etc. doesn't need to be downgraded.
However, building that is probably not that easy and you can always run composer bump --dev-only to get rid of that issue.

You must be logged in to vote
1 reply
@Seldaek
Comment options

No need IMO, with 2.9.1 prefer lowest should work fine again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.