I have a comments box in my website
<td id="commentsBox" class="xec" size="200"></td>
I use Javascript to read the comments box and create an XML string.
<ROWS><COMMENTS>My comments</COMMENTS></ROWS>
The XML string is passed to a stored procedure via java. (I have simplified the SQL Code and XML String for the purposes of the question)
CREATE PROCEDURE [DB].[TEST$ExecuteXML] @doc VARCHAR(max)
,@P_Result VARCHAR(max) OUTPUT
AS
BEGIN
DECLARE @idoc INT;
EXEC sp_xml_preparedocument @idoc OUTPUT
,@doc;
INSERT INTO MyTable (
COMMENTS
,UPDATE_DATE
)
SELECT COMMENTS
,getDate()
FROM OPENXML(@idoc, '/ROWS', 1) WITH (
COMMENTS VARCHAR(200) 'COMMENTS'
);
SET @p_result = 1;
END
I have looked at sites dealing with SQL Injection such as https://technet.microsoft.com/en-us/library/ms161953(v=sql.105).aspx
Is it possible to enter something into the textbox that will be destructive to the database?
UPDATE
In response to @Linky I add here (part of) the Java code - although I am at a loss to understand how this could be problematic, as the premise of my question is that the SQL Server procedure could accept anything in the XML.
XMLObject br = new XMLObject(xmlString);
String result = br.update();
public class XMLObject {
public static final int RESULT_FAILED = 0;
public static final int RESULT_SUCCESS = 1;
protected DBConnection dbConn = null;
protected String theXML=null;
public XMLObject(String theXML) {
this.theXML=theXML;
}
public String update() {
String result;
ArrayList<DBField> fields = new ArrayList<>();
fields.add(new DBField(DBField.STRING, theXML, false));
result = DMLUtils.executeString("ExecuteXML", fields);
return result;
}
}