doushi9474 2014-01-08 15:08
浏览 17
已采纳

PHP:如果我允许用​​户将内容添加到双引号变量中,是否可以将其操作为漏洞?

This code is used inside a closed source CMS:

If I have a php file set up like this

$var1 = ""; $var2 = ""; $var3 = "";

And allow people to add their own content into the variables, can this be manipulated and turned into a vulnberability? The only way I will be using these variables is echoing out the variables contents and returning the variable in a function.

I just want to make sure that php code can't be entereed into the variables somehow and be processed. I'm not 100% aware of all php vulnerabilities, so figured I'd ask on here.

EDIT

So to give a little more information: I am using this inside a closed source CMS that I've developed. I am giving textarea's for the users to type in their content for that particular variable. They type in their variables, and then it saves to a page via file_put_contents(). This page is a php page included in pages that use this, and basically prevents me from having to store all these variables inside a database. To use the variables, they type (in a template engine) {%var1%} and the variables is replaced with the string using a return from the template engine.

  • 写回答

1条回答 默认 最新

  • douqiaoru2583 2014-01-08 15:13
    关注

    It depends how you're setting $var1-3, you haven't given us any information on this.

    If it's coming from the user (including $_SERVER) they could set it to anything.

    This only becomes a risk if you are working with a database (they could use SQL injection) or printing their value to the page (they could provide javascript).

    There are many ways of avoiding these issues, for example escaping html chars with htmlspecialchars() will avoid javascript injection as it converts the <script> tags to text.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容