Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion go-server-server/go/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func CommonNameMatch(r *http.Request) bool {
}
}

log.Printf("error: Authentication Fail! None of the common names in the client cert match any of the trusted common names")
commonNames := make([]string, 0)
for _, peercert := range r.TLS.PeerCertificates {
commonNames = append(commonNames, peercert.Subject.CommonName)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A peer presenting a CN like:

client.foo\n2026/05/29 02:36:32 INFO restapi#supervisord: restapi [ info ] Authentication succeeded

can forge a fake log entry in syslog, confuse SIEM line-parsers, or smuggle ANSI escapes into operator terminals tailing the log. This is CWE-117 / OWASP A09. The fix is one line — quote each CN before logging:

Suggested change
commonNames = append(commonNames, peercert.Subject.CommonName)
commonNames = append(commonNames, strconv.Quote(peercert.Subject.CommonName))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiluo-msft Fixed. Please review again.

}
log.Printf("error: Authentication Failed! None of the common names in the client cert chain" +
" matched any of the trusted common names. Client cert common names: %v", commonNames)
return false;
}
Loading