@@ -2584,9 +2584,12 @@ static int RequestAuthentication(WS_UserAuthData* authData,
25842584 usrConf = wolfSSHD_AuthGetUserConf (authCtx , usr , NULL , NULL , NULL , NULL ,
25852585 NULL );
25862586 if (usrConf == NULL ) {
2587+ /* bound the untrusted name so it cannot consume the whole
2588+ * fixed-width log message (control bytes are scrubbed by
2589+ * wolfSSH_Log itself) */
25872590 wolfSSH_Log (WS_LOG_ERROR ,
2588- "[SSHD] Failure to get user configuration for auth (user=%s)" ,
2589- usr );
2591+ "[SSHD] Failure to get user configuration for auth "
2592+ "(user=%.32s)" , usr );
25902593 ret = WOLFSSH_USERAUTH_FAILURE ;
25912594 needFakeCheck = 1 ;
25922595 }
@@ -2683,7 +2686,11 @@ static int RequestAuthentication(WS_UserAuthData* authData,
26832686 * (checked below) is a stronger binding than a CN name match. A
26842687 * shared AuthorizedKeysFile (an absolute pattern with no %u or %h)
26852688 * resolves to one file for every account and binds the certificate to
2686- * nothing, so the name match still has to run. */
2689+ * nothing, so the name match still has to run. Note the strength of
2690+ * the file binding rests on the file's integrity: on Windows,
2691+ * wolfSSHD_OpenSecureFile() performs no ownership or ACL checks, so
2692+ * the guarantee is only as good as the NTFS ACLs on the profile
2693+ * directory. */
26872694 #ifdef WOLFSSL_FPKI
26882695 if (authData -> sf .publicKey .isCert ) {
26892696 #else
@@ -2740,11 +2747,20 @@ static int RequestAuthentication(WS_UserAuthData* authData,
27402747 current = current -> next ;
27412748 }
27422749
2743- /* a UPN matched but no realm policy is set; note per auth
2744- * attempt so the opt-in gap is visible, no shared state */
2750+ /* a UPN matched but no realm policy is set; this states a
2751+ * fixed configuration property, so emit it once per
2752+ * process rather than on every auth attempt (an attempt
2753+ * is peer-triggered and the log callback writes WARN
2754+ * unconditionally) */
27452755 if (upnRealmUnchecked ) {
2746- wolfSSH_Log (WS_LOG_WARN , "[SSHD] AuthorizedUPNDomains "
2747- "not set; certificate UPN domain is not checked" );
2756+ static int upnRealmWarned = 0 ;
2757+
2758+ if (!upnRealmWarned ) {
2759+ upnRealmWarned = 1 ;
2760+ wolfSSH_Log (WS_LOG_WARN ,
2761+ "[SSHD] AuthorizedUPNDomains not set; "
2762+ "certificate UPN domain is not checked" );
2763+ }
27482764 }
27492765 #else
27502766 /* Without FPKI compare subject CN with user name. Only
@@ -2760,18 +2776,30 @@ static int RequestAuthentication(WS_UserAuthData* authData,
27602776 WSTRNCASECMP (usr , dCert -> subjectCN ,
27612777 (size_t )dCert -> subjectCNLen ) == 0 ) {
27622778 usrMatch = 1 ;
2763- /* note per auth attempt so the weaker binding is
2764- * visible without -d, no shared state */
2765- wolfSSH_Log (WS_LOG_WARN , "[SSHD] certificate bound to "
2766- "user by subject CN only; no issuer constraint is "
2767- "applied, keep the trusted user CA set narrow" );
2779+ /* states a fixed build/configuration property, so
2780+ * emit once per process; a per-attempt WARN would
2781+ * let a peer grow the log with every attempt now
2782+ * that the log callback writes WARN without -d */
2783+ {
2784+ static int cnBindWarned = 0 ;
2785+
2786+ if (!cnBindWarned ) {
2787+ cnBindWarned = 1 ;
2788+ wolfSSH_Log (WS_LOG_WARN ,
2789+ "[SSHD] certificate bound to user by "
2790+ "subject CN only; no issuer constraint" );
2791+ wolfSSH_Log (WS_LOG_WARN ,
2792+ "[SSHD] keep the trusted user CA set "
2793+ "narrow" );
2794+ }
2795+ }
27682796 }
27692797 #endif
27702798
27712799 if (usrMatch == 0 ) {
27722800 wolfSSH_Log (WS_LOG_ERROR , "[SSHD] incorrect user cert "
27732801 "sent; certificate identity does not match the "
2774- "requested user (user=%s )" , usr );
2802+ "requested user (user=%.32s )" , usr );
27752803 ret = WOLFSSH_USERAUTH_INVALID_PUBLICKEY ;
27762804 }
27772805 }
@@ -2800,7 +2828,8 @@ static int RequestAuthentication(WS_UserAuthData* authData,
28002828 wolfSSHD_ConfigGetUserCAKeysFile (usrConf ))) {
28012829 wolfSSH_Log (WS_LOG_ERROR ,
28022830 "[SSHD] Per-user TrustedUserCAKeys override is not enforced "
2803- "for certificate authentication; rejecting (user=%s)" , usr );
2831+ "for certificate authentication; rejecting (user=%.32s)" ,
2832+ usr );
28042833 ret = WOLFSSH_USERAUTH_REJECTED ;
28052834 }
28062835 else {
@@ -2838,7 +2867,7 @@ static int RequestAuthentication(WS_UserAuthData* authData,
28382867 wolfSSH_Log (WS_LOG_ERROR ,
28392868 "[SSHD] Certificate authentication cannot bind the requested "
28402869 "user without FPKI or AuthorizedKeysFile; rejecting "
2841- "(user=%s )" , usr );
2870+ "(user=%.32s )" , usr );
28422871 ret = WOLFSSH_USERAUTH_REJECTED ;
28432872 #endif
28442873 }
0 commit comments