 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
05-20-2009, 08:19 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
|
Retaining thread ID when posting reply
I know there are already tons of PHP forums available, but this is just a proof of concept for myself I suppose. So the problem I have is when a user goes to post a reply to a thread, I have an invisible input which post the thread ID to the page I have which enters the reply into the database. The actually problem being that the POST field can be easily manipulated allowing the user to change what thread he/she were actually replying to. Now, with that being said. I could check right before the data is going to be entered if the user has permission to post/read/view that thread or category.
There has to be a better way to do this. How can I retain the thread ID that they're replying too?
__________________
|
|
|
05-20-2009, 08:28 PM
|
#2 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
You know, I've read something about this with a possible solution, I can't recall right now what it was though. Hopefully someone else can chime in....
I'm sure there's a pretty easy solution....
|
|
|
|
05-20-2009, 09:55 PM
|
#3 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Always validate ANY sort of input. vB passes the thread number via GET data, it is still safe because you validate it. Validation would consist of you checking in the database if that user (who should also be authenticated) is indeed the owner of the post.
The rule of thumb is that if it is data from the client side, assume its hostile.
|
|
|
|
05-20-2009, 10:07 PM
|
#4 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
I suppose the first question that springs to mind is why would anybody want to alter the POST ID of the thread they're replying to?
Of course, if they wanted to post a nonsensical response in a random thread, they'd navigate to that thread and post. So as long as you're checking if they have permission to post in that thread, and the thread is valid, where does the problem arise? And what does the so-called master hacker achieve?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
05-20-2009, 10:12 PM
|
#5 (permalink)
|
|
The Contributor
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
|
Of course, rule number one. Never trust user input. :)
So maybe something like this:
/reply.php?t=56
And all that 't' GET variable would be is the thread ID.
I guess just keep it simple. Just verify and filter the GET var and go with it. Yeah?
EDIT: After read Wildhoney's post, is it more advantageous to use GET or the hidden input field like I currently am? Does it even matter?
__________________
|
|
|
05-20-2009, 10:36 PM
|
#6 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by h0ly lag
Of course, rule number one. Never trust user input. :)
So maybe something like this:
/reply.php?t=56
And all that 't' GET variable would be is the thread ID.
I guess just keep it simple. Just verify and filter the GET var and go with it. Yeah?
EDIT: After read Wildhoney's post, is it more advantageous to use GET or the hidden input field like I currently am? Does it even matter?
|
I'm not sure it really matters all that much....
|
|
|
|
05-20-2009, 10:43 PM
|
#7 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Nor me. Don't trust the content.
So as long as:
- It's an integer;
- It's a valid thread;
- User has permission to post in the valid thread
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
05-20-2009, 11:38 PM
|
#8 (permalink)
|
|
The Contributor
Join Date: Apr 2008
Location: Nevada, USA
Posts: 52
Thanks: 10
|
Sounds good to me. Oh and is the is_numeric() function sufficient for this?
__________________
|
|
|
05-21-2009, 12:03 AM
|
#9 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by h0ly lag
Sounds good to me. Oh and is the is_numeric() function sufficient for this?
|
Yes
(10 char requirement).
|
|
|
|
05-21-2009, 12:04 AM
|
#10 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by h0ly lag
Sounds good to me. Oh and is the is_numeric() function sufficient for this?
|
Yeah that should work.
|
|
|
|
05-21-2009, 12:21 AM
|
#11 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
There are ways to also attempt to force an integer. Such as if somebody put in 24a then you could, for instance, typecast that value using (int) and it'd become 24.
However, I wouldn't even bother attempting to purify it. If it's anything other than a number, I would assume they've been fiddling and deny the post.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
05-21-2009, 12:35 AM
|
#12 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Wildhoney
There are ways to also attempt to force an integer. Such as if somebody put in 24a then you could, for instance, typecast that value using (int) and it'd become 24.
However, I wouldn't even bother attempting to purify it. If it's anything other than a number, I would assume they've been fiddling and deny the post.
|
1) Shouldn't you be sleeping?
2)I thought var_dump and print_r were used for arrays? I guess you can use it for other things too?
|
|
|
|
05-21-2009, 10:50 AM
|
#13 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by allworknoplay
1) Shouldn't you be sleeping?
2)I thought var_dump and print_r were used for arrays? I guess you can use it for other things too?
|
Mhm, I do it all the time with other data types.
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
05-21-2009, 01:27 PM
|
#14 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Sleeping? Yes, I should!
As for the var_dump. Nooo, I think that is for all data types. Well, that's what I use it for, anyway. I don't use it for arrays though, nor objects. For arrays I use print_r.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|