Skip to content

[fix] escape shell metachars in chdir: to prevent injection#9451

Open
kares wants to merge 1 commit into
jruby:jruby-10.0from
kares:fix-chdir-escape-10
Open

[fix] escape shell metachars in chdir: to prevent injection#9451
kares wants to merge 1 commit into
jruby:jruby-10.0from
kares:fix-chdir-escape-10

Conversation

@kares
Copy link
Copy Markdown
Member

@kares kares commented May 20, 2026

PopenExecutor constructs a cd '<dir>'; ... for the chdir: option in spawn/system/IO.popen;

directory path was embedded in single quotes without escaping, allowing single-quote breakout command injection:

  system('echo hello', chdir: "x'; touch /tmp/pwned; echo '")

p.s. MRI uses the POSIX chdir syscall directly and is not affected

PopenExecutor constructs a "cd '<dir>'; ..." for the chdir: option in
spawn/system/IO.popen; the directory path was embedded in single quotes
without escaping, allowing single-quote breakout and arbitrary command
injection:

  system('echo hello', chdir: "x'; touch /tmp/pwned; echo '")

MRI uses the POSIX chdir syscall directly and is not affected
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.

1 participant