Author Topic: Unfiltered form accepts <script> tag , it's dangerous ?  (Read 2237 times)

0 Members and 17 Guests are viewing this topic.

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Unfiltered form accepts <script> tag , it's dangerous ?
« on: December 13, 2013, 08:42:57 pm »
Hello , i have a message form which saves the contents to database and shows it when requested , i used to filter some hardcoded tags like <?php ?> but i found it is vulnerable to <script>alert(1);</script>


Javascript is client side , so the vulnerability is dangerous only for clients (there are no clients till now). Is there any rush for me to patch this bug as soon as possible ? Is there any fear for compromising my server or find any info for the server ?

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #1 on: December 13, 2013, 08:46:20 pm »
so then why don't don't you use regex and strip the tags, or just remove the text along with those tags...? however I am sure there are better ways to do it :P

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #2 on: December 13, 2013, 08:56:10 pm »
so then why don't don't you use regex and strip the tags, or just remove the text along with those tags...? however I am sure there are better ways to do it :P


I don't want to remove all tags , im using regex to find the tags i want to remove but i didn't thought about script ! is this dangerous at the moment i have to rush ? Always talking for the server !

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #3 on: December 13, 2013, 09:06:39 pm »
Yes, patch it. You never want something that can run scripts or code without your direct control over. Having clients being able to store and run scripts is bad.
>>>import this
-----------------------------

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #4 on: December 13, 2013, 09:26:44 pm »
Thanks !! i will , i im controlling tags like this :


if user wants to post <?php echo phpinfo(); ?> i will make it <!--?php echo phpinfo(); ?-->


is this enough ?


im using php 5.3.3

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #5 on: December 13, 2013, 09:28:26 pm »
Why not remove or reject the entries?
>>>import this
-----------------------------

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #6 on: December 13, 2013, 09:32:43 pm »
Why not remove or reject the entries?


Don't know just a quick thought , is it insecure way ? or just a waste..
« Last Edit: December 13, 2013, 09:33:05 pm by invader7 »

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #7 on: December 13, 2013, 09:40:49 pm »
It's a quick and dirty way, but removing the entries all together would be ideal.
>>>import this
-----------------------------

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #8 on: December 13, 2013, 09:47:13 pm »
It's a quick and dirty way, but removing the entries all together would be ideal.




thanks !!

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #9 on: December 13, 2013, 09:53:03 pm »
This is a classic XSS example. I suggest you read up on it. Why don't you just filter everything with htmlspecialchars() or htmlentities()? I sure hope you are escaping the database query with PDO prepared statements or mysql_real_escape_string()
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #10 on: December 13, 2013, 10:03:08 pm »
This is a classic XSS example. I suggest you read up on it. Why don't you just filter everything with htmlspecialchars() or htmlentities()? I sure hope you are escaping the database query with PDO prepared statements or mysql_real_escape_string()



Yes i have my queries secured thanks !! I know im XSS vulnerable right now but its ok because im in development stage , for one moment i thought that im exposing my server to a server side script. But im safe ! Client side attacks are harmless for the server (i think :P )

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #11 on: December 13, 2013, 10:21:59 pm »



Yes i have my queries secured thanks !! I know im XSS vulnerable right now but its ok because im in development stage , for one moment i thought that im exposing my server to a server side script. But im safe ! Client side attacks are harmless for the server (i think :P )


Client side attacks (XSS) would allow an attacker to steal your session(s)/cookies and be logged in (if there is a login) without even typing username/password. But you are correct. XSS cannot harm the server directly.
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #12 on: December 13, 2013, 10:30:55 pm »
Client side attacks (XSS) would allow an attacker to steal your session(s)/cookies and be logged in (if there is a login) without even typing username/password. But you are correct. XSS cannot harm the server directly.


Yes i know about cookie stealing , i was afraid about posting <?php tags to my messages. Thanks a lot for your time !! I appreciate it !

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #13 on: December 13, 2013, 11:26:32 pm »

Yes i know about cookie stealing , i was afraid about posting <?php tags to my messages. Thanks a lot for your time !! I appreciate it !

The PHP tags/code wouldn't be able to execute unless you ran it through eval().
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline invader7

  • /dev/null
  • *
  • Posts: 12
  • Cookies: 0
    • View Profile
Re: Unfiltered form accepts <script> tag , it's dangerous ?
« Reply #14 on: December 13, 2013, 11:36:05 pm »
The PHP tags/code wouldn't be able to execute unless you ran it through eval().


What do you mean , how i'm supposed to run eval() if i cant enclose it at <?php tag ?