create account

A silly mistake most programmers make by febin

View this thread on: hive.blogpeakd.comecency.com
· @febin ·
A silly mistake most programmers make
I found this security bug in one of the prominent food startups of India. All their customer data including residential info , order info and contact details were vulnerable.
![Exposed Customer Data](https://cdn-images-1.medium.com/max/800/1*1pQJw5UecS6xC5FYEi6uLw.png)

Look at the following code.
````
@app.route(“/customer/info”)
def customer_info():
  customer_id = requests.args.get(‘customer_id’)
  customer = customers.query.filter(Customer.id==customer_id).one()
  customer_schema.jsonify(customer)
````

A customer of id 5453 will have the following request URL

````
http://server_ip/customer/info?customer_id=5453
````

Now look at the URL, the id is a number. A hacker will try changing the number from 5453 to 5454

````
http://server_ip/customer/info?customer_id=5454
````

This will allow him to fetch details of the customer with id 5454, which he is not supposed to see. Now he can write a script which loops through customer ids and fetch information; he has hacked into a company’s confidential data.

This can be prevented by adding authentication to check if the user has privileges to access the data. A unique string identifier is much better than an integer identifier.
👍  
properties (23)
authorfebin
permlinka-silly-mistake-most-programmers-make
categoryprogramming
json_metadata{"tags":["programming"],"image":["https://cdn-images-1.medium.com/max/800/1*1pQJw5UecS6xC5FYEi6uLw.png"],"app":"steemit/0.1","format":"markdown"}
created2018-05-27 22:34:33
last_update2018-05-27 22:34:33
depth0
children0
last_payout2018-06-03 22:34:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,193
author_reputation245,954,781
root_title"A silly mistake most programmers make"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id58,015,552
net_rshares120,513,836
author_curate_reward""
vote details (1)