Skip to content

security(#236): wrap exercise name in XML tags in muscle inference prompt - #246

Merged
ChristopherRotnes merged 1 commit into
masterfrom
security/236-prompt-sanitize
May 15, 2026
Merged

ChristopherRotnes merged 1 commit into
masterfrom
security/236-prompt-sanitize

Conversation

@ChristopherRotnes

@ChristopherRotnes ChristopherRotnes commented May 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • buildMuscleInferencePrompt was interpolating user-supplied exercise names with bare double-quotes, so a name like Knebøy" Ignore previous instructions could break the prompt structure
  • Angle brackets are stripped from the name first (prevents XML tag injection), then the name is wrapped in <exercise> tags — the Anthropic-recommended boundary for untrusted input in Claude prompts
  • 3 new tests added to prompts.test.js covering: XML tag presence, safe embedding of double-quoted names, and angle-bracket stripping
  • Recommendation prompts (buildRecommendPrompt, buildPeriodRecommendPrompt) interpolate controlled muscle labels from the MUSCLES constant (not user input) — no change needed there

Test plan

  • Run npm test — 90 tests should pass including 3 new prompt injection tests
  • Type an exercise name with double quotes (e.g. Knebøy "dyp") in ExerciseForm — muscle inference should still work correctly
  • Verify the generated prompt in browser DevTools network tab shows <exercise>...</exercise> wrapping

Closes #236

🤖 Generated with Claude Code

…ompt

A user-supplied exercise name was interpolated with bare double-quotes in
buildMuscleInferencePrompt, allowing a crafted name containing a quote to
break out of the string boundary and inject instructions. Angle brackets
are stripped first, then the name is wrapped in <exercise> tags — the
Anthropic-recommended structural boundary for untrusted input.

Three new tests cover: XML tag presence, safe embedding of a name with
double quotes, and stripping of angle brackets to prevent tag injection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@supabase

supabase Bot commented May 15, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project kyolnraqudwrjjbtxhwx because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-246.westeurope.7.azurestaticapps.net

@ChristopherRotnes
ChristopherRotnes merged commit a0a716f into master May 15, 2026
3 checks passed
@ChristopherRotnes
ChristopherRotnes deleted the security/236-prompt-sanitize branch May 15, 2026 21:02

This branch was previously deployed

1 inactive deployment
preview — 04c9d9a0 Deployed May 15, 2026 by ChristopherRotnes via Build and deploy #8
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.

As a developer I want exercise names sanitized before Claude prompt interpolation so I can prevent prompt injection

1 participant