Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Limit submissions over time?

by jhourcle (Prior)
on Jun 18, 2006 at 12:55 UTC ( [id://556078]=note: print w/replies, xml ) Need Help??


in reply to Re: Limit submissions over time?
in thread Limit submissions over time?

Well, you can rely on environmental variables to check the IP of the machine connecting to the server, as it's set by your local webserver. (assuming you trust your local webserver, that is.) Yes, there are issues, but I don't think it's worth ruling them out -- for authentication yes, not it can still be used for authorization, if you know where the problems are.

HTTP_ADDR is very reliable. However, the problem comes that it might not be the IP for the machine that the person is connecting from.

Many proxies will also set X_FORWARDED_FOR, but they're not required to, and those IP addresses aren't necesarily routable, which means that a collision in non-routable space may not be a collision for different proxy servers.

If you're just looking for _some_ sort of rate throtling (ie, better than nothing at all), I'd use a combination of HTTP_ADDR, and X_FORWARDED_FOR. I'd probably not worry about the issues with non-routable colisions, and keep track of the following:

if ( defined $ENV{'X_FORWARDED_FOR'} ) { &track(':'.$ENV{'X_FORWARDED_FOR'}); &track{$ENV{'HOST_ADDR'}.':'.$ENV{'X_FORWARDED_FOR'}); } else { &track{$ENV{'HOST_ADDR'}); }

(specific tracking code depends on what you're planning, how much memory you have, and what other resources (ie, database), you have available.)

Now, let's look at the flaw in my plan -- anyone can send whatever they want in X_FORWARDED_FOR, which would suggest they're a proxy server, and you'd not be rate limiting them if they put something random in it. (it's possible that the original poster would want to rate limit proxy servers at some smaller interval, just to keep the 10,000 possibility down).

Personally, I'd just impose extra sleep for those times of collisions in the case of a proxy -- if you slow it down to one every 30 seconds or so, it makes it less likely that it'll get abused. (and remember that in whatever tracking system you're using, log at the time that it comes in, but set the timestamp to the time that it's expected to run, so if something else comes in while it's sleeping, it won't just wait ($time), it'll wait $time past the current one finishing.

Just remember -- anything you can do will never making spamming impossible. You juat need to make things harder on the spammer so they'll try somewhere else -- hopefully, without imposing too much of a burder on your legitimate users.

Replies are listed 'Best First'.
Re^3: Limit submissions over time?
by davido (Cardinal) on Jun 18, 2006 at 15:35 UTC

    You know, another strategy might be to do some sort of a diff calculation on incoming mail, and if it appears to be, within a certain tolerance for error, approximately equal to one of the past five messages you received, block it.

    This could be made even more secure if you also implement session management (CGI::Session, for example), and even more secure if you also require logins. But again each level of additional protection means additional assumptions about the end user, and/or additional hoops for the end user to jump through.


    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://556078]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found