Securing a Contact Form

北城余情 提交于 2019-12-05 07:14:45

问题


I have a client whose website I created with Wordpress. It has a contact form created with contact form 7. This client is a subsidiary of a larger organization who's IT department runs scans on their subdomains. The asked my client to protect Contact Form 7 from malicious scripts or take it down.

When I asked for an example of what they tested, my client informed me that they run tests to see if a script could be inserted into a input (ie: <script>alert('hello');</script>) field or as a url string (ie: www.mydomain.com/contact?<script>alert('hello');</script>).

With the query string, the contact form sets the action to: action="/?scriptalert('hello');/script#wpcf7-f1-p6-o1". My first question would be, will this harm anything since the "<" and ">" has been removed from the string?

If so, is there anything I can add to remove the possibility of running scripts in this contact form?


回答1:


HTML Encoding is one way to prevent any HTML/JS from taking effect. It's a good idea to encode any user-supplied value before displaying it in the page.

See http://ca3.php.net/manual/en/function.htmlentities.php



来源:https://stackoverflow.com/questions/6685761/securing-a-contact-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!