r/shittyprogramming • u/aerosole • Jan 19 '16
Obfuscate your table names: it will prevent SQL infection!
Don't use obvious names for your database tables like 'users' or 'products'. This makes it easy for malicious users to enter things like ";DROP TABLE users" and drop your tabels. Instead make table names hard to guess by using the same strategies you should use for picking passwords:
Replace letters with numbers: 'us3rs', 'pr0ducts'
You can also prefix them with a salt: 'salt_us3rs', 'salt_pr0ducts'. This should secure any rainbow tables as well. This is really basic stuff and called security through obfuscatery. Take care!
38
u/HelloYesThisIsDuck Jan 19 '16
salt_pr0ducts
I was doing great at obfuscating my tables, until you went and published the name of my bath salts table. Now I'll have to start over.
1
u/flsixtwo Jan 21 '16
Got to watch out naming tables BATH_SALTS, they will start cannibalizing the other tables in the database.
1
u/HugoNikanor Jan 22 '16
You can solve it by obfuscating and salting it a bit more:
salt_s41t_pr0ducts2
19
u/redneckrockuhtree Jan 19 '16
So....SAP?
5
3
u/nickcash Jan 20 '16
There's something about the combination of meaningless names like PA0001 and German abbreviations that makes them maddening to work with.
15
u/YMK1234 Jan 19 '16
Now we just need a way to obfuscate the system tables and we are done :D
6
u/causalNondeterminism Jan 19 '16
when I discovered
select * from information_schema.columns, my job at a software company which didn't document much of anything improved dramatically.7
u/YMK1234 Jan 19 '16
result like "column1, column2, column2a, column3, column_1, ..."
1
u/causalNondeterminism Jan 19 '16
*cringe* and then I found out that DB2 for i has a second set of column descriptors so they never had to care about SQL column names because those are the only ones which display on 5250.
12
u/ThisIsADogHello Jan 19 '16
Using salts is a pretty common technique and most hackers will expect it. Use some other less common spices instead, for example you may wish to use the table name basil_us3rs
6
2
19
u/foonix Jan 19 '16
Just set the table prefix to "because_ima_f4g0rt_". Hackers will be too embarrassed to type that.
8
u/Neebat Jan 19 '16
If your table names are too obfuscated to query, does that mean you're using No-SQL?
3
u/Lucky_Chuck Jan 19 '16
Maybe all you need to do is use language that isn't standardized so SELECT would still be select, but it'll be in a different language that doesn't have a standard.
6
Jan 19 '16
if you are haunted by a programming goblin, be sure to name at least one of your tables his name in reverse so that he might accidentally speak it out loud while muttering in front of his terminal, and get sucked back into the Sumerian puzzle cube he came from.
3
Jan 19 '16
You used to work at my company, didn't you? You are an unsung genius, and I salute you. With one finger.
3
3
Jan 19 '16
Does it have to be any kind of salt? Is chicken salt okay as well as table salt? I like chicken salt.
3
u/VelvetineRabbit Jan 20 '16
These answers are all terrible. Use a zero width non joiner! Attackers won't even be able to see it! And who knows? Maybe it will confuse malicious JOINers???
2
u/abermea Jan 19 '16
'salt_us3rs', 'salt_pr0ducts'
Well, last time I checked, people usually put salt on tables
2
Jan 20 '16
So what salt should I use? Is common table salt OK, or is it more secure to use some more uncommon salt like cupric slufate?
2
2
Jan 21 '16
I can't tell if this is supposed to be something stupid because I don't know enough about SQL
1
0
Jan 19 '16
[deleted]
36
0
Jan 19 '16
[deleted]
14
4
u/FlipTheTables Jan 19 '16
pls back off my table
┬─┬ノ(ಠ_ಠノ)
5
Jan 19 '16
(o・_・)ノ”(ノ_<。)
Stop that.
(╯°□°)╯︵ ┻━┻
0
28
u/hatsune_aru Jan 19 '16
I like to have my table name encrypted as the MD4 of what it should be, like MD4("users").