MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / sanitizeHeaderValue

Function sanitizeHeaderValue

internal/outbound/compose.go:266–271  ·  view source on GitHub ↗

sanitizeHeaderValue strips CR and LF to prevent header injection. Without this, an attacker-controlled value like "abc\r\nBcc: leak@evil.com" in conversation_id (or any other passthrough header) would smuggle arbitrary headers into the composed message — a blind-Bcc / fake-DKIM-Signature primitive a

(s string)

Source from the content-addressed store, hash-verified

264// validates conversation_id and returns 400 on CRLF, but this is the
265// last line of defense for any future caller.
266func sanitizeHeaderValue(s string) string {
267 if !strings.ContainsAny(s, "\r\n") {
268 return s
269 }
270 return strings.NewReplacer("\r", "", "\n", "").Replace(s)
271}
272
273func generateBoundary() string {
274 b := make([]byte, 16)

Callers 1

headerWriterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected