]> git.feebdaed.xyz Git - 0xmirror/nginx.git/commitdiff
Mail: reset stale auth credentials with "smtp_auth none;".
authorSergey Kandaurov <pluknet@nginx.com>
Mon, 7 Jul 2025 19:48:44 +0000 (23:48 +0400)
committerpluknet <pluknet@nginx.com>
Wed, 13 Aug 2025 14:20:34 +0000 (18:20 +0400)
They might be reused in a session if an SMTP client proceeded
unauthenticated after previous invalid authentication attempts.
This could confuse an authentication server when passing stale
credentials along with "Auth-Method: none".

The condition to send the "Auth-Salt" header is similarly refined.

src/mail/ngx_mail_auth_http_module.c
src/mail/ngx_mail_smtp_handler.c

index 27f64b92e0d95a89db9c707c76900b949b4ba1f4..4ca6d6e24dccaa886242916c2e62652951514b95 100644 (file)
@@ -1321,7 +1321,10 @@ ngx_mail_auth_http_create_request(ngx_mail_session_t *s, ngx_pool_t *pool,
     b->last = ngx_copy(b->last, passwd.data, passwd.len);
     *b->last++ = CR; *b->last++ = LF;
 
-    if (s->auth_method != NGX_MAIL_AUTH_PLAIN && s->salt.len) {
+    if ((s->auth_method == NGX_MAIL_AUTH_APOP
+         || s->auth_method == NGX_MAIL_AUTH_CRAM_MD5)
+        && s->salt.len)
+    {
         b->last = ngx_cpymem(b->last, "Auth-Salt: ", sizeof("Auth-Salt: ") - 1);
         b->last = ngx_copy(b->last, s->salt.data, s->salt.len);
 
index e68ceedfdb511d23e2a62f3832e9b17d3f27fe62..1e26c2c8d7b971b57fc408ec26d235108b4ed4a7 100644 (file)
@@ -782,6 +782,9 @@ ngx_mail_smtp_mail(ngx_mail_session_t *s, ngx_connection_t *c)
 
     ngx_str_set(&s->out, smtp_ok);
 
+    ngx_str_null(&s->login);
+    ngx_str_null(&s->passwd);
+
     return NGX_OK;
 }