Exposing table name and field names in request URL

后端 未结 3 667
抹茶落季
抹茶落季 2021-01-12 19:16

I was tasked to create this Joomla component (yep, joomla; but its unrelated) and a professor told me that I should make my code as dynamic as possible (a code that needs le

相关标签:
3条回答
  • 2021-01-12 19:43

    I have no problem with using the same (or very similar) names in the URL and the database — sure, you might be "exposing" implementation details, but if you're choosing radically different names in the URL and the DB, you're probably choosing bad names. I'm also a fan of consistent naming — communication with coders/testers/customers becomes much more difficult if everyone calls everything something slightly different.

    What bugs me is that you're letting the user run arbitrary queries on your database. http://.../index.php?table=users&user_id=1, say? Or http://.../index.php?table=users&password=password (not that you should be storing passwords in plaintext)? Or http://.../index.php?table=users&age=11?

    If the user connected to the DB has the same permissions as the user sitting in front of the web browser, it might make sense. Generally, that's not going to be the case, so you'll need some layer that knows what the user is and isn't allowed to see, and that layer is a lot easier to write correctly by whitelisting.

    (If you've stuck enough logic into stored procedures, then it might work, but then your stored procedures will hard-code column names...)

    0 讨论(0)
  • 2021-01-12 19:54

    Your aliasses could be a rot13() on the meta/name of your objects.

    Although, if you escape the input accordingly when working with those names, I don't see any problem in exposing their names.

    0 讨论(0)
  • 2021-01-12 20:02

    When composing a SQL query with data from the input, it presents a security risk. But keep in mind that columns values are inserted to the fields by taking input from the user, analyzing it and composing a SQL query with it (except for prepared statements). So when done properly, you have nothing to worry about - simply restrict the user to those column & tables. Open source software's code/database is visible to all - and it doesn't harm the system so much as one would think.

    0 讨论(0)
提交回复
热议问题