Restrict plugin migration to home scope (#39663)

## Why

Plugin imports persist user-global enabled state. Repository-controlled settings
must not be allowed to select executable plugin content for installation.

## What changed

- Detect plugin migrations only from home-scoped external agent settings.
- Reject plugin imports with a non-empty project `cwd` before loading Codex
  configuration, while continuing to treat an empty `cwd` as home scope.

## Testing

- Cover repository-scoped detection with remote, installed, and project-relative
  marketplaces.
- Verify that forged project-scoped imports fail without writing `config.toml`.

GitOrigin-RevId: 53cb46ae049cb49283187312d475d40cf42e35ab
This commit is contained in:
charlesgong-openai authored and copyberry committed 2026-08-20 08:24:18 +00:00
1 parent 240bbfc14a
commit 97c82c0900
4 files changed
+74 -115

No files matched your search

@@ -327,7 +327,9 @@ impl ExternalAgentConfigService {
);
}
if self.source.supports_plugin_migration(settings.as_ref()) {
// Plugin import persists user-global enabled state, so repository-controlled
// settings must never be treated as plugin installation authority.
if scope.is_home() && self.source.supports_plugin_migration(settings.as_ref()) {
match ConfigBuilder::default()
.codex_home(self.codex_home.clone())
.fallback_cwd(Some(self.codex_home.clone()))