by jroseattle · 13y ago · 0 comments
The blind timing-based information leak is pretty clever and makes a nice counterexample to a lot of wrong common-knowledge.
That being said, this is not necessarily an issue with the DB tier as it is with the data input tier.
Why, other than "because one might forget it"?
That is, what if bits of the query depend on various conditions and need to be constructed part by part? Keeping the placeholders and the actual values synced seems like a nightmare in those cases.. unless I am missing something.
public static void AddParameterValue(this SqlCommand cmd, string paramName, object value)
{
if (cmd.CommandText.Contains("@" + paramName))
cmd.Parameters.AddWithValue(paramName, value);
}
to help set parameters only if they are referenced in the SQL statement.