Skip to content

AssetManager copies entire bower-asset package (including executable test/script files) to web/assets #20838

Description

@delikates-nsk

Description

AssetManager copies entire bower-asset package (including executable test/script files) to web/assets

'assetManager' => [
    'forceCopy' => true,
    'appendTimestamp' => false,
    'linkAssets' => false,
]

and after including the pjax component in a view - when a client accesses the site, the following files and subfolders appear in web/assets/<random_name>/ directory from vendor/bower-assets/:

  • /script
  • /test
  • /vendor
  • CHANGELOG.md
  • CONTRIBUTING.md
  • Gemfile
  • Gemfile.lock
  • jquery.pjax.js
  • LICENSE
  • package.json
  • README.md

The contents of all these files and subfolders can be viewed (if directory listing is not disabled at the web server level).

What particularly concerns me are three "executable" files in the "/script" folder:

  • bootstrap
  • server
  • test

I'm not sure if this poses a security threat to the site, but it seems to me that their presence in web/assets is clearly unnecessary.

composer.lock:
...
{
            "name": "bower-asset/yii2-pjax",
            "version": "2.0.9",
            "source": {
                "type": "git",
                "url": "https://github.com/yiisoft/jquery-pjax.git",
                "reference": "452b56b7124326487fd0d3be6b205fcaa66598a0"
            },
 },
...

Package version

2.0.54

PHP version

8.3.30

Activity

  1. added theissue type on May 8, 2026
  2. terabytesoftw commented on May 8, 2026

    @terabytesoftw
    Member

    You can configure the asset to your liking; in the settings, you only need to add:

    public $publishOptions = [
        'only' => [
            'jquery.pjax.js',
        ],
    ];
  3. WarLikeLaux commented on May 29, 2026

    @WarLikeLaux
    Contributor

    The whole package gets published because PjaxAsset::$sourcePath points at the package root (@bower/yii2-pjax) with no $publishOptions set (framework/widgets/PjaxAsset.php:21), so AssetManager copies the entire directory through FileHelper::copyDirectory(). Only jquery.pjax.js is actually used; script/, test/, vendor/, Gemfile, the *.md files and so on come along with it.

    On the script/bootstrap|server|test worry: those are shell scripts, and the web server serves them as static text rather than executing them, so this is information disclosure and docroot clutter, not RCE. Still no reason for them to be published.

    @terabytesoftw's publishOptions = ['only' => ['jquery.pjax.js']] fixes it per app. The open question is whether to bake that into the bundle so every app is clean by default:

    // PjaxAsset
    public $publishOptions = ['only' => ['jquery.pjax.js']];

    PunycodeAsset has the same shape ($sourcePath = '@bower/punycode', only punycode.js used, root carries scripts/, tests/, .github/), so it would want ['only' => ['punycode.js']] too. The other core bundles point at dist or @yii/assets, so they're unaffected.

    It's a small change to the default published file set (only build/test/doc files stop being copied, the asset itself is untouched), but it does change a public bundle's default, so probably a CHANGELOG entry plus an UPGRADE note.

    Do you want this promoted to the bundle defaults (PjaxAsset and PunycodeAsset), or kept as per-app config / documented? Happy to send a PR once you decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions