close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

godaddy websiteprotection scan alert

Thread began 12/15/2010 12:08 pm by lk412779 | Last modified 12/21/2010 8:02 pm by Ray Borduin | 1854 views | 10 replies |

lk412779

godaddy websiteprotection scan alert

my site is hosted on godaddy and the websiteprotection service they offer alerted me to several apparent sql syntax errors that could lead to injection attacks. I've tried several searches here for pertinent info, but have not found anything to help-so sorry in advance if i have missed something obvious. Ive attached the report that the website scanner generated.
I would like to know what changes to the code are necessary to make the site more secure.

here is the code i think it is referencing:

<div class="cartwrapper">
<div class="atcdiv">
<form name="eCart1_1_ATC_3" method="POST" action="/testinfo.php?testid=3" >
<input type="hidden" name="eCart1_1_ID_Add" value="3" >
<input type="text" name="eCart1_1_Quantity_Add" value="1" size="4" >
<input type="submit" class="eC_FormButton" value="Add to Cart" name="eCart1_1_ATC">
</form>
</div>
<div class="vcdiv">
<form name="eCart1_View_form_1" method="POST" action="/testinfo.php?testid=3">
<input name="eCart1_View_1" type="button" class="eC_FormButton" onClick="MM_goToURL('plugins/parent','eCart/')" value="View Cart">
</form>
</div>
</div>

More info:
Also my database tables that contain username, usermail and usermessage (i have a webassist contact form) are getting spammed with things such as <script>alert(42);</script> (which is code that i recognize from the alert i have attached)-
i should say that the input form is not on the page that contains the eCart buttons. Hope any of this info is helping...

Attached Files
details.txt
Sign in to reply to this post

Jason ByrnesWebAssist

please send a copy of your testinfo.php page so I can examine the code.

Sign in to reply to this post

lk412779

Here is the testinfo.php page

Attached Files
testinfopage.txt
Sign in to reply to this post

Jason ByrnesWebAssist

i need a copy of the actual php page. the file you sent seams to be the browser source? I need to see the code on the php page, not the source after it has been processed by the server and rendered in a browser.

Sign in to reply to this post

lk412779

oops, here it tis

Attached Files
testinfo_php.txt
Sign in to reply to this post

Jason ByrnesWebAssist

part of the problem is in hand coding the where clause for the recordset rather than using Dreamweaver to create the filter.

change:
$testid=$_GET['testid'];

to:
$testid=intval($_GET['testid']);



then look for the following code, you will find it twice:

php:
 action="<?php echo $_SERVER["PHP_SELF"]; echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""?>"





and change it to:

php:
 action="<?php echo $_SERVER["PHP_SELF"]; echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".str_replace("\"""&quote;"str_replace(">""&gt;"str_replace("<""&lt;"$_SERVER["QUERY_STRING"]))):""?>"
Sign in to reply to this post

lk412779

Thank you very much for the help Jason, the last scan looked better. I am still having an issue with some of my "simple contact form" fields in my database getting populated with spam so i think i'm going to spend a day doing some reading/learning on this stuff before i go any further. I'll be back!

Sign in to reply to this post

lk412779

Ok, I have posted in the validation section regarding the spam issue but i am still uncertain regarding the way to use Dreamweaver to correctly filter the where clause. I think i understand that by using intval that only values that are passed that are integers will be accepted and i can see that this would be better than a page accepting any string (such as sql code), is there a better way to pass or declare the variable $testid so that i can still have a dynamic page that is fairly secure? If this is an elementary question, plz forgive me, not lookin for a handout, really just looking for a nudge in the right direction :). thanks again-

Sign in to reply to this post

Ray BorduinWebAssist

Use the built in techique of adding parameters to the sql statement. It will automatically add code to prevent sql injection.

Sign in to reply to this post

lk412779

ok, after removing our original fix and using the advanced recordset dialog from the bindings tab in DW the result is a change from


$testid=intval($_GET['testid'])
mysql_select_db($database_mysqlconnection, $mysqlconnection);
$query_Recordset1 = "SELECT * FROM products WHERE ProductID=$testid";

to

$testid_Recordset1 = "1";
if (isset($_GET['testid'])) {
$testid_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['testid'] : addslashes($_GET['testid']);
}
mysql_select_db($database_mysqlconnection, $mysqlconnection);
$query_Recordset1 = sprintf("SELECT * FROM products WHERE ProductID=%s", GetSQLValueString($testid_Recordset1, "int"));


This is what you meant YES?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...