Skip to content

Add an option to disable reading project config file or dangerous options in it #2923

Closed

Description

@Xerkus

I am concerned that malicious .phpactor.json file in the project can lead to arbitrary code execution via configuration options like language_server_psalm.bin with only minimal interaction.

All it would take is to download malicious package and try to inspect its content, depending on the editor and lsp client setup.

For example, default neovim nvim-lspconfig autostart feature with .phpactor.json as one of the default root markers would allow it to be anywhere too. Just open any php file below it in the tree, phpactor would be started automatically and we got got.

Ideally, project config should be explicitly marked as trusted, much like most IDEs are doing, before any unsafe options are allowed to be used. Ability to disable them entirely at project level would be a reasonably good enuf solution in the short term.

Activity

  1. added a commit that references this issue on Sep 6, 2025
  2. dantleech commented on Sep 6, 2025

    @dantleech
    Collaborator

    That's a very valid concern, can you test: #2924 ?

  3. added 6 commits that reference this issue on Sep 6, 2025
  4. Xerkus commented on Sep 6, 2025

    @Xerkus
    Author

    That was fast. Thank you

  5. nexxai commented on Sep 21, 2025

    @nexxai

    @dantleech This looks like a great change in terms of security, but using the vim plugin (without the CLI installed), I'm unclear how to trust a project's .phpactor.json file.

    When I try to do something like :PhpactorContextMenu, I'm getting this error within Neovim:

    Error detected while processing function phpactor#ContextMenu[1]..phpactor#rpc[19]..function phpactor#ContextMenu[1]..phpactor#rpc:line   18:
    E605: Exception not caught: Could not parse response from Phpactor: Vim(let):E474: Unidentified byte: Local config ".phpactor.json" f
    

    If I try to run my keymap for :PhpactorImportClass, I get this error:

    E5108: Error executing lua: vim/_editor.lua:0: nvim_exec2()[1]..function phpactor#ImportClass[1]..phpactor#rpc, line 18: Could not parse response from Phpactor: Vim(let):E474: Unidentified byte: Local config ".phpactor.json" found but it's in an untrusted directory, run `phpactor config:trust` if you want it to be loaded
    {"version":"1.0.0","action":"input_callback","parameters":{"inputs":[{"name":"qualified_name","type":"list","parameters":{"default":null,"label":"Select class:","choices":{"Illuminate\\Support\\Carbon":"Illuminate\\Support\\Carbon","Carbon\\Carbon":"Carbon\\Carbon"},"keyMap":[],"multi":false}}],"callback":{"action":"import_class","parameters":{"qualified_name":null,"alias":null,"source":"<?php\n\nnamespace App\\Settings;\n\nuse Spatie\\LaravelSettings\\Settings;\n\nclass BannerNotification extends Settings\n{\n    public bool $active;\n\n    public string $message;\n\n    public Carbon $test;\n\n    public static function group(): string\n    {\n        return 'banner';\n    }\n}","offset":181,"path":"\/Users\/nexxai\/code\/ipms\/app\/Settings\/BannerNotification.php"}}}}
    stack traceback:
    	[C]: in function 'nvim_exec2'
    	vim/_editor.lua: in function 'cmd'
    	/Users/nexxai/.config/nvim/lua/config/keymaps.lua:39: in function </Users/nexxai/.config/nvim/lua/config/keymaps.lua:35>
    

    I've looked and don't see any :PhpactorConfigTrust or anything similar, so I assume this is just due to this change not being cemented yet, but I also could be missing something super obvious too.

  6. przepompownia commented on Sep 22, 2025

    @przepompownia
    Contributor

    Try ./bin/phpactor config:trust (relative to the plugin directory) while such Vim command not defined yet.

  7. michel-cetina commented on Sep 23, 2025

    @michel-cetina

    I'm experiencing the same behavior as @nexxai, strange thing is that even with the latest tag at the moment: 2025.07.25.0
    the config:trust command is not available (Command "config:trust" is not defined.). I've also tried to add the core.trust key manually using the config:set option but then after running any command I have the warning: Phpactor\MapResolver\InvalidMap: Key(s) "core.trust" are not known

    I've bypassed the whole trust logic by adding the env variable PHPACTOR_UNCONDITIONAL_TRUST=1 to my terminal.

    Please let me know if you need any extra information.

  8. dantleech commented on Sep 28, 2025

    @dantleech
    Collaborator

    I'm experiencing the same behavior as @nexxai, strange thing is that even with the latest tag at the moment

    the version with this feature hasn't been tagged yet, so that is strange - possibly you have two versions of Phpactor?

  9. dantleech commented on Sep 28, 2025

    @dantleech
    Collaborator

    I've suppressed the error when the incoming call is from the legacy RPC (i.e. the VIM plugin), I've also added :PhpactorTrust and :PhpactorUntrust commands to the VIM plugin.

  10. michel-cetina commented on Oct 1, 2025

    @michel-cetina

    I'm experiencing the same behavior as @nexxai, strange thing is that even with the latest tag at the moment

    the version with this feature hasn't been tagged yet, so that is strange - possibly you have two versions of Phpactor?

    You're right, Mason takes the bin from the tag but Lazy is taking data directly from the master branch. Thanks for adding the extra commands for us vim users 😄

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions