Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Question about XSS attacks
Old 05-30-2011, 03:50 PM Question about XSS attacks
Super Talker

Posts: 113
Trades: 0
I'm trying to create a BBCode for a forum and unfortunately the user's input needs to go into an HTML attribute. I don't know much about XSS attacks, except that it's a very real and potentially serious problem. My question is, how can I prevent an XSS attack if the user input must go inside an HTML attribute?

Would using str_replace() to erase any quotes or apostrophes in the user input be enough to prevent an XSS attack?
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-30-2011, 05:49 PM Re: Question about XSS attacks
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Don't allow any <script> tags and don't exec() any user input code.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-30-2011, 06:11 PM Re: Question about XSS attacks
Super Talker

Posts: 113
Trades: 0
But that wouldn't stop XSS attacks as described in this thread, right?
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Old 05-30-2011, 06:33 PM Re: Question about XSS attacks
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
For BBCode why would you allow the event attributes to be populated?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-30-2011, 06:39 PM Re: Question about XSS attacks
Super Talker

Posts: 113
Trades: 0
I'm trying to allow LaTeX on a forum and the images are generated like this:

Code:
<img src="http://latex.codecogs.com/gif.latex?userinput"/>
So I need to parse the user input and delete whatever characters create an XSS vulnerability. Most of the characters on the keyboard need to be allowed, though, because LaTeX uses most characters.

Last edited by Learnin' n00b; 05-30-2011 at 06:41 PM..
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Old 05-31-2011, 09:15 AM Re: Question about XSS attacks
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You just need to look for, and break character patterns that could present a risk factor

<script, onload,onunload, onclick, onmouse*, exec(, <?, <?php and so on

to kill them you simply insert a space somewhere in the sequence found.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Question about XSS attacks
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.94645 seconds with 12 queries