-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic auth: Blowfish/Bcrypt password hashing doesn't work #3150
Comments
It looks like this is a base image issue: https://trac.nginx.org/nginx/ticket/382 It also looks like |
I am sorry but we have no plans to switch to alpine. |
Closing. This bug is related to the missing support for bcrypt in debian/ubuntu https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=149452 |
Apache can support it :) This would be a problem for FIPS environments, as the default password encryption is MD5, but FIPS bans all MD5. The SHA1 implementation in "htpasswd" does not include a salt, so is vulnerable to a rainbow attack. Therefore, bcrypt is really the only secure password mechanism available. You really should support bcrypt. |
@aledbf could you please reopen this and discuss how we can add support for bcrypt? I'm happy to submit a PR, given some direction. |
@jfuechsl @james-stevens this is an issue with Debian itself, not NGINX. The only course of action is to switch to a different distribution, like alpine (which is known to work) this image https://github.com/kubernetes/ingress-nginx/tree/master/images/nginx Note: this is not a trivial task |
Thanks for the response. Looks like there isn't much to be done about it. |
So its works in Apache, but there is nothing you can do to get it working in nginx. Seems unlikely to me. |
In Apache bcrypt is done in
The Blowfish code is in And the time between my comments is 4 mins - so it took me 4 mins to find the code and write about it. |
I am sorry but I don't understand what are you expecting from the ingress-nginx. |
Afaik,
This bug report has been open since 2002 and the last comment was 2017. Not sure how quick things are to change there. But to be fair, I also question how big the use case for Nginx password hashing nowadays is. We had a niche use case but were able to fall back to an alternative solution. It might be good to at least add it to the documentation that nginx password hashing shouldn't be used with |
Yeah - my mistake - I'm really sorry - I didn't read which project this was on carefully enough. I'm sorry for the trouble. |
@james-stevens @jfuechsl I am testing the migration to alpine in #4862 Important: due to the change in the distribution you need to change |
I can confirm that the latest version (0.27.0) works. Thank you! |
Can also confirm this works now. Example resource "random_password" "password" {
length = 15
special = true
override_special = "_%@"
}
resource "kubernetes_secret" "basic-auth" {
metadata {
name = "basic-auth"
namespace = "my-namespace"
}
data = {
"auth" = "admin:${bcrypt(random_password.password.result, 9)}"
}
} Ingress Annotations ingress:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: "Authentication Required" |
Is this a request for help? Yes, but also might be a bug report
What keywords did you search in NGINX Ingress controller issues before filing this one?
"bcrypt"
"crypt_r() failed"
Is this a BUG REPORT or FEATURE REQUEST? BUG REPORT
NGINX Ingress controller version:
nginx-ingress-0.22.1
Kubernetes version (use
kubectl version
):Environment:
uname -a
): 4.4.0-134-generic (Local)What happened:
I want to enable basic auth so I created a htpasswd configuration with a bcrypt hash. However, when I sign in, I get an "internal server error" with the following log entry:
What you expected to happen:
Basic auth to work with bcrypt hashes, as described here: http://httpd.apache.org/docs/current/programs/htpasswd.html
Bcrypt should be supported by
ingress-nginx
, sincemd5
,sha1
andcrypt
are not considered secure anymore for hashing passwords.How to reproduce it (as minimally and precisely as possible):
I generated the htpasswd string using Go, like this:
Which generates the following output (contains 128bit salt):
Which I encode to base64 and put into a Secret's
auth
field:Which is reused by an ingress rule:
When I open the site in a browser, if prompts for a password but returns a 500 error, with the log output shown above.
The text was updated successfully, but these errors were encountered: