Skip to content

fix(validate): block workspace alias shell injection in generated bash steps#1018

Merged
jamesadevine merged 2 commits into
mainfrom
copilot/fix-shell-injection-vulnerability
Jun 15, 2026
Merged

fix(validate): block workspace alias shell injection in generated bash steps#1018
jamesadevine merged 2 commits into
mainfrom
copilot/fix-shell-injection-vulnerability

Conversation

Copilot AI commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Workspace alias values were validated too loosely, allowing shell metacharacters to pass into generated double-quoted bash arguments (--container-workdir / SafeOutputs bounding dir). This change closes that injection path by hardening alias validation and adding workspace-level expression rejection.

  • Validation hardening

    • Tighten is_safe_path_segment to a strict allowlist: [A-Za-z0-9._-]
    • Keep existing traversal/newline guards (.., /, \, leading ., \n, \r)
    • Update error text to reflect the stricter contract
  • Defense-in-depth on front matter

    • Extend validate_front_matter_identity to run reject_pipeline_injection on workspace
  • Regression coverage

    • Add tests rejecting shell-metacharacter workspace aliases
    • Add tests rejecting ADO expression syntax in workspace
pub fn is_safe_path_segment(s: &str) -> bool {
    !s.is_empty()
        && !s.contains("..")
        && !s.contains('/')
        && !s.contains('\\')
        && !s.starts_with('.')
        && !s.contains('\n')
        && !s.contains('\r')
        && s.chars()
            .all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.'))
}

Test plan

Covered by existing and newly added unit tests in src/validate.rs and src/compile/common.rs.

Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix shell injection vulnerability in workspace alias fix(validate): block workspace alias shell injection in generated bash steps Jun 15, 2026
Copilot AI requested a review from jamesadevine June 15, 2026 06:53
@jamesadevine jamesadevine marked this pull request as ready for review June 15, 2026 07:52
@jamesadevine jamesadevine merged commit e7bf9c4 into main Jun 15, 2026
@jamesadevine jamesadevine deleted the copilot/fix-shell-injection-vulnerability branch June 15, 2026 07:53
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