The vulnerability exists in the eventsource-encoder library, where the event and id fields of an SSE message are not properly sanitized. The patch for this vulnerability is in commit 0076767ef6deaa204578cdae5af5496aa27a5b53. The commit modifies the encodeMessage function in src/encode.ts to add validation for newline characters in the event and string id fields before they are written to the output stream. The newly added assertSingleLine function throws a TypeError if a newline character is found, thus preventing the injection. The vulnerable function is encodeMessage as it is the function that directly handles the unsanitized input and constructs the malformed SSE stream. The public-facing encode function is the entry point for this vulnerability, as it calls the internal encodeMessage function.