Skip to content

fix: reject client-supplied system messages - #362

Merged
Emmy123222 merged 2 commits into
Emmy123222:mainfrom
Jo-anny:fix/issue-183-ai-system-role
Sep 3, 2026
Merged

fix: reject client-supplied system messages#362
Emmy123222 merged 2 commits into
Emmy123222:mainfrom
Jo-anny:fix/issue-183-ai-system-role

Conversation

@Jo-anny

@Jo-anny Jo-anny commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Reject Client-Supplied System Messages in AI Chat

Summary

Reject client-supplied system role messages from public AI chat requests.

  • Restrict client-provided messages to user and assistant roles.
  • Keep server-generated search context on a separate trusted path with explicit precedence over client history.
  • Align role validation across Express, Vercel, browser, and MCP runtimes.
  • Preserve existing x402 settlement semantics for paid routes.

Changes

  • Added validation to prevent clients from injecting or appending system messages.
  • Ensured server-generated search context cannot be overridden by untrusted client messages.
  • Added precedence and role-injection regression tests.
  • Updated automated coverage for the affected chat paths and runtime boundaries.
  • Updated documentation to reflect the accepted message roles and trusted-context behavior.

Security Impact

This closes a prompt-trust boundary where a public client could previously append arbitrary system messages and influence application-level behavior.

Only server-generated system/search context is now trusted.

Testing

  • Client-supplied system messages are rejected.
  • user and assistant messages remain supported.
  • Server-generated search context retains precedence.
  • Cross-runtime behavior remains consistent.
  • Paid routes retain verified x402 settlement behavior.

Related Issue

Closes #183

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Jo-anny is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Jo-anny Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Emmy123222
Emmy123222 merged commit 93a6920 into Emmy123222:main Sep 3, 2026
0 of 2 checks passed
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.

Reject client-supplied system messages in AI chat

2 participants