473,549 Members | 2,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newsletter Secure Subscribe/Unsubscribe

Hello...
I wrote a simple subscribe script that when a user completes the
subscription form he gets added in the database and then he receives an
e-mail where he/she clicks on the follow link :

<a
href=www.mysite .com?confirm&su bscribers_id=my sql_insert_id($ rs_subscriber_i d)>Confirm</a>

and gets added in the newsletter subscribers.

The problem with that is that you can easily exploit it... if you start
subscribing and then just copy pasting the above url with ascending ids.

Same happens with the unsubscribe.
<a
href=www.mysite .com?unsubscrib e&subscribers_i d=$row_subscrib er_id>Unsubscri be</a>
Exploit: just use random subscriber_ids and start unsubscribing people.

But if that Number was encoded somehow and then decoded... it would solve
the proble... or at least the chances would be less.
Could you please help me ???
Please !!!
Thanks.
Nov 3 '05 #1
7 3413
Angelos wrote:
The problem with that is that you can easily exploit it... if you start
subscribing and then just copy pasting the above url with ascending ids.

Same happens with the unsubscribe.
<a
href=www.mysite .com?unsubscrib e&subscribers_i d=$row_subscrib er_id>Unsubscri be</a>
Exploit: just use random subscriber_ids and start unsubscribing people.

But if that Number was encoded somehow and then decoded... it would solve
the proble... or at least the chances would be less.


Hi Angelos,

You could keep track of the IP addresses and allow only one subscription
and unsubscription per IP per day.
You'd get an extra db table, like:

ip | date | action
=============== =============== ============
123.450.123.450 2005-11-03 subscribe

HTH.
Peter.
--
http://www.phpforums.nl
Nov 3 '05 #2
> You could keep track of the IP addresses and allow only one subscription
and unsubscription per IP per day.
You'd get an extra db table, like:

ip | date | action
=============== =============== ============
123.450.123.450 2005-11-03 subscribe


Thanks for your answer,

I thought about it but... IP address is not the best way to do it... Because
it changes.
I though using the date as a unique identifier... but what happens if two
persons subscribe in the same second.

The only way I can see is something like creating an MD5 from the users id
and then decoding it....
Ofcourse there is no way to decode an MD5... so that's my Question :-)

Cheers
Nov 3 '05 #3
Angelos wrote:
I thought about it but... IP address is not the best way to do it... Because
it changes.
True, but since it's meant to prevent automated scripts subscribing and
unsubscribing (right?) that wouldn't matter.
In case of an ISP using DHCP, the user would have to relogon to his/her
ISP to get the IP changed. So that's pretty unlikely.
The only way I can see is something like creating an MD5 from the users id
and then decoding it....
Ofcourse there is no way to decode an MD5... so that's my Question :-)


Decoding md5 is impossible. But you could use the md5 hash of the id
still. In your confirm script just get the md5 hash of the id and
compare it to the md5 hash specified in the subscribers_id GET-var.

HTH.
Peter.
--
http://www.phpforums.nl
Nov 3 '05 #4
> Decoding md5 is impossible. But you could use the md5 hash of the id
still. In your confirm script just get the md5 hash of the id and compare
it to the md5 hash specified in the subscribers_id GET-var.


Thaaanks ... you just gave me an Idea/Solution

If at the time that I Insert the user in the databse I create an MD5 string
depending either on his e-mail or his id .... and store it in the database
and then compare that.

So Thats All I want !!!
THANKS
Nov 3 '05 #5
Angelos wrote:
Hello...
I wrote a simple subscribe script that when a user completes the
subscription form he gets added in the database and then he receives an
e-mail where he/she clicks on the follow link :

<a
href=www.mysite .com?confirm&su bscribers_id=my sql_insert_id($ rs_subscriber_i d)>Confirm</a>

and gets added in the newsletter subscribers.

The problem with that is that you can easily exploit it... if you start
subscribing and then just copy pasting the above url with ascending ids.

Same happens with the unsubscribe.
<a
href=www.mysite .com?unsubscrib e&subscribers_i d=$row_subscrib er_id>Unsubscri be</a>
Exploit: just use random subscriber_ids and start unsubscribing people.

But if that Number was encoded somehow and then decoded... it would solve
the proble... or at least the chances would be less.
Could you please help me ???
Please !!!
Thanks.


Create an extra table "verificati on" in your database containing:
user_id
verification_co de

Generate a random number for the verification code and save both to the
verification table.

Now send the email with both the user_id and the verification_co de in
the link. When the user clicks on the link, compare both fields. If
they both match, remove the entry from the verification table.

Alternatively - concatenate an internal (known only to you) string to
the user id and MD5 hash the result. Use this as the verification code
and send just that. When the code comes back in, check the hash against
the verification table to get the user id.

(Note: use the string concatenated to the user id instead of a random
number, because random numbers can repeat!).

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 3 '05 #6
Angelos wrote:
Thaaanks ... you just gave me an Idea/Solution

If at the time that I Insert the user in the databse I create an MD5 string
depending either on his e-mail or his id .... and store it in the database
and then compare that.

So Thats All I want !!!
THANKS


No problem. :)
But if you choose to use the subscriber id, there's no need to write the
md5 hash to the database. You could just use the md5 function on the id
and compare it to the md5 hash that was sent by the user.

HTH.
Peter.
--
http://www.phpforums.nl
Nov 3 '05 #7
Following on from Angelos's message. . .
Hello...
I wrote a simple subscribe script that when a user completes the
subscription form he gets added in the database and then he receives an
e-mail where he/she clicks on the follow link :


(1) As you know it is the *wrong thing* to use the user id. No problem,
as others have suggested you use a 'random' key.

(2) You could use a hash (with salt!) or a random number and search your
table for the key when you get the response.

(3) BUT there is a problem with hashing on ID and that is that the hash
remains constant over time. So let's suppose somebody subscribes, you
don't like their posts and 'suspend their account' all they have to do
is re-submit. (OK you could put in /some/ protective logic.)

(4) AND there are missed opportunities. For example "We have sent this
email 'cos you appear to have asked to subscribe... Click HERE to
confirm or HERE if this is incorrect" OK so your URL could be
....?id=1234&co nfirm=Y and .....&confirm=N . Now this encourages
experimentation and one day you'll get papa using mama's id to
'unsubscribe the bitch!'.

So here is (roughly) what I do: Set up a table with a 'random' key, the
command line string that would otherwise have been used, an expiry date
and a group id. Entries are removed when either they expire, or they
are used or one of the other entries in the group is used (so multiple
choices are one choice actioned only). Page logic goes 1-look up action
using big 'random' number on command line 2-If not found take
appropriate actions 3-If found return array of parameters and remove
this action and any in the same group 4-Continue processing according to
action.

This also means you have a single URL for email clicks which then farms
actions out to other scripts. All your security processing can be put in
one place. If the action is 'say look at our terms and conditions' then
there may be no need for a login but for 'look at my details' there
would be.

Basically this is a scheme for lending out keys to your site not giving
them away.

--
PETER FOX Not the same since the borehole business dried up
pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Nov 3 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6366
by: Nicolas | last post by:
Hello, I have programmed an application to manage newsletters in PHP. I send the mails using smtp, but when there are more than 500 subscribers and when the mails (in html) are too big, it is really slow. What can I do gain speed ? Thanks,
4
2150
by: Jeremy Ross | last post by:
Hello, We are looking for a Newsletter Program that is tested and is knowing to work with PHP/MySQL. We will be having allot of people use this newsletter so it should be able to handle sending lots of emails. Also we would need to be able to send the newsletters in HTML format. Free or paid programs are not an issue, just as long as...
1
3236
by: -DRB- | last post by:
Hi all, Off topic... not sure - apologies if so - but I know you guys/gals will be able to help! I would like to set up a subscribe/unsubscribe newsletter service from the website. I've done a bit of research on this and one that seems reasonable priced is Acc Subscribe v1.4 from: http://www.hotcgiscripts.com/
1
1599
by: wm2004 | last post by:
Using HTML, CGI, Perl or anything else to create newsletter automatically. How you go about that. Thanks! Get An Online Business and Make Money! Learn the secrets of many ordinary people who quit their day jobs to pursue an online business. There are many affiliate programs to choose from, but choose an interest you are passionate about and...
0
1638
by: sylvain | last post by:
http://groups.yahoo.com/group/HiTechUnited (Source of articles about the HiTech Underemployment Crisis) HiTechUnited is a weekly newsletter, delivered Mondays, written by and for underemployed/unemployed HiTech workers. Subscribers believe something can be done to improve our situation and we can "Work It Out" together. If you've been...
1
1491
by: Joe | last post by:
Hi, I am looking for an asp or asp.net script that will allow people to subscribe/unsubscribe to mailing/newsletter list. I have seen that there are free PHP scripts but didn’t find any free in asp or asp.net. I would appreciate if you can suggest any scripts that you know that are free or commercial (cheap). Thanks Joe
0
2065
by: Kamilche | last post by:
''' event.py An event manager using publish/subscribe, and weakrefs. Any function can publish any event without registering it first, and any object can register interest in any event, even if it doesn't exist yet. The event manager uses weakrefs, so lists of listeners won't stop them
0
1054
by: Geoff Coope | last post by:
Hi All I have a client that wants a newsletter system that can handle. Templates where they can add images / text Newsletter signup via own website into db UnSubscribe Managament of db and newsletters Anybody know of some php scripts that will aid this or is it something that
0
7527
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7967
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.