Quantcast
Channel: LowEndTalk
Viewing all articles
Browse latest Browse all 39981

php security experts...submitting forms safely

$
0
0

Let's say I have a form that looks like this:

<form action="/script.php" method="post"> <input name="my_input" length="80" /> <input type="submit" value="submit" /> </form>

Now I also want to include a numeric identifier - call it a ticket id. "Here's the ticket history, do you want to add something?" The user can't modify that.

My question is...what is the safest way to get that ticket id in the form submission?

No problem accomplishing it, but my question is around security. So here are the ways to get a variable back that I can think of:

<form action="/script.php" method="post"> <input name="my_input" length="80" /> <input type="hidden" name="ticket_id" value="12345" /> <input type="submit" value="submit" /> </form>

or

<form action="/script.php?ticket_id=12345" method="post"> <input name="my_input" length="80" /> <input type="submit" value="submit" /> </form>

I'm concerned that someone could craft a malicious POST and submit it and append their comments to a different ticket. i.e., compose a POST from their own server/browser/tool. If I was doing this with GET then they certainly could do that just by changing the url vars - it's possible to do that also with POST too, right?

I can check that the user owns that ticket of course and do some other validation, but fundamentally, how do you present data to a user and safely get it back again in an HTML form?

Is there something other than creating a unique serial number ("FORM 12345 should present ticket id 6789") record on the server side and then checking it back?

I'm using PHP & MySQL on the backend though I'm not sure my question is specific to those technologies.


Viewing all articles
Browse latest Browse all 39981

Trending Articles