-1

I've got a website with multiple pages that have html forms. But I'm getting bombarded with weird data that does not belong in the field. Example:

\'\"><svg/onload=(new(Image)).src=\'//rytk88vs0h2tc4yierrvrpgr2i8lwdm1eo8cx\\56burpcollaborator.net\

But this is supposed to be a

<select><option></option></select>

It is not a text input field. So how is the person submitting weird code above? How can I prevent this?

mega6382
  • 9,211
  • 17
  • 48
  • 69
Kakenx
  • 1,315
  • 3
  • 18
  • 34

2 Answers2

5
\'\"><svg/onload=(new(Image)).src=\'//rytk88vs0h2tc4yierrvrpgr2i8lwdm1eo8cx\\56burpcollaborator.net\

This is an attempt at an XSS attack.

So how is the person submitting weird code above?

  1. A form describes a user interface.
  2. The browser constructs that UI and presents it to the user
  3. The user enters data into the form
  4. The browser takes that data and formats it into an HTTP request

BUT there is nothing stopping someone from using some other method to construct an HTTP request and sending it to your server.

How can I prevent this?

You can't control what people send to your server.

You can only take steps to prevent it being harmful.

There is plenty of documentation out there on how to defend against SQL injection, XSS, and CSRF (which are the most common attacks).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • As mentioned in the OP's comment chain, [OWASP's PHP Security Cheat Sheet](https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet) is an excellent resource for common security vulnerabilities. – Script47 Apr 10 '18 at 08:54
0

it is an attempt to propertyinjection. you should always check, what values your form sends on submit. in this case you will probably expect an id as it is a select. a simple method to check if it is valid:

$alloptions = array(1 => 'Option A', 2 => 'Option B');

if(isset($_POST['select'])){
 if(!array_key_exists($_POST['select'], $alloptions)){
  echo 'error';
 }
}

foreach($alloptions as $optionid => $optionname){
 echo '<option value="'.$optionid.'">'.$optionname.'</option>;
}
Bernhard
  • 1,852
  • 11
  • 19