Drive by query on .NET SqlClient incorrect syntax error

Status
Not open for further replies.

rhy7s

Wise, Aged Ars Veteran
194
Hi there, my mother is listing her business on a website which occasionally throws up the error below when she's editing her listing. The site tech support says it's a problem with her computer, suggesting cookies as the culprit. This isn't my field but that sounds a little iffy, does this seem likely from the following error message she's emailed to me?

Code:
Server Error in '/' Application.
Incorrect syntax near ','.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near ','.

Source Error:

Line 84:         SqlCommand command = new SqlCommand(stQry, conn);
Line 85:         command.Connection.Open();
Line 86:         command.ExecuteNonQuery();
Line 87:         command.Connection.Close();
Line 88:     }


Source File: d:\domains\nzstays.co.nz\wwwroot\App_Code\serv.cs    Line: 86

Stack Trace:

[SqlException (0x80131904): Incorrect syntax near ','.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1950890
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846875
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +317
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   serv.wr(String stQry) in d:\domains\nzstays.co.nz\wwwroot\App_Code\serv.cs:86
   user_edit.btnSubClick(Object sender, EventArgs e) in d:\domains\nzstays.co.nz\wwwroot\user_edit.aspx.cs:447
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
She is using a website where the error and source are presented to the user on failure.

She should probably stop using that site and demand that all of her details are purged from their database...

Even if it is a 'cookie' problem then it means that user sourced data is not going through an appropriate sanitisation before inclusion in a sql query. This is how sql injection attacks happen. From the source code supplied this is almost certainly what is happening.
 

wallinbl

Ars Legatus Legionis
14,319
Subscriptor
The website isn't using parameterized queries, which is a fairly serious security flaw. Most likely, your mother is putting a single quote in a field where the programmer didn't expect it, and because it's just a concatenated string for the database query, it's causing failure.

If your mother has entered anything sensitive on this site (credit card, etc), she should have that information removed - this site is a risk for having its database compromised.

It's terrible that they're blaming this issue on the user - not only are they incompetent, they have terrible customer relations.
 
Status
Not open for further replies.