Skip to content

Commit a91ab68

Browse files
committed
ajdust for security review
1 parent bba9cfc commit a91ab68

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

doc/developer/design/20250321_password_authentication.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ Passwords hashed with `scram-sha-256` will be stored in the configured secret st
4343

4444
1. The user sends a username and password to the Materialize server.
4545
2. The protocol layer will communicate with the coordinator layer to validate the password. (via the adapter Client)
46-
a. The coordinator layer will check the password against the stored hash. If the password is correct, the user will be authenticated.
47-
b. If the password is incorrect, the user will be denied access.
46+
a. The coordinator layer will check the password against the stored hash. If the password is correct, the user will be authenticated.
47+
b. If the password is incorrect, the user will be denied access.
4848

49-
3. **OPTIONAL: Book-Keeping**: Login and failed login requests should be tracked. Metrics should be created to monitor potential security events.
49+
3. **Audit and Metrics:** Login and failed login requests should be logged. Metrics should be created to monitor potential security events.
5050

5151
**Password Rotation or Expiration**: While not currently in scope, the design should allow for additions in the future, such as password rotation and expiration.
5252

53-
**Abuse Detection**: Action should be taken action when brute force attempts are detected, either by locking the user or blocking the requesting client IP.
54-
5553
### 2. Password Management Syntax:
5654

5755
Users should be able to manage their passwords and set passwords for roles they create. Superusers should be able to alter any non-internal user's password.
@@ -87,7 +85,10 @@ Users should be able to manage their passwords and set passwords for roles they
8785
}
8886
```
8987

90-
- **OPTIONAL: Password Versioning**: Updates to the password hashing mechanisms may be required.
88+
- Iterations must be >= 400,000... this **must be configurable with a system variable.**
89+
- We must use at least 32 bytes of cryptographically random data for salts.
90+
91+
- **OPTIONAL: Password Versioning**: Updates to the password hashing mechanisms may be required.
9192
- For passwords received in plain text we should be able re-encrypt them with stronger algorithms.
9293
- For client side challenges we may be able to increase the number of hash iterations.
9394
We will already be storing the necessary password hashing metadata to perform these actions.
@@ -101,7 +102,7 @@ Passwords for `mz_system`(v1) and `mz_support`(TBD) roles will be configurable v
101102

102103
Environmentd's HTTP endpoint will have added support for session-based authentication. This includes session creation, storage, and deleting/setting cookies. To handle sessions we should use [tower session-store](https://docs.rs/tower-sessions/latest/tower_sessions/). This should explicitly require secure cookies `.with_secure(true)` when running with TLS.
103104
Required new endpoints:
104-
- POST: api/login
105+
- POST: api/login
105106
- Accepts username, password Authentication Headers
106107
- imposes strict rate limiting : returning 429
107108
- returns 401 on auth failure
@@ -120,7 +121,7 @@ ALTER ROLE ... WITH SUPERUSER;
120121
ALTER ROLE ... WITH NO SUPERUSER;
121122
```
122123

123-
A role's superuser state should be stored as a rolsuper along with the user in the catalog. It may make sense to make this an Option<bool>. If the value of rolsuper is not `Some(v)` then we defer to metadata if we're using frontegg auth.
124+
A role's superuser state should be stored as a rolsuper along with the user in the catalog. It may make sense to make this an Option<bool>. If the value of rolsuper is not `Some(v)` then we defer to metadata if we're using frontegg auth.
124125

125126

126127
### Note on Configurable Authentication Mechanism
@@ -130,7 +131,7 @@ The authentication mechanism for an environment must be configurable. A new flag
130131

131132
### Note on Console builds:
132133

133-
Console does currently do not support runtime or startup configuration. Configuration is handled only at build time. To resolve this we should add a `config.json` or `config.js` file which can be mounted directly into the Nginx container assets. This file should come from a materialize-console config map which must be setup by Orchestratord. We will also need changes to the console to support reading in configuration from this map. The initial config value here should be `authentication_type: password`, in cloud we should use `authentication_type: frontegg` or `authentication_type: jwt`. The console build process can still be used to set default values for this config file.
134+
Console does currently do not support runtime or startup configuration. Configuration is handled only at build time. To resolve this we should add a `config.json` or `config.js` file which can be mounted directly into the Nginx container assets. This file should come from a materialize-console config map which must be setup by Orchestratord. We will also need changes to the console to support reading in configuration from this map. The initial config value here should be `authentication_type: password`, in cloud we should use `authentication_type: frontegg` or `authentication_type: jwt`. The console build process can still be used to set default values for this config file.
134135

135136

136137
### Note on Emulator Auth:
@@ -151,7 +152,7 @@ A minimal viable prototype (MVP) for this solution will include:
151152

152153
1. **Authd Service**: This would involve creating a separate authentication service to handle authentication. This approach is more complex and introduces security concerns, as it would require developing secure endpoints and integrating a user management system that could be prone to additional complexity and security risks.
153154

154-
- **Reasons Not Chosen**: This solution is more involved, requiring significant additional work to secure, develop, and maintain. Additionally, it does not align with the Postgres.
155+
- **Reasons Not Chosen**: This solution is more involved, requiring significant additional work to secure, develop, and maintain. Additionally, it does not align with Postgres.
155156

156157
2. **Password Authentication in Ingress Layer**: Using a front-end proxy like PGbouncer or NGINX to handle password authentication before traffic hits Materialize.
157158

@@ -170,7 +171,11 @@ A minimal viable prototype (MVP) for this solution will include:
170171
## Open questions
171172

172173
1. **Where exactly are passwords stored**: While it makes sense to store passwords in the catalog, I have not yet identified exactly where they should be stored. Should it go alongside `mz_roles`, or in a new `mz_auth_id` table. The latter makes sense as it could store password metadata, and might let us store multiple passwords down the road.
174+
**A:** In the catalog
173175

174176
2. **Audit Logging and Brute Force Detection**: Do we need to log all failed password attempts and the IPs of those attempts? Do we need to take action to lock an IP or User when an attempt threshold is met?
177+
**A:** yes log attempts and failed attempts along with the password. No mitigation is required, at least not for v1.
175178

176179
3. **Password Strength Validation**: Should Materialize include built-in password strength validation, or should it be handled outside the system (e.g., via Kubernetes or other security tools)?
180+
**A:** MZ should not have built-in password strength, down the road we may want to consider something like postgres's [passwordcheck](https://www.postgresql.org/docs/current/passwordcheck.html
181+
).

0 commit comments

Comments
 (0)