doucheng4660 2019-03-08 22:05
浏览 498

当用户提供任意URL参数时如何防止注入?

We have a core PHP application. We got it tested from a security agency and they notified us that our site is having cross site scripting problem. They have reported same issue on most of the pages. The exact error they reported is

Cross-site scripting (reflected) /users/main/commoncontacts.php [name of an arbitrary supplied URL parameter]

They have also shared the GET request they sent:

/users/main/commoncontacts.php/v8hhi">alert(1)g2gx7

I have spent a lot of time while looking for a solution for this. Everyone talks about different methods for stopping the injection but mainly all talks about parameter value not parameter name. So when a non-existing parameter name is passed then how it shall be happened?

One of my assumption is that I shall use parse_url and parse_str functions to check and suspicious parameter and if find the same then I shall show an error message or send an error response.

Please help.

  • 写回答

1条回答 默认 最新

  • douyao1994 2019-03-08 23:55
    关注

    that's why we need a validation, also trim, htmlentities and htmlspecialchars needed

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题