Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If the tables name in the database are unguessable does it make it more secure?
for example instead of naming the user "USER" we name it "USER-x0001"
does this approach make the database more secure again SQL injection?
Posted
Comments
Suvendu Shekhar Giri 14-Jul-15 12:23pm    
Why not prevent SQL injection?
If you have taken preventive measures for SQL injection then I don't think it makes any sense. However, this is my personal opinion let's see other ideas :)
Richard Deeming 14-Jul-15 12:35pm    
If you've got a spare hour, watch Troy Hunt's video[^] on the mechanics of SQLi. It includes a demonstration (about 29 minutes in) of a tool which can extract all table and column names from the database.

Choosing "unguessable" table names might provide an extra two seconds of protection when your site is attacked. It will also annoy your and any other developer who has to work with the database.

The only solution to protect your database from SQLi is to use parameterized queries.
roysalha 15-Jul-15 7:36am    
Thanks for the video (i will watch it later) and for your quick response.
if user input have been validated and we use parameterized queries like the example below is it enough?

cmd.CommandText = "INSERT INTO [product-SF001] (cat_ID, prod_Name, prod_Description, prod_Img, prod_Active) VALUES (@catID, @prodName, @prodDescription, @prodImgUrl, @isActive)";

cmd.Parameters.Add("@catID", SqlDbType.Int);
cmd.Parameters.Add("@prodName", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@prodDescription", SqlDbType.VarChar, 600);
cmd.Parameters.Add("@prodImgUrl", SqlDbType.VarChar, 250);
cmd.Parameters.Add("@isActive", SqlDbType.Bit);

cmd.Parameters["@catID"].Value = catID;
cmd.Parameters["@prodName"].Value = prodName;
cmd.Parameters["@prodDescription"].Value = prodDescription;
cmd.Parameters["@prodImgUrl"].Value = prodImgUrl;
cmd.Parameters["@isActive"].Value = isActive;

1 solution

No, not significantly. It's possible to use SELECT to return all the table names in a DB.
To avoid SQL Injection, use parameterized queries instead of string concatenation.
 
Share this answer
 
Comments
roysalha 15-Jul-15 7:29am    
hello, thanks for the quick response.
Sorry maybe my question was not clear enough. I am wondering if all preventive measures for SQL injection have been implemented. Does the "unguessable" table name approach make it more secure?
OriginalGriff 15-Jul-15 7:32am    
As I said: "No, not significantly."
You prevent SQL Injection by stopping your users executing their commands, not by trying to limit the damage when they do...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900