# Secuiyrt issue in App

**URL:** <https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345>\
**Category:** Rails\
**Created:** [April 5, 2010, 12:11pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345 "2010-04-05T12:11:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 5, 2010, 12:11pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345/1 "2010-04-05T12:11:14Z")

</div>

Hi,  
I am facing a following problem:-  
I have app in which user can edit his/her personal information and we  
are showing it on browser. Some of users has added  
“” javascript in name textbox. Due to  
this whenever I am showing name on browser it is executing the script  
and giving javascript alert.  
Can anyone tell me how to fix this? Is there any plugin avaliable?

Thanks,  
Tushar

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 5, 2010, 12:29pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345/2 "2010-04-05T12:29:44Z")

</div>

use  
\<%= h @user.information %\>  
This will escape angle brackets and therefore neutralize any embedded  
JavaScript

ushar Gandhi wrote:

> Hi,  
> I am facing a following problem:-  
> I have app in which user can edit his/her personal information and we  
> are showing it on browser. Some of users has added  
> “” javascript in name textbox. Due to  
> this whenever I am showing name on browser it is executing the script  
> and giving javascript alert.  
> Can anyone tell me how to fix this? Is there any plugin avaliable?
> 
> Thanks,  
> Tushar

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 5, 2010, 12:37pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345/3 "2010-04-05T12:37:34Z")

</div>

On 5 April 2010 11:29, Charanya N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> use  
> \<%= h @user.information %\>  
> This will escape angle brackets and therefore neutralize any embedded  
> JavaScript

_Any_ user entered data that you display should be escaped in this  
way. You are lucky that no-one with more malicious intentions has  
found the hole in your system.

I strongly suggest that you study the guide on securing rails  
applications at [http://guides.rubyonrails.org/](http://guides.rubyonrails.org/). There may be other  
more serious holes in your app.

Colin

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 5, 2010, 12:40pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345/4 "2010-04-05T12:40:51Z")

</div>

Charanya N. wrote:

> use  
> \<%= h @user.information %\>  
> This will escape angle brackets and therefore neutralize any embedded  
> JavaScript
> 
> ushar Gandhi wrote:
> 
> > Hi,  
> > I am facing a following problem:-  
> > I have app in which user can edit his/her personal information and we  
> > are showing it on browser. Some of users has added  
> > “” javascript in name textbox. Due to  
> > this whenever I am showing name on browser it is executing the script  
> > and giving javascript alert.  
> > Can anyone tell me how to fix this? Is there any plugin avaliable?
> > 
> > Thanks,  
> > Tushar

Thanks a lot.  
It is working fine.

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 5, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345/5 "2010-04-05T14:31:06Z")

</div>

Yes, you can escape user data. But you also should not allow the  
original  
request (with the “Hack”) to complete. Try to use mod\_security in your  
apache installation!

2010/4/5 Tushar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > > are showing it on browser. Some of users has added  
> > > –  
> > > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
MÃ¡rio SÃ©rgio Coelho Marroquim

> **[blogdomario](https://blogdomario.wordpress.com/)**

[http://www.muraldeideias.com.br](http://www.muraldeideias.com.br)

> **[Home - Credishop](https://www.credishop.com.br/)**
>
> Mais conquistas na sua vida Crédito aprovado com facilidade Possibilidade de usar o crédito rotativo Cartão adicional totalmente grátis Parcela suas compras Pode ter 42 dias para pagar Aceito em diversos estabelecimentos … menos é Leia mais…

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 5, 2010, 4:38pm UTC](https://www.ruby-forum.com/t/secuiyrt-issue-in-app/186345/6 "2010-04-05T16:38:06Z")

</div>

On Mon, Apr 5, 2010 at 5:29 AM, Mario Sergio Coelho Marroquim  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes, you can escape user data. But you also should not allow the original  
> request (with the “Hack”) to complete. Try to use mod\_security in your  
> apache installation!

Is there a non-Apache-httpd equivalent?

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
