# security question

**URL:** <https://discuss.rubyonrails.org/t/security-question/64346>\
**Category:** rubyonrails-docs\
**Created:** [June 30, 2012, 8:13am UTC](https://discuss.rubyonrails.org/t/security-question/64346 "2012-06-30T08:13:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aram\_harrow](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@aram\_harrow](https://discuss.rubyonrails.org/u/aram_harrow)\
**Post date:** [June 30, 2012, 8:13am UTC](https://discuss.rubyonrails.org/t/security-question/64346/1 "2012-06-30T08:13:59Z")

</div>

Hi all,

I have a perhaps-naive question about section 8.7 on command-line injection:

> **[Securing Rails Applications — Ruby on Rails Guides](https://guides.rubyonrails.org/security.html#command-line-injection)**
>
> Securing Rails ApplicationsThis manual describes common security problems in web applications and how to avoid them with Rails.After reading this guide, you will know: All countermeasures that are highlighted. The concept of sessions in Rails, what...

The code

> `system(``"/bin/echo"``,``"hello; rm *"``)`

> `# prints "hello; rm *" and does not delete files`

is given as an example of a way to sanitize inputs to the system command, but if the attacker can change the second argument here, then this is vulnerable to

`system(``"/bin/echo"``,``"`rm \*`").```

So I think this is a bad example, although I’m not sure what to replace it with, and I am too inexperienced to feel confident changing the ruby guide myself.

-aram

---

<div class="post-metadata">

**Author:** ![Michael\_Pearson](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Michael\_Pearson](https://discuss.rubyonrails.org/u/Michael_Pearson)\
**Post date:** [June 30, 2012, 10:01am UTC](https://discuss.rubyonrails.org/t/security-question/64346/2 "2012-06-30T10:01:50Z")

</div>

Nope. System, in multiple argument mode, does not evaluate the arguments with the shell. So ``, $foo, ~/ etc don’t get evaluated.

$ irb

> > system ‘/bin/echo’, ‘`rm *`’

`rm *`

=\> true

---

<div class="post-metadata">

**Author:** ![fxn](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/fxn/32/12956_2.png) [@fxn](https://discuss.rubyonrails.org/u/fxn)\
**Post date:** [June 30, 2012, 10:02am UTC](https://discuss.rubyonrails.org/t/security-question/64346/3 "2012-06-30T10:02:25Z")

</div>

When system/exec are given several arguments there is no shell expansion going on:

1.9.3-p194 :001 \> system(“/bin/echo”, “`ls`”)

`ls`

=\> true
