Skip to content

Security: Unsanitized client name used in User-Agent construction#379

Open
tuanaiseo wants to merge 1 commit intostripe:mainfrom
tuanaiseo:contribai/fix/security/unsanitized-client-name-used-in-user-age
Open

Security: Unsanitized client name used in User-Agent construction#379
tuanaiseo wants to merge 1 commit intostripe:mainfrom
tuanaiseo:contribai/fix/security/unsanitized-client-name-used-in-user-age

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

buildUserAgent appends untrusted clientName directly into a header value. If clientName contains control characters (e.g., CR/LF), it may enable header injection or malformed outbound requests depending on HTTP client behavior.

Severity: medium
File: tools/modelcontextprotocol/src/userAgent.ts

Solution

Sanitize clientName before interpolation: strip/deny CR, LF, and non-printable characters; enforce a strict allowlist regex and length limit.

Changes

  • tools/modelcontextprotocol/src/userAgent.ts (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

`buildUserAgent` appends untrusted `clientName` directly into a header value. If `clientName` contains control characters (e.g., CR/LF), it may enable header injection or malformed outbound requests depending on HTTP client behavior.

Affected files: userAgent.ts

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Apr 11, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented Apr 11, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant