News for hackers. Stuff that matters.
Re:Password may not contain: select, insert, update, delete,... by Retr0id on Sunday January 21, 2024 @09:00AM (#39078471)
Optimistically, perhaps this requirement stems from an overzealous WAF
Re:Password may not contain: select, insert, update, delete,... by berkes on Sunday January 21, 2024 @09:10AM (#39078542)
That, or some poorly architectured "framework" or toolkit.

Others in the comments see this as "proof" that the application has poor security. I don't think we can draw that conclusion. We can, however, draw the conclusion that some part of the stack is poorly implemented.

Re:Password may not contain: select, insert, update, delete,... by junon on Sunday January 21, 2024 @09:12AM (#39078561)
I mean, this is a gross misunderstanding of how user input makes its way into a database safely. If you're putting out error messages like this it's a giant red flag.
Re:Password may not contain: select, insert, update, delete,... by graemep on Sunday January 21, 2024 @09:17AM (#39078611)
It is also very common not to do things right. https://www.bbc.com/future/article/20160325-the-names-that-b...

That article is a few years old now and things should have got better, but even by 2016 everyone should have known properly sanitising inputs was critical for a decade or two.

Re:Password may not contain: select, insert, update, delete,... by junon on Sunday January 21, 2024 @09:19AM (#39078630)
Right but that's not really an excuse not to do them right.
Re:Password may not contain: select, insert, update, delete,... by pixl97 on Monday January 22, 2024 @10:32AM (#39090508)
You're working at the premise backwards...

One of the systems is already wrong. The excuse not to do the system right is monetary cost of fixing the broken system.

Out of all the excuses in the world, money wins.

Re:Password may not contain: select, insert, update, delete,... by junon on Monday January 22, 2024 @11:27AM (#39091348)
EDIT: responded to the wrong comment, apologies.

I really don't understand your point. If I hash on the browser the hash is still being sent to the server. A MitM or sniffing attack can just send the hash and log in. It doesn't actually protect the user at all unless they're re-using the password elsewhere. This also assumes that you're using a seeded hash of some sort, or a multi-round hasher with settings unique to every other website. Otherwise you're still going to run into stuffing and collisions.

So for sites where the plaintext password is sensitive (password managers etc) that's important. For most sites, it's not inherently wrong not to hash passwords in the browser, though it does protect against password reuse.

I'm not saying you're wrong, I just don't think you're accurately portraying the problem you're fixing.

Re:Password may not contain: select, insert, update, delete,... by mikkom on Sunday January 21, 2024 @09:17AM (#39078610)
And top of that, password should NEVER be stored to database
Re:Password may not contain: select, insert, update, delete,... by eddd-ddde on Sunday January 21, 2024 @10:31AM (#39079311)
It's normal for them to make it to an executed SQL query.
Re:Password may not contain: select, insert, update, delete,... by duskwuff on Sunday January 21, 2024 @02:37PM (#39082107)
No, it isn't.

If a user's password leaves the web application in any form other than a hash, something nonstandard and probably bad is going on.

Re:Password may not contain: select, insert, update, delete,... by Wingy on Sunday January 21, 2024 @04:41PM (#39083358)
Hashing can be done in a stored procedure. Maybe the organization decided that it's better for the DBA to handle hashing. Nonstandard maybe but not necessarily bad.
Re:Password may not contain: select, insert, update, delete,... by duskwuff on Sunday January 21, 2024 @05:00PM (#39083538)
> Hashing can be done in a stored procedure. [...] Nonstandard maybe but not necessarily bad.

No, it's unambiguously bad. You're transmitting a cleartext password to a system which doesn't have a business need to know it, and which wasn't designed to process secret data. There's a substantial risk that the database may leak that data in some unexpected way, e.g. by logging it when an error occurs or by showing the parameter in a process list. Worse, a stored procedure can potentially be covertly modified to store or exfiltrate the password while hashing it.

Re:Password may not contain: select, insert, update, delete,... by junon on Sunday January 21, 2024 @05:41PM (#39083834)
To be clear, this only improves security if the user reuses passwords.
Re:Password may not contain: select, insert, update, delete,... by Wingy on Monday January 22, 2024 @01:58PM (#39093712)
That's true, the hashing should definitely be done as early as possible.

"As early as possible" is interesting. It could be done on the client, however you need to actually have the hash to check if a string hashes to the same as it because of the salts embedded in the strings. Using an algorithm without salting would allow you to hash the password on the client then allow arbitrary 32 (or however long your hash digests are) character strings on the server as a password equivalent. This would also protect from a misconfigured or malicious server logging unhashed passwords.

Re:Password may not contain: select, insert, update, delete,... by duskwuff on Monday January 22, 2024 @03:10PM (#39094744)
> It could be done on the client

No, that's actually too early -- if you let the client hash the password, you're vulnerable to a "pass-the-hash" attack where the client submits a hash without knowing the password.

There are protocols like SRP and other PAKEs which allow this to be done securely, but it's uncommon for them to be used in web applications.

Re:Password may not contain: select, insert, update, delete,... by Wingy on Monday January 22, 2024 @03:33PM (#39095023)
My reasoning was that if you can capture the hash, you could have also captured the password but that doesn't account for a situation where the database is compromised.
Re:Password may not contain: select, insert, update, delete,... by berkes on Tuesday January 23, 2024 @04:39AM (#39101358)
Hashing is hardly ever done client side. Most often server side, which is fine, because it's not the same as "storing plain text".

In fact, if you rely on client side hashing, you are not only making the app a lot less accessible (it will only work with JS enabled), the security is worse, because now you are publishing a salt to the client. Or you are working with unsalted hashes which is hardly better than just plain text.

SSL is what protects passwords in transit. Not some JavaScript client side hashing DIY.

Re:Password may not contain: select, insert, update, delete,... by duskwuff on Tuesday January 23, 2024 @11:38AM (#39105712)
I think you may have misunderstood me. By "the web application" I mean the application server, not client-side code.
Re:Password may not contain: select, insert, update, delete,... by junon on Sunday January 21, 2024 @09:19AM (#39078625)
Well, not in plaintext.
Re:Password may not contain: select, insert, update, delete,... by klyrs on Sunday January 21, 2024 @01:17PM (#39081034)
That's why you hash the password with an SQL built-in hash function. For security! But the password is still in plaintext inside the query so you can retrieve it from the logs for... security?

(I joke, but 20 years younger me, self-teaching php and security etc? Who knows what she'd think of this)

Re:Password may not contain: select, insert, update, delete,... by cookiengineer on Sunday January 21, 2024 @03:50PM (#39082905)
You can just try out some || concated strings and an or statement to verify the lack of security. It's not like it's a secret how to do SQL injections in 2024.

Bypassing this kind of filter is literally the second picoCTF SQL injection level, which is intended for high school STEM students.

Re:Password may not contain: select, insert, update, delete,... by berkes on Tuesday January 23, 2024 @04:34AM (#39101327)
Yrs. But you presume that these password rules are there for security. I'm saying they are there because some part of the stack is stupid.

I'm quite certain you cannot breach security like that, but that some (ancient) piece of the stack has some hardwired rules, which, at some point, might indeed be a "defence against injection". But this is no proof that this is still the case.

Re:Password may not contain: select, insert, update, delete,... by turminal on Sunday January 21, 2024 @09:21AM (#39078646)
That would imply WAF gets to see unhashed passwords, so not good at all.
Re:Password may not contain: select, insert, update, delete,... by jesprenj on Sunday January 21, 2024 @09:49AM (#39078902)
WAF always sees unhashed passwords -- passwords are sent TLS encrypted in a POST body (unhashed) and are hashed by the server software -- and that's regardless of the password policy.
Re:Password may not contain: select, insert, update, delete,... by hiatus on Sunday January 21, 2024 @09:25AM (#39078684)
How would a WAF do its job if it can't see the request payload?
Re:Password may not contain: select, insert, update, delete,... by wongarsu on Sunday January 21, 2024 @09:36AM (#39078794)
There are various schemes where the password is salted, hashed or prehashed on the client side, to various effectiveness. They have never been really popular and the advent of ubiquitous https probably made them even less common, but they do exist. They do help protect you from your own WAF though.
Re:Password may not contain: select, insert, update, delete,... by d-z-m on Sunday January 21, 2024 @09:48AM (#39078894)
can you elaborate on this? Or link something that does? My intuition is that whatever gets sent over the wire is effectively the password. Not sure how the server could validate some rolling hash of the password (based on like a timestamp or something) without having to store the pre-image(i.e. the raw password).
Re:Password may not contain: select, insert, update, delete,... by wongarsu on Sunday January 21, 2024 @10:02AM (#39079033)
Yes, that's the common counter argument. Your hash has now just become the password, and no amount of clever salting really solves that.

It still prevents the server (and any proxies, MitM attackers, etc) from seeing the plain-text password, which can help protect the user if they reused the password somewhere else. Assuming the client wasn't also compromised, which is very likely in web applications but maybe a valid scenario in apps and desktop applications.

The other imho valid idea is that you can run a key derivation function client-side (e.g. salted with the user-name), in addition to running your normal best-practice setup server side. This can allow you to run more expensive key derivation which provides more protection if your database is leaked, while also making dictionary attacks on your authentication endpoints less viable.

Re:Password may not contain: select, insert, update, delete,... by liversage on Sunday January 21, 2024 @04:38PM (#39083338)
The SRP Authentication and Key Exchange System does not send the password from the client to the server. This scheme is supposedly used by Blizzard when authenticating users in some of their online games.

https://www.rfc-editor.org/rfc/rfc2945

https://security.stackexchange.com/questions/18461/how-secur...

Re:Password may not contain: select, insert, update, delete,... by aidenn0 on Sunday January 21, 2024 @10:02PM (#39085667)
If your password is 123456, then client-side hashing will make this less obvious. If the site is compromised in a way that reveals passwords, then it will not trivially work on other sites that use your password. In addition, stronger total hashing can be used, since if your server can do M hashes persecond and your client can do N hashes per second, the total number of hashes to allow a one second login are (M/$NUMBER_OF_CONCURRENT_LOGINS)+N which is strictly larger than (M/$NUMBER_OF_CONCURRENT_LOGINS).

SRP[1] is an even better improvement, where an eavesdropper cannot authenticate as you; there is a challenge-response to login.

1: https://en.wikipedia.org/wiki/Secure_Remote_Password_protoco...

Re:Password may not contain: select, insert, update, delete,... by rassimmoc on Sunday January 21, 2024 @09:31AM (#39078737)
why would waf see hashed passowrds? passwords are hashed by application, so that is after waf does its job and hands request over to app.
Re:Password may not contain: select, insert, update, delete,... by wkat4242 on Sunday January 21, 2024 @02:33PM (#39082058)
These are SQL commands. The WAF would see the password unless you pre-hash it on the client side in JavaScript (not a bad idea). But the database really should never ever see the plaintext password. If it does you're doing a lot more wrong than just being open to SQL injection.
Re:Password may not contain: select, insert, update, delete,... by g4zj on Sunday January 21, 2024 @09:14AM (#39078579)
What does WAF stand for?
Re:Password may not contain: select, insert, update, delete,... by thedougd on Sunday January 21, 2024 @09:17AM (#39078605)
Web application firewall

It’s a reverse proxy that inspects requests for bad stuff like sql injection.

Re:Password may not contain: select, insert, update, delete,... by travoc on Sunday January 21, 2024 @09:31AM (#39078746)
One of the things that devs can blame when our app doesn’t work in production.
Re:Password may not contain: select, insert, update, delete,... by amiljkovic on Sunday January 21, 2024 @09:16AM (#39078602)
Web Application Firewall
Re:Password may not contain: select, insert, update, delete,... by dharmab on Sunday January 21, 2024 @09:15AM (#39078594)
Web Application Firewall