Skip to content

Ask permission to load .phpactor.json in project root - #2924

Merged
dantleech merged 2 commits into
masterfrom
gh-2923-arbitrary-code-trust
Sep 6, 2025
Merged

dantleech merged 2 commits into
masterfrom
gh-2923-arbitrary-code-trust

Conversation

@dantleech

@dantleech dantleech commented Sep 6, 2025 •

Copy link
Copy Markdown
Collaborator

In order to mitigate the risk of arbitrary code execution via. a malicious .phpactor.json always ask permission.

image

@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch from dd2f40d to f1d52a7 Compare September 6, 2025 11:32
Comment thread lib/Phpactor.php Resolved
@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch from f1d52a7 to afda5cf Compare September 6, 2025 12:10
Comment thread lib/Phpactor.php Resolved
@Xerkus

Xerkus commented Sep 6, 2025

Copy link
Copy Markdown

Worked great.

May be for convenience have newly created config files trusted by default? As long as there was none before.

@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch 4 times, most recently from 1e270c8 to c5a6268 Compare September 6, 2025 12:38
@dantleech

Copy link
Copy Markdown
Collaborator Author

May be for convenience have newly created config files trusted by default? As long as there was none before.

I think there's still a risk there that you git pull on a compromised repo and ...

@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch 2 times, most recently from 4d9d406 to 77cb30d Compare September 6, 2025 12:49
@Xerkus

Xerkus commented Sep 6, 2025

Copy link
Copy Markdown

There was an interaction where that makes sense - where phpactor detects psalm and other tooling in composer and asks if they should be enabled.

May be that flow should be updated to ask if location should be trusted and if it is recorded as not trusted no request to enable tools should be made afterwards.

@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch from 77cb30d to b37bf38 Compare September 6, 2025 12:58
In order to mitigate potential arbitrary execution attacks always ask
permission before loading a project-level phactor configuration file.

- Introduce the concept of trust
- Language server to ask permission before allowing configuration files
  to be loaded.
- CLI shows a warning if a configuration file is present but not loaded
  due to trust issues.
- `phpactor config:trust` command introduced to allow setting the trust
  status of the resolved project root.

pFixing tests

Unconditional trust env var
@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch from b37bf38 to 99ceded Compare September 6, 2025 13:06
@dantleech

dantleech commented Sep 6, 2025 •

Copy link
Copy Markdown
Collaborator Author

May be that flow should be updated to ask if location should be trusted and if it is recorded as not trusted no request to enable tools should be made afterwards.

Yeah ... I've changed it so that auto-config modifies the file regardless but the confirmation text indicates that the config file is not trusted and won't be used.

@dantleech
dantleech force-pushed the gh-2923-arbitrary-code-trust branch from 0be3170 to e5480c6 Compare September 6, 2025 13:23
@dantleech
dantleech merged commit bf18b7b into master Sep 6, 2025
@dantleech
dantleech deleted the gh-2923-arbitrary-code-trust branch September 6, 2025 13:26
@dantleech

Copy link
Copy Markdown
Collaborator Author

I'll let it in the main branch for a week or so and then tag a new version, thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants