PHP security - cheating form submission

黄舟
Release: 2023-03-05 22:06:02
Original
1904 people have browsed it



Spoof form submission

Creating a spoofed form is almost as easy as forging a URL. After all, form submission is just an HTTP request made by the browser. Part of the format of the request depends on the form, and some of the data in the request comes from the user.

Most forms use a relative URL address to specify the action attribute:

  <form action="process.php"
method="POST">
Copy after login


When the form is submitted, the browser requests the URL specified in the action, and it uses the current URL address to locate the relative URL. For example, if the previous form was generated in response to a request for http://www.php.cn/, the URL address http://www.php.cn/ will be requested after the user submits the form.

Knowing this, it is easy to think that you can specify an absolute address so that the form can be placed anywhere :

<form
action="http://example.org/path/to/process.php" method="POST">
Copy after login


This form can be placed anywhere, and the submissions produced using this form are the same as those produced by the original form. Realizing this, an attacker can view the source file of the page and save it on his server while changing the action to an absolute URL address. By using these methods, an attacker can arbitrarily change the form, such as removing the maximum field length limit, removing local validation code, changing the value of a hidden field, or rewriting the element type for more flexible purposes. These changes help an attacker submit any data to the server, and because the process is so simple and easy, the attacker does not need to be an expert to do it.

Spoofed form attacks cannot be prevented, and although this may seem a bit strange, it is actually true. But you don't need to worry about this. Once you filter input correctly, users must follow your rules, regardless of how they submit.

If you experiment with this technique, you may notice that most browsers include a Referer message in the HTTP header to identify the address of the previous page. In this example, the Referer value is the URL address of the form. Please don't be fooled by it and use it to differentiate between your form submissions and spoofed form submissions. In the demonstration in the next section, you can see that HTTP headers are also very easy to forge, and the method of using Referer to determine is well known.

The above is the content of PHP security-spoofing form submission. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!