Skip to content

fix(alias): preserve quoted words during alias reparse - #1439

Merged
chaliy merged 1 commit into
mainfrom
2026-04-24-propose-fix-for-alias-expansion-vulnerability
Apr 24, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-04-24-propose-fix-for-alias-expansion-vulnerability

Conversation

@chaliy

@chaliy chaliy commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Alias expansion rebuilt a command string by serializing parsed Word/Redirect values via Display, dropping quoting context and allowing re-parsed arguments/redirects to be split or interpreted as shell syntax.

Description

  • Add format_word_for_alias_reparse to emit quoted words with quoting/escaping preserved while keeping expansion parts intact.
  • Use format_word_for_alias_reparse when reconstructing alias-expanded arguments and when formatting redirect targets.
  • Keep unquoted words serialized via existing Display behavior to preserve previous semantics for non-quoted tokens.
  • Add two spec tests validating that quoted argument literalness and quoted redirect targets are preserved under shopt -s expand_aliases in crates/bashkit/tests/spec_cases/bash/alias.test.sh.

Testing

  • Ran the bash spec suite test: cargo test -p bashkit --test spec_tests bash_spec_tests -- --nocapture which now passes (previous failing case fixed and overall spec tests passed).
  • Ran formatter check: cargo fmt --check which returned clean.
  • All changes are limited to crates/bashkit/src/interpreter/mod.rs and crates/bashkit/tests/spec_cases/bash/alias.test.sh and tests above succeeded.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 0372dae Commit Preview URL Apr 24 2026, 08:17 AM

@chaliy
chaliy force-pushed the 2026-04-24-propose-fix-for-alias-expansion-vulnerability branch from 6fb8a46 to 0372dae Compare April 24, 2026 08:16
@chaliy
chaliy merged commit c7b8ce4 into main Apr 24, 2026
34 checks passed
@chaliy
chaliy deleted the 2026-04-24-propose-fix-for-alias-expansion-vulnerability branch April 24, 2026 15:53
@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

chaliy added a commit that referenced this pull request May 30, 2026
### Motivation
- Alias expansion rebuilt a command string by serializing parsed
`Word`/`Redirect` values via `Display`, dropping quoting context and
allowing re-parsed arguments/redirects to be split or interpreted as
shell syntax.

### Description
- Add `format_word_for_alias_reparse` to emit quoted words with
quoting/escaping preserved while keeping expansion parts intact.
- Use `format_word_for_alias_reparse` when reconstructing alias-expanded
arguments and when formatting redirect targets.
- Keep unquoted words serialized via existing `Display` behavior to
preserve previous semantics for non-quoted tokens.
- Add two spec tests validating that quoted argument literalness and
quoted redirect targets are preserved under `shopt -s expand_aliases` in
`crates/bashkit/tests/spec_cases/bash/alias.test.sh`.

### Testing
- Ran the bash spec suite test: `cargo test -p bashkit --test spec_tests
bash_spec_tests -- --nocapture` which now passes (previous failing case
fixed and overall spec tests passed).
- Ran formatter check: `cargo fmt --check` which returned clean.
- All changes are limited to `crates/bashkit/src/interpreter/mod.rs` and
`crates/bashkit/tests/spec_cases/bash/alias.test.sh` and tests above
succeeded.

------
[Codex
Task](https://chatgpt.com/codex/cloud/tasks/task_e_69ead8dc5628832b9398ec5ef236c965)
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