The vulnerability lies in the lack of certificate validation when establishing a secure SMTP connection using STARTTLS. The analysis of the patch commit 4ccd9088e00c659719438781975d087951b093af reveals the exact location of the vulnerability. In the file ckan/lib/mailer.py, the function _mail_recipient was modified. The vulnerable code was the line smtp_connection.starttls(), which was called without any arguments. This usage of the starttls method from Python's smtplib does not perform any certificate validation. The patch introduces logic to create a proper SSL context using ssl.create_default_context(), which enforces certificate validation by default, and then passes this context to the starttls method. This ensures that the SMTP server's certificate is verified, mitigating the Man-in-the-Middle (MITM) risk. The function _mail_recipient is the direct runtime indicator of this vulnerability being triggered.