Am I affected?

type your cowlib version to check

Description

Improper Neutralization of CRLF Sequences ('CRLF Injection') vulnerability in ninenines cowlib allows SSE event splitting and injection via unvalidated field values.

cow_sse:event/1 in cowlib guards the id and event fields against \n but not against bare \r, and the internal prefix_lines/2 function used for data and comment fields splits only on \n. Because the SSE specification requires decoders to treat \r\n, \r, and \n as equivalent line terminators, an attacker who controls any of these fields can inject additional SSE lines and forge a complete event with an arbitrary event type and data payload on the receiving end. In typical deployments where browser EventSource clients or other SSE consumers dispatch on event.type and render event.data, this enables event splitting, client-side logic manipulation, and stored-XSS-equivalent behaviour when event data is inserted into the DOM.

This issue affects cowlib from 2.6.0 before 2.16.1.

Weaknesses & attack patterns

Weakness

CWE-93 · Improper Neutralization of CRLF Sequences ('CRLF Injection') in catalog → MITRE ↗

Attack patterns

CAPEC-34 · HTTP Response Splitting MITRE ↗

Affected — Hex / cowlib Hex.pm ↗ Repository ↗

2.6.0 < 2.16.1 affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:ninenines:cowlib:*:*:*:*:*:*:*:*
modules · source files · routines
modules cow_sse
source files src/cow_sse.erl
routines cow_sse:event/1 · cow_sse:event_id/1 · cow_sse:event_name/1 · cow_sse:event_data/1 · cow_sse:event_comment/1 · cow_sse:prefix_lines/2

Affected — GitHub / ninenines/cowlib Repository ↗

93b2b89 < 6165fc4 affected
every other version: unaffected
default status unaffected
cpe cpe:2.3:a:ninenines:cowlib:*:*:*:*:*:*:*:*
modules · source files · routines
modules cow_sse
source files src/cow_sse.erl
routines cow_sse:event/1 · cow_sse:event_id/1 · cow_sse:event_name/1 · cow_sse:event_data/1 · cow_sse:event_comment/1 · cow_sse:prefix_lines/2

Workarounds

Sanitize user-controlled values before passing them to cow_sse:event/1: reject or strip any value containing \r or \n characters in the id, event, data, and comment fields. Alternatively, ensure that all SSE field values are derived exclusively from trusted, application-controlled data rather than user input.

Configurations

The application must pass user-controlled data as the id, event, data, or comment field to cow_sse:event/1 (or a higher-level wrapper such as cowboy_req:stream_events/3). Applications that construct SSE events exclusively from trusted, application-controlled values are not affected.

References

Credits

Peter Ullrich Finder
Loïc Hoguin Remediation developer

CVSS breakdown

CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:L/SA:N
« All CVEs