I have a web form and I'm using PHP. I'm aware that forms can be manipulated (I believe it's called replay attack or a man-in-the-middle attack). So I'd like to use some authenticity token as a hidden field.
The threat possibilities that I'm aware of are:
- Attacker hijacks the legitimate user's form (this I believe is the man-in-the-middle attack)
- the legitimate user is himself the attacker: he gets the form, reads the token but uses it to send dangerous data (this I believe is the replay attack)
Before I get to the questions, please correct me if anything I said so far is incorrect, because maybe my understanding is flawed.
Now to the questions:
- What is the best practice to generate this token so that the form without it gets rejected (for example, salting?).
- What do people do to make sure that the token isn't being replayed.
Thanks in advance.
Edit: I'm reading more on the topic with the help of your answers. Anyone who helps out with a useful answer/comment gets a +1 :)
New small questions based on comments:
- Is session hijacking the same as man-in-the-middle attack?