The vulnerability exists in the SseStream._transform method within @nestjs/core. The method constructs Server-Sent Events (SSE) messages and did not properly sanitize the message.type and message.id fields. An attacker, able to control these fields, could inject newline characters (\r or \n). Since the SSE protocol uses newlines to delimit fields and events, this flaw allowed for the injection of malicious data:, event:, or id: fields. This could lead to cross-site scripting (XSS) if the client renders the data as HTML, event spoofing, or corruption of the client's reconnection state. The provided patch confirms this by adding a sanitization step that removes newline characters from these fields, directly addressing the root cause of the vulnerability. Therefore, the SseStream._transform function is the precise location of the vulnerability.