SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Client string data altered - SQL 2000

Client string data altered - SQL 2000

Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 23
Note to moderators: please move this post to appropriate category if this category was intended only for the Security Skills Exam discussions.

2nd Edit: Okay, back to original claim. Further testing in php to develop a workaround indicates the problem is not with the php parser as the string is not being altered until after being passed to the db client or the interface to the db client.

Edit: I just realized the problem might be related to the php parser considering 'backslash newline' as a line continuation sequence and removes it before calling the sql client. And, I just proved it. Odd that it would remove 'backslash newline' from the middle of a string, but it seems that it does. In php, this query, "insert unittest (teststring) values ('e\\\\\x0a\x0ae')" results in 'e\e', which is what I wanted. By adding an extra back slash before and new line after, the parser removes the inner set but leaves the outer set alone (thankfully). I am going to leave this post for the next person with simular problem. (note: the result string that I claim is what I want has a square box to indicate the new line character, but in order to show it in this post, I substituted a non-printable UTF-8 html escape sequence character.)

Original Post:
I have been security testing sql injection attack vectors from php application. Most articles note that single quote has to be escaped as two single quotes to prevent early termination of the input string, AND validate any other potentially dangerous character sequences -- but fail to mention what those 'potentially dangerous character sequences' (aka PDCS) are.

I set up a unit test in php to brute force all character permutations to identify PDCS. I found odd behavior with dblib and ADO clients altering my test strings. It appears that the client libraries will respond to the backslash character as an escape character introducer, but only before the characters (found so far), 0x0a (LF), 0x0d (CR), 0x10 (DLE), and 0x3d (=).

The test strings are 4 character permutations that range from 0-255. I've tested SQL2000 to insure varchar will correctly insert and select these strings without altering them. I use the default collation SQL_Latin1_General_CP1_CI_AS.

In Query Analyzer the following TSQL inserts the string without error or alteration:

schema: create table unittest (utID int IDENTITY, teststring varchar(10))

declare @s varchar(10)
set @s = 'e\'+char(10)+'e'
insert unittest (teststring) values (@s)

When using a client, the backslash and LF are stripped out of the string and only 'ee' is stored. I can store 'e\e' and 'e'+char(10)+'e' without error, but not 'e\'+char(10)+'e'.

I set up DB-Library Options in the Client Network Utility with 'Automatic ANSI to OEM conversion' unchecked to avoid the client from altering some characters from 128-255.

I've tried escaping the escape introducer (backslash) without success.

I've also searched the internet for the last two weeks for any hint of what is occurring here and how to disable or hack around it. Got nothing.

Any help or insight here will be much appreciated.


You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum