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

Closed Thread
Cross Site Scripting Advise Please.
Old 05-19-2010, 10:01 AM Re: Cross Site Scripting Advise Please.
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
The main you need to know about cross site scripting is that any time a form submits data or a query contains data which is then displayed on the page, that data should first be escaped in some way before being displayed. The main functions used for this are:

1. strip_tags() to remove HTML characters in favor of plain text
2. htmlspecialchars() or htmlentities() to display HTML in a way that is readable, but won't be interpreted by the browser.

The other big thing is that you should keep the register_globals in php.ini turned OFF. It is off by default now days, but it didn't used to be, and a lot of servers still keep it on. This was a very poorly thought out directive as it allows anyone to take over any empty variable on the page by simply querying it ?var=value.

XSS, if successful, lets malicious users do all sorts of nasty things.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
View Public Profile Visit wayfarer07's homepage!
 
 
Register now for full access!
Old 05-19-2010, 10:57 AM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
Quote:
Originally Posted by chrishirst View Post
No no, it's because "product_page.php" is there.

Passing a target page is what makes it potentially a weakness, because an "attacker" could replace "product_page.php" with "remoteURI.tld" and if you have failed to "sanitise" the GET parameters, could be including the content from or redirecting to that remote URI.
Ok, a long shot but...

Would adjusting the code that generates the buy button that TAKES you to the basket stop the "product_page" from being inserted?

** EDIT **

Ive now got the URL displaying as basket.php?src=Array&productID=123456

Would this be any better PCI wise??
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."

Last edited by rolda hayes; 05-19-2010 at 12:12 PM.. Reason: Clearing up a typo!
rolda hayes is offline
View Public Profile
 
Old 05-19-2010, 11:16 AM Re: Cross Site Scripting Advise Please.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It should be because possible hackera can now only alter the product IDs, and provided your receiving code "cleans" the values for injection attacks there is limited scope for hijacking or malicious attacks.
__________________
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
View Public Profile Visit chrishirst's homepage!
 
Old 05-19-2010, 11:27 AM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
Wow! may be getting somewhere here!

Running another scan so I'll let you know!

Indy-Dance.gif
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
View Public Profile
 
Old 05-19-2010, 02:54 PM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
Nope.... scans finished and Still comes back as a security fault...
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
View Public Profile
 
Old 05-19-2010, 03:12 PM Re: Cross Site Scripting Advise Please.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Are you processing card information on your own site or are you using a payment gateway?

PCI is all about protecting financial data inside your own systems both online and offline.
If you change domains to process the card data it may be possible that the test process could be detecting this as a possible XSS vulnerability.
__________________
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
View Public Profile Visit chrishirst's homepage!
 
Old 05-19-2010, 03:14 PM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
Processing on own site. (info being sent to us, then manually running through PDQ terminal.)
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
View Public Profile
 
Old 05-19-2010, 11:05 PM Re: Cross Site Scripting Advise Please.
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
On the SQL injection side of this, these two videos may help you to understand what this threat is all about a little better:

Part 1: http://www.youtube.com/watch?v=YyaQw0ae_7I

Part 2: http://www.youtube.com/watch?v=e4EYkoLlSq0
Marik is offline
View Public Profile
 
Old 05-20-2010, 05:25 AM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
again... a long shot but...

Could I use ModRewrite to change the url to something better??
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
View Public Profile
 
Old 05-20-2010, 05:28 AM Re: Cross Site Scripting Advise Please.
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
Quote:
Originally Posted by rolda hayes View Post
again... a long shot but...

Could I use ModRewrite to change the url to something better??
You can, absolutly, but it wont remove the risk of someone injecting into your variables. You will still need to clean the input and do some data validation/sanitisation.
Phunk Rabbit is offline
View Public Profile Visit Phunk Rabbit's homepage!
 
Old 05-20-2010, 08:04 AM Re: Cross Site Scripting Advise Please.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by rolda hayes View Post
again... a long shot but...

Could I use ModRewrite to change the url to something better??
You can and does disguise the nature of the URL somewhat so it may well fool the scanner

Quote:
Originally Posted by Phunk Rabbit View Post
You can, absolutly, but it wont remove the risk of someone injecting into your variables. You will still need to clean the input and do some data validation/sanitisation.
Agreed. No matter what method is used to construct the URIs, user input should be "cleaned". Especially when passing data via a GET method.
__________________
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
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2010, 06:34 AM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
Ok, an update on things...

I've added:

PHP Code:
$_POST filter_var_array($_POST,FILTER_SANITIZE_STRING);
$_GET filter_var_array($_GET,FILTER_SANITIZE_STRING); 
to the top of the page, and this is stopping the pop up window injection when testing the URL.

What they are (now) saying... is that indeed the url must be cleaned and it should not show in the href= of the page.

so I need to remove the end of the generated URL:

basket.php?src="><script>alert(123)<%2Fscript>&amp =&productID=1126558"



Any ideas now where to go??
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
View Public Profile
 
Old 05-27-2010, 11:20 AM Re: Cross Site Scripting Advise Please.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
All the link should need (and have) is the product ID ref
__________________
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
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2010, 12:21 PM Re: Cross Site Scripting Advise Please.
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
I don't think that the filter_var_array() function is going to be enough to sanitize your data. I'm fairly certain that you'll still be open to SQL Injection. From what I can tell, you're just basically using it to strip tags, which isn't enough. You'll want to use mysql_real_escape_string() for anything that you're putting in a database query. You'll find the PHP Security Consortium a very helpful resource as it will explain about the different types of attacks and how to prevent them. There are quite a few that this code is vulnerable to and I'd suspect that you'll have to look at every single file individually. It only takes one vulnerability to compromise a site, so you could be 99% covered and it doesn't matter if an attacker finds that last 1%.
__________________
Want new web resources every day? - Follow me on
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by VirtuosiMedia; 05-27-2010 at 12:50 PM..
VirtuosiMedia is offline
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 05-27-2010, 02:43 PM Re: Cross Site Scripting Advise Please.
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 961
Name: Darren
Location: England
Trades: 0
I AM PCI COMPLIANT!!!!!

A big thanks to everyone who has contributed to this thread!!!


Indy-Hat-Tip.gif
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
View Public Profile
 
Closed Thread     « Reply to Cross Site Scripting Advise Please.

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.46034 seconds with 12 queries