dsf11t5u1651 2013-01-07 18:02
浏览 42
已采纳

我应该尽可能地将URL隐藏到脚本中吗?

I'm fairly new to php and here is something I wonder what to do with.

For several functionalities on my site I have a php script which handles the actions after a user clicks something. i.e.:

<a href='/php/delete.php?id=xxx'>delete</a>

<form action='/php/handleregistration.php' method='post'></form>

In my code these links are easily visible as you view the source code, but looking at other websites' code these kind of references are much harder to find. I suppose most is handled by the same types of php scripts but through some javascript/jQuery.

So, my question is, Should I do this? Why and what's the best way to do it?

  • 写回答

4条回答 默认 最新

  • douzhongqiu5032 2013-01-07 18:06
    关注

    I don't believe you need to worry. You should always write secure code, and validate and sanitise your data before doing anything with it anyways. I.E: don't assume id=xxx is valid, as someone could manually type something knowing the script URL.

    Most of the sites you see are probably using a framework or some sort of url rewriting. This makes the URL's look nicer (even scripts). It doesn't add much in the way of security though, this could be considered Security through Obscurity. It would do nothing more than prevent someone who doesn't know what they are doing from an easy attack. It would never stop a skilled attacker, and this is why security should be implemented on the server side.

    Edit:

    As a side note, you may want to use POST for delete just to prevent some nasty unforseen consequences. As Tim said, you should have a delete confirmation page, cause even if the user is logged in, it doesn't mean they are in control.

    Imagine a website with an iframe set to width=0 and height=0 src=http://yoursite.com/php/delete.php?id=xxx

    This would cause the logged in user to delete their account. (Or change password, charge credit card, etc) without their knowledge.

    Of course changing GET to POST doesn't completely resolve this issues, but its one step of many to take in securing web apps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站