Live data from Hacker News

How not to write an API

ghost.teario.com

71–80 of 172 posts

Re: How not to write an API

#71
post #66

Earlier quoted context omitted.

> I like to generate a hash on the client side I'm confused. What do you do with that hash then?

It is sent to the server, instead of the clear-text password. This isn't really necessary if you're using HTTPS, however.

For anyone reading: please just use HTTPS!

Re: How not to write an API

#72
post #66

Earlier quoted context omitted.

> I like to generate a hash on the client side I'm confused. What do you do with that hash then?

It is sent to the server, instead of the clear-text password. This isn't really necessary if you're using HTTPS, however.

Sending a straight hash of the password is no more secure than sending the password in cleartext - an attacker can just replay the hash they sniffed off the network.

As skyebook said, use HTTPS. There's no excuse.

Re: How not to write an API

#73
post #66

Earlier quoted context omitted.

It is sent to the server, instead of the clear-text password. This isn't really necessary if you're using HTTPS, however.

Sending a straight hash of the password is no more secure than sending the password in cleartext - an attacker can just replay the hash they sniffed off the network. As skyebook said, use HTTPS . There's no excuse.

This practice is more to prevent the user's password from being revealed than it is to prevent others from logging in as you. In a trusted environment, you may not care that someone there has access to your account, but you don't want them to know what password you chose.

Having said that, do use HTTPS when possible, but keep in mind some corporate environments force proxies that can see your traffic anyway.

Re: How not to write an API

#74
post #66

Earlier quoted context omitted.

It is sent to the server, instead of the clear-text password. This isn't really necessary if you're using HTTPS, however.

Sending a straight hash of the password is no more secure than sending the password in cleartext - an attacker can just replay the hash they sniffed off the network. As skyebook said, use HTTPS . There's no excuse.

[deleted]

Re: How not to write an API

#77
Whenever I get that plaintext password "vibe" on a site, I like to make my password something somewhat degrading go the site; like "thisSiteSux!", but slightly more vulgar. It's not my fault if they see it.

Once after having gotten the vibe, I ended up on phone support with the site in question. At some point I was instructed to "log back in with ummmm that uhhh same password you signed up with...." I could tell that my plaintext-dar hadn't failed me that time :)

Re: How not to write an API

#78
post #67
post #58

Earlier quoted context omitted.

@Killswitch Problem is PHP is a templating language, not a generic purpose one. Other languages use frameworks for webdevs that usually provide basic security features like auto escaping output,orms by default(so no sql strings),csrf on forms... PHP doesnt ,so it's easier to shoot yourself in the foot.

You mean like Symfony, Laravel, etc? Frameworks that a lot of PHP developers use these days...

You dont need a framework to do PHP webdev, in every other languages,you do.That's my point, PHP IS a templating language,no Symfony,Zend or Laravel can change that. If i write "print" in Python it wont output the result back to HTTP like PHP does. Ruby or Java dont have <?ruby or <?java tags, you get my point.

Re: How not to write an API

#79
post #30
post #3

Short version: http://criticker.com sells access to their API for apps. Any API account can retrieve a list of all users it registered on the site, then retrieve the cleartext password for each user it created. There are so many WTFs in this whole situation that it's a wonder criticker has managed to keep the website online. Which is a shame, as it looks like a really useful website.

I dont think you realize how common the WTFs in this situation are. If you are dealing with a reputable company, this is super super WTF. When you are looking at a small website/API someone made for fun or something....It can normally be badly broken in less than 2-3 minutes....and I'm not even that talented like some of the guys out there.

Security is definitely hard, but security challenges are often proportional to your apps' surface area. If you just have a simple token-based API, your language probably has libraries that can get you started with a reasonably designed security story. It's the same with passwords: at this point, you shouldn't be rolling your own password management system unless you have very specific needs.

For this reason, I don't think "I made it for fun" or "I made it over a weekend" is a good excuse for such broken security. For tiny new apps, it's easier to use a library that does it correctly than it is to roll your own.

Re: How not to write an API

#80
post #42
post #39

Earlier quoted context omitted.

It's not particularly sensitive data being jeopardized- isn't it just movie reviews?

Given the prevalence of password reuse, exposing user passwords is never a good idea.

Just to drive this home a little more: a lot of your users will use the exact same e-mail address and password on your site that they use for their bank. And while they shouldn't do that, they will, and that's why you should use best practices to protect your users' credentials even if their account on your site is completely unimportant.
Post reply on HN