Skip to content

Harden Kiro CLI path resolution - #25

Merged
Finesssee merged 2 commits into
mainfrom
codex/fix-kiro-cli-path-hijack-vulnerability
Apr 4, 2026
Merged

Finesssee merged 2 commits into
mainfrom
codex/fix-kiro-cli-path-hijack-vulnerability

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Motivation

  • The Kiro provider previously resolved and executed kiro-cli via PATH (e.g. which or env resolution), which allows a local PATH-hijack to execute attacker-controlled binaries under the user context.

Description

  • Add an explicit environment override CODEXBAR_KIRO_CLI_PATH and a filename/path validator is_allowed_kiro_binary in rust/src/providers/kiro/version.rs to allow only explicit, trusted Kiro CLI paths.
  • Replace PATH-based discovery with find_kiro_cli() that only accepts the env override or known Windows install locations and validates discovered files before returning them.
  • Update KiroProvider::which_kiro() in rust/src/providers/kiro/mod.rs to reuse version::find_kiro_cli() so the login and usage execution paths use the same hardened resolver.
  • Preserve existing version-detection and compatibility APIs (detect_version, get_version, is_installed) while removing untrusted which lookups.

Testing

  • Ran formatter: cd rust && cargo fmt --all — succeeded.
  • Ran full test suite: cd rust && cargo test --quiet — failed in this environment due to missing x86_64-pc-windows-msvc target, so tests could not be executed here.
  • Ran a focused test attempt: cd rust && cargo test -p codexbar --lib providers::kiro::version::tests::test_parse_version_simple — failed because the package has no library target in this workspace configuration.
  • Ran cross-target check: cd rust && cargo check --target x86_64-unknown-linux-gnu --quiet — failed here due to missing native glib-2.0 (pkg-config) system dependency, so further automated verification could not complete in this environment.

Codex Task

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Requesting changes before merge:

This PR removes PATH lookup entirely (which::which() calls removed), which regresses Kiro detection on WSL/Linux environments where the CLI may be installed in a non-standard location.

Please restore PATH-based discovery with the same hardening pattern used in PR #26 (check if path is explicit vs bare command name).

The PR removed PATH-based discovery entirely, which regressed Kiro
detection on WSL/Linux where the CLI may be in a non-standard location.

This restores which::which() lookups with the same hardening pattern
used in PR #26:
1. Check env override first (explicit path)
2. Hardened PATH lookup (which::which + is_allowed_kiro_binary validation)
3. Fall back to known Windows install locations

This maintains the security hardening while preserving cross-platform
compatibility.
@Finesssee

Copy link
Copy Markdown
Collaborator Author

Fixed: Restored hardened PATH lookup for WSL/Linux support.

The Problem:
The PR removed all calls, which regressed Kiro detection on WSL/Linux environments where the CLI may be installed in a non-standard location.

The Fix (commit 2fcfd4a):
Added hardened PATH lookup back to with the same pattern used in PR #26:

  1. Env override (explicit ) - checked first
  2. Hardened PATH lookup - and with validation
  3. Known Windows paths - fallback for standard Windows installs

This maintains security (validated filenames, env override priority) while restoring cross-platform compatibility.

Security preserved:

  • validates filename is , , 1% > 1% > , or
  • Env override takes precedence (user explicitly trusts the path)
  • No CWD hijacking risk (which::which resolves via PATH, not checking if bare name exists in current dir)

The PR should now be safe to merge.

@Finesssee
Finesssee merged commit 4aedff2 into main Apr 4, 2026
4 of 8 checks passed
Finesssee added a commit that referenced this pull request Apr 4, 2026
Security fixes:
- Harden updater integrity checks (PR #24)
- Harden CLI binary resolution (PR #26)
- Harden Kiro CLI path resolution (PR #25)
- Verify VC++ runtime before packaging (PR #23)

New provider:
- Add Infini AI Coding Plan provider (PR #28)

Bug fixes:
- Fix Windows CLI visibility (Issue #22)
- Fix Claude .local/bin detection (Issue #22)
Finesssee added a commit that referenced this pull request Apr 7, 2026
Security fixes:
- Harden updater integrity checks (PR #24)
- Harden CLI binary resolution (PR #26)
- Harden Kiro CLI path resolution (PR #25)
- Verify VC++ runtime before packaging (PR #23)

New provider:
- Add Infini AI Coding Plan provider (PR #28)

Bug fixes:
- Fix Windows CLI visibility (Issue #22)
- Fix Claude .local/bin detection (Issue #22)
@Finesssee
Finesssee deleted the codex/fix-kiro-cli-path-hijack-vulnerability branch August 28, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant