Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
tef
May 30, 2004

-> some l-system crap ->

qntm posted:

the track record of reliability that those programs have proved themselves to have (a level of reliability which any replacement program would have to match)

this just shows how far we've come in 40 years of software engineering.


similarly old editors like vi and emacs being popular show that we haven't really progressed in terms of interface either.

Adbot
ADBOT LOVES YOU

Mrs. Wynand
Nov 23, 2002

DLT 4EVA
We've progressed - it's just that that the improvements you get from completely new techniques haven't managed to outpace the stability you get from the sheer amount of time these projects have had to accumulate bugfixes and incremental improvements.

If you built vi now and gave it 34 years to mature I'm sure it would be much better then vi is now. Of course by then the old vi may have acquired mind reading powers or something.

tripwire
Nov 19, 2004

        ghost flow

tef posted:

For what it is worth (not much), the talk that started this derail is online: http://vimeo.com/17675268

The first bit is james on why php isn't that great, and the second bit is me waffling on like an idiot. Finally there is some q&a where I'm rude to the audience.


I really liked your talk! It was funny how many people in the audience were irked by your slagging on drupal :)

qntm
Jun 17, 2009

tef posted:

this just shows how far we've come in 40 years of software engineering.

Not really, it's just impossible for a computer program to demonstrate 40 years of continuous reliability under heavy load without having been written 40 years ago. There's plenty of code out there which was written "only" 20 years ago or 10 years ago and has done its job perfectly ever since and will continue to do so long into the future. If you want someone to replace your working but antiquated COBOL with something modern i.e. recently-made, then proving that any possible replacement can meet the task means testing it to breaking point and under NASA-level intensity and scrutiny.

There is nothing to stop people writing programs right now, in modern languages, which will operate perfectly for the next 40 years. It happens all the time. The problems are (1) getting explicit requirements out of a program which was invariably programmed with a great deal of skill and subtlety but has little to no surviving documentation (those requirements could be met if they were clear), (2) proving that the replacement matches those requirements to the satisfaction of the person with the money and the severe disinclination to switch, and (3) making the switch seamlessly. We could do this. There's nothing stopping any of this happening, other than the fact that it's cheaper for the customer and more profitable for the provider for everybody to stick with what works.

tef
May 30, 2004

-> some l-system crap ->

tripwire posted:

I really liked your talk! It was funny how many people in the audience were irked by your slagging on drupal :)

Thanks,

It was just one really vocal guy, we had a beer afterwards.

tef
May 30, 2004

-> some l-system crap ->
each password is salted with its first two characters

MrMoo
Sep 14, 2000

Janin posted:

I'm honestly shocked that Perl runs at all on a EBCDIC platform

Perl is there to help convert EBCDIC to more sane encodings. It's surprising how much Perl is used on big expensive machines.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

tef posted:

similarly old editors like vi and emacs being popular show that we haven't really progressed in terms of interface either.

Not really. Newer software is easier to get up to speed on. Some may argue that nothing new is as fast to edit in as vi or emacs, but that's arguable and besides, it's a reasonable trade-off for many.

In other words, I don't think your case is as airtight as you presume. :)

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.




Oh god - it's like he works where I work except nobody here ever heard of a salt before I was hired.

Kelson
Jan 23, 2005

Lord Rumples Catte posted:

Tiny Bug Child posted:

that chart made me curious enough to go see what the most popular passwords for our sites are and a bunch of the same ones show up like "dragon" and "baseball" and "monkey" and "pepper" and "superman"

Lord Rumples Catte posted:

wait


WHY CAN YOU SEE THESE?!!?

Tiny Bug Child posted:

uhhh, i'm the lead web developer, graham. i have to be able to see the mysql database to do my job.


I love web developers!

mr_jim
Oct 30, 2006

OUT OF THE DARK

I think hope Tiny Bug Child is a gimmick.

h_double
Jul 27, 2001

qntm posted:

We have that kind of scenario where I work, but the problem is our Perl needs to be run on about 65 different machines all running different operating systems. "Getting a module from CPAN" becomes such a tall order that if something isn't included in every Perl installation by default, rolling your own or figuring out how to do without it almost always ends up being quicker and easier.

Yeah, that is a pretty extreme case, and it's hard to fault Perl too much for being kludgey at times, it is such a down-in-the-trenches language to begin with (I mean that in a good way).

In my scenario, however, the code was running on a handful of well-supported OS, and the work the modules was doing was central to the script's function. The guy who had written the code in the first place was mostly a C programmer, and if he couldn't figure out how do to something in the C idiom, he'd drop in system() calls and backticks as needed (which isn't the most portable code either).

To be fair, the code worked reliably and that's what matters. It was just such a textbook example of a really smart guy whose intelligence starts to calcify to stubbornness and arrogance at the edges. I did manage to eventually sell him on the value of hashes and regexps at least.

The Reaganomicon
Oct 14, 2010

by Lowtax

mr_jim posted:

I think hope Tiny Bug Child is a gimmick.

In Real Life

evensevenone
May 12, 2001
Glass is a solid.
Honestly if you program C for long every other language just seems like cheating. It kind of takes a mental shift to let the compiler/interpreter/library handle things without having this nagging feeling that the whole thing is going to explode.

h_double
Jul 27, 2001
Oh sure, and I think every programmer has a phase they go through where they must fight the temptation to reinvent the wheel.

This is especially true for anybody who learned to code in the 70s or 80s, when getting performance out of the bare metal was still so important that readable, well-designed code barely entered the equation.

MononcQc
May 29, 2007

Kelson posted:

I love web developers!

to be fair if you have access to the DB, it's not hard to see this. Type in the passwords you want to look for and concatenate them with their salt. If rows match, you know that password is used.

Kelson
Jan 23, 2005

MononcQc posted:

to be fair if you have access to the DB, it's not hard to see this. Type in the passwords you want to look for and concatenate them with their salt. If rows match, you know that password is used.
You could hash the 'most popular' passwords and compare, but he didn't. The passwords weren't hashed. That is TERRIBLE.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

MononcQc posted:

to be fair if you have access to the DB, it's not hard to see this. Type in the passwords you want to look for and concatenate them with their salt. If rows match, you know that password is used.

But even this would be defeated with md5($username . $password . $global_salt).

You could still loop through all users, but you couldn't just do a "select count(*) from users where pw_hash = md5("qwerty" . $global_salt)"

MononcQc
May 29, 2007

Wheany posted:

But even this would be defeated with md5($username . $password . $global_salt).

You could still loop through all users, but you couldn't just do a "select count(*) from users where pw_hash = md5("qwerty" . $global_salt)"

You absolutely could if your hashing function exists as part of your DB engine. Knowing this is about a horror thread, I'd be ready to bet it's MD5 in MySQL.

SELECT * FROM `users` WHERE `password`=MD5(CONCAT(`username`,"SomePassword","global salt"));

Salts don't really stop you from brute-forcing passwords like that. Afaik they're mostly useful to stop someone from making a single rainbow table to scan over the whole DB in one go to grab all passwords and instead force intruders to generate the equivalent of one rainbow table per user. This is why salts should be unique per password per user. Correct me if I'm wrong.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
And some people recommend iterating the hash function multiple times so that an attack on an individual password would be too costly.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



MononcQc posted:

to be fair if you have access to the DB, it's not hard to see this. Type in the passwords you want to look for and concatenate them with their salt. If rows match, you know that password is used.

It's more likely they just store them in plain text, which is probably more common than you'd think given the number of piles of lovely PHP that were created in the last 10 years. Many of them were probably wrapped in something pretty and secure-looking and left alone otherwise.

MononcQc
May 29, 2007

Munkeymon posted:

It's more likely they just store them in plain text, which is probably more common than you'd think given the number of piles of lovely PHP that were created in the last 10 years. Many of them were probably wrapped in something pretty and secure-looking and left alone otherwise.

He does mention earlier in that thread that their passwords are hashed (they pick the first two letter as a salt) and do not have clear text versions of them. I assumed they didn't store them in plain text but some other posts make it kind of ambiguous in the original thread.

But yes, I am absolutely not surprised by the idea of having dozen of sites keeping stuff in clear text or yet just MD5'ing it and calling it 'encryption'.

I've seen pretty retarded stuff, some of which I've documented in a blog post. Basically, corporation handling healthcare-related data wouldn't even put any check on the data available (accessible with auto-incrementing IDs). When called out on it, they 'encrypted it' with base64. When called out on that, they decided to drop all the data because it was too hard to do. They then called the product a complete success. And they also threatened to sue us in the process.

Not mentioned in the blog post is how a coworker of mine found an SQL injection that worked, managed to get the admin password to the DB (whose server was accessible to everyone) and could access databases of dozens and dozens of customers' tables, all on the same database, with sensitive information such as their client lists and whatnot.

MononcQc fucked around with this message at 17:28 on Dec 17, 2010

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thanks for making me feel better about the (relative) security of the place I work - that doesn't happen often.

MononcQc
May 29, 2007

Munkeymon posted:

Thanks for making me feel better about the (relative) security of the place I work - that doesn't happen often.

To be fair, my old job had to be second to Tiny Bug Child's job in terms of retarded security decisions. In the two years and a half I was there we significantly made things better, but a lot was left to do. Here's a short list of what I can name off the top of my head:

  • The dev database and prod database are the same thing. There is no staging and all development operations are done on production data.
  • I had complete access to that database when getting there as an intern
  • The database held non-salted passwords, md5s of credit cards (which is illegal) on top of the 4 first and 4 last numbers, letting you brute-force CC numbers in seconds. We also stored expiration dates and whatnot
  • The dev accounts were all on the same server with that DB access. That server had access to every other production server directly
  • The dev accounts could set ther own .htaccess files, basically granting the outside world an access to the whole god drat production stack.
  • Countless XSS injections. When I warned them about it, they scanned the frontend unlogged pages with some generic XSS-scanning software and called it a day.
  • Countless CSRF vectors, including sending messages and spending e-money
  • E-money had a real-life value that constantly changed according to promotions and whatnot (because they kept having users pay different amounts for it). The real-life value was not tracked (they would have needed a realtime exchange rate), but was written in the books as reported costs at a flat fee over twice their real value. Basically fraud.
  • I found a single complaint e-mail that had its own template language for it. The actual template implementation had been deleted when moving from CVS NT to SVN 2 years before and nobody noticed
  • Only a small percentage of the code base was tested, and they were test added in the last 3 months I was there, mostly by me.
  • Some newsfeed service could be called by the frontend to get data. The backend server (a mix of a REST interface with ActiveMQ queues) would then call the frontend back to generate the templates, which would be serialized and sent back to the servive, which would then send them back again to the frontend.
  • 5 weeks before I left, we removed all that retarded stuff, replaced it with a denormalized table with bitfields allowing us to match on range queries as we pleased. This gave us a 10000% speedup, just by getting rid of all that dumb stuff.
  • Our news portal (thankfully not managed by our team) supported SMS alerts. However, the dumb dev team there never checked the validity of the phone number entered (no auth) and didn't support looking for account cancellations. CSRF was also rampant there and you could effectively use a script to subscribe every phone number ever without anyone able to unsubscribe.
  • Some other CSRF problems: can dynamically generate emails as an admin, unsubscribe users, delete photos, send private messages on behalf of other members
  • We had a retarded 'autologin' scheme that we had to implement (against our will) for emails. At some point the template system went haywire after a bad change and people could log in as random users for 5 hours. They finally listened to us and removed the system. I also got the right to call upper management at any time middle management wanted us to do something retarded again.
  • We found our DBA's username and password on some Russian site
  • The DBA's answer was that it was normal because we used MySQL 4.x which has non-secure password functions
  • A few weeks later, users started getting Russian spam.
  • Not all databases ran the same MySQL versions
  • our payment system was hosted on a single metal that was 5 years old with 0 redundancy. It was our only source of income. It took 1 year and a half of complaining before they backed up the databases and one more year before they actually built a failover server.

The team and I (we were 4) fixed most of these bugs in the 2.5 years I spent there, including closing most security holes, separating dev from prod (a massive undertaking with millhundreds of thousands of lines of PHP code), documenting all insane stuff and sending it to management, etc. This software was mostly 10 years old PHP and there is a whole lot more crap I haven't even mentioned that was as bad or retarded. I've not even touched architecture and infrastructure decisions.

My final days there were spent reviewing over 900 MySQL queries and sanitizing the poo poo out of them, right after having introduced a token system to remove CSRF holes. I like to believe I made the site tolerable rather than a complete horror.

One week after I left, they decided to build a second system to replace it.

I can say I've learned a whole drat lot during that time, mostly about how not to do things. I can easily detect some code smells months or years before they get problematic, which gets pretty useful. Probably explains my love of Erlang for maintainable software that was well thought-out.


tl;dr I've seen web development hell and tried to fix it. I quit.

MononcQc fucked around with this message at 18:05 on Dec 17, 2010

Zombywuf
Mar 29, 2008

My first job fresh out of uni I was given root access to all our customers databases on the second day (i.e shown the page on the internal wiki where all the login details were stored). This was a lot of data.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



MononcQc posted:

  • The database held non-salted passwords, md5s of credit cards (which is illegal) on top of the 4 first and 4 last numbers, letting you brute-force CC numbers in seconds. We also stored expiration dates and whatnot

I hope this makes you feel at least a little better about your old job: http://forums.somethingawful.com/showthread.php?threadid=2803713&userid=40673&perpage=40&pagenumber=2#post372379389

MononcQc
May 29, 2007

Munkeymon posted:

I hope this makes you feel at least a little better about your old job: http://forums.somethingawful.com/showthread.php?threadid=2803713&userid=40673&perpage=40&pagenumber=2#post372379389

Haha, oh man. This forum could run its own thedailywtf.com.

Lysandus
Jun 21, 2010
code:
if ( !responseBuffer = ByteBuffer.wrap(newData) )
{
    responseBuffer = ByteBuffer.wrap(newData, 0, newData.length);
}
:psyduck:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

MononcQc posted:

Correct me if I'm wrong.

:hfive:

I'm pretty paranoid when it comes to security, cryptography and such, but I know I'm not a security expert.

I've probably made some insecure software in my time, but at least if someone informed me of my insecure service, I'd a) poo poo my pants, b) try my loving best to secure it.

I probably wouldn't talk about "the peasants accounts", even ironically..

e:

MononcQc posted:

SELECT * FROM `users` WHERE `password`=MD5(CONCAT(`username`,"SomePassword","global salt"));

poo poo, and this works. :saddowns: It might take a while for any site with a significant number of users, but I guess I have to poo poo my pants now :toxx:

Wheany fucked around with this message at 21:06 on Dec 17, 2010

Zhentar
Sep 28, 2003

Brilliant Master Genius

Wheany posted:

poo poo, and this works. :saddowns: It might take a while for any site with a significant number of users, but I guess I have to poo poo my pants now :toxx:

I'm not familiar with the performance of SQL Server's MD5 function, but "a while" is probably a few seconds. A high end nvidia card with a good CUDA md5 implementation can easily exceed one billion hashes per second.

MononcQc
May 29, 2007

Even without MySQL's MD5, you could nest queries, use cursors, accumulate data in increments wherever you want, etc. As Zhentar said, going with CUDA lets you be real fast. Then you could also rent some Amazon instances and work on it with a whole farm.

If you're looking for a specific password, it's easy to verify if it's there or not for any user. Again, salts are not meant to make it hard to find a password or make it harder to brute force. They're only there to keep someone from coming in with a pre-generated table of MD5s and matching it against your table to find them real fast. Having good, strong passwords is still recommended to make the brute-force slow.

The concept of salts is just to make it impractical, or at least slightly harder, to find all passwords for everyone at once.

Better approaches include using slow hashes like bcrypt (I think that's the one at least), which basically let you decide how long it takes to hash the password. This lets you make hashing to check your users a bit longer. This is not bad for a login query because it can still be relatively short in the grand scheme of things, but for someone trying to brute-force the password, it's a question of adding a whole drat lot of time.

I have not seen people using slow hashes or complaining about them yet, though.

E: duplicated word

MononcQc fucked around with this message at 22:31 on Dec 17, 2010

king_kilr
May 25, 2007
http://codahale.com/how-to-safely-store-a-password/

tef
May 30, 2004

-> some l-system crap ->

Wheany posted:

But even this would be defeated with md5($username . $password . $global_salt).

salts should be prefixes, not suffixes.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

tef posted:

salts should be prefixes, not suffixes.

Mind telling us why?

nielsm
Jun 1, 2009



Never mind me.

nielsm fucked around with this message at 02:35 on Dec 18, 2010

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

KARMA! posted:

Mind telling us why?

A simplified answer:

For most hash constructions, you can amortize the costs of a changing suffix more readily than a changing prefix, meaning that you can take a dictionary of unsalted hashes for common passwords and cheaply transform it to a dictionary of suffix-salted hashes for common passwords, allowing more effective attacks against databases of accounts.

Please note that this is a broad discussion of one particular class of attack, and there are a whole lot of caveats attached to this description which I'm not going to go into here.

The answer you should keep in mind is more general: Cryptographic protocols are really incredibly hard to design well, and they tend to be extremely subtle and fragile, often for reasons that don't appear to make sense unless you have had extensive specialist education in the field. If you don't know exactly why every single decision was made in an existing protocol, you are not qualified to change the protocol. Please don't invent your own cryptographic protocols.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

ShoulderDaemon posted:

For most hash constructions, you can amortize the costs of a changing suffix more readily than a changing prefix, meaning that you can take a dictionary of unsalted hashes for common passwords and cheaply transform it to a dictionary of suffix-salted hashes for common passwords, allowing more effective attacks against databases of accounts.

It looks to me like the username is taking the place of a nonconstant prefix.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Jabor posted:

It looks to me like the username is taking the place of a nonconstant prefix.

Oh, probably, but it's a goofy construction and usernames are lower-entropy and often longer than the random nonces you're supposed to use as salts which will have who-knows-what kind of effect on attackers trying to minimize costs because now they can potentially exploit having the whole first block of the hash being a combination of low-entropy terms; not to mention the possibility of collisions where user foo has password barqux and user foobar has password qux, which all means that the potential attack surface is larger in some really-hard-to-quantify manner.

There's just no good reason for using a non-standard protocol which seems like it might have the same security properties as the real thing but hasn't been studied when you can just not write your own cryptographic protocols.

Seriously, cryptographic protocols are really hard for lots of small, subtle, incredibly obscure reasons. It's very hard to get the education you need to be able to do a halfway-adequate job of reasoning about possible attacks, the education expires extremely quickly, and even the experts get it wrong a large proportion of the time. It can be fun to see if you can find all the problems in some homemade protocol, but even if you and your best friend and 5000 people on the internet think you found them all, you're simply wrong.

tef
May 30, 2004

-> some l-system crap ->

KARMA! posted:

Mind telling us why?

It depends on the hash, but most are built on the Merkle–Damgård http://en.wikipedia.org/wiki/Merkle%E2%80%93Damg%C3%A5rd_construction

if A = abc and you know the hash of ab, the hash of abc is easy to compute.

By comparison if you have A = abc and you know the hash of bc, the hash of abc
is more work to compute.

This is why I think authentication and passwords should be handled by frameworks entirely -- it is far, far too easy to break poo poo.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

The thinking behind bcrypt's strengthening can be extended to the idea of halting password puzzles:

I.e A correct password will halt the password checker, an invalid one will never terminate.

Alternatively, you might enjoy a real authentication protocol:

http://en.wikipedia.org/wiki/Secure_Remote_Password_protocol

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply