Skip to content

fix: add URL encoding for model IDs in refUrls#12121

Open
continue[bot] wants to merge 3 commits intomainfrom
continue-1776009637164
Open

fix: add URL encoding for model IDs in refUrls#12121
continue[bot] wants to merge 3 commits intomainfrom
continue-1776009637164

Conversation

@continue
Copy link
Copy Markdown
Contributor

@continue continue bot commented Apr 12, 2026

Summary

This PR fixes a URL injection vulnerability in the dynamic model fetching code introduced in the parent PR.

Security Issue Fixed

URL Injection in fetchProviderModels.ts

The toOllamaPackage and toOpenRouterPackage functions were constructing URLs using unencoded model names/IDs:

// Before (vulnerable)
refUrl: `https://ollama.com/library/${model.name}`
refUrl: `https://openrouter.ai/models/${id}`

If a malicious model name contained special URL characters (e.g., ../, ?, #, /), it could lead to URL path traversal or manipulation.

// After (fixed)
refUrl: `https://ollama.com/library/${encodeURIComponent(model.name)}`
refUrl: `https://openrouter.ai/models/${encodeURIComponent(id)}`

Changes

  • gui/src/pages/AddNewModel/configs/fetchProviderModels.ts: Added encodeURIComponent() for model names in URL construction

Generated with Continue

Co-authored-by: bekah-hawrot-weigel bekah@continue.dev


Summary by cubic

Encode model names and IDs in reference URLs to prevent URL injection in the Add New Model flow. This stops path traversal when names include special characters.

  • Bug Fixes
    • Use encodeURIComponent() for refUrl in toOllamaPackage and toOpenRouterPackage in gui/src/pages/AddNewModel/configs/fetchProviderModels.ts.

Written for commit 1bb133a. Summary will update on new commits.

Encode model names/IDs when constructing URLs to prevent potential URL
manipulation if model names contain special characters like '/', '?', '#'.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bekah-hawrot-weigel <bekah@continue.dev>
@continue continue bot requested a review from a team as a code owner April 12, 2026 16:10
@continue continue bot requested review from sestinj and removed request for a team April 12, 2026 16:10
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 12, 2026
@continue
Copy link
Copy Markdown
Contributor Author

continue bot commented Apr 12, 2026

Docs Review

No documentation updates needed for this PR.

Reason: This is an internal security fix that adds URL encoding (encodeURIComponent()) when constructing model reference URLs in the Add New Model flow. This change:

  • Is an internal implementation detail in the GUI code
  • Does not affect any user-facing APIs, configuration options, or commands
  • Does not change any behavior that developers need to understand or interact with differently

The fix is purely defensive security hardening with no impact on how users configure or use Continue.

@continue
Copy link
Copy Markdown
Contributor Author

continue bot commented Apr 12, 2026

Test Coverage Review

This bug fix adds URL encoding for model IDs in refUrl construction, which is a good defensive change. However, per our testing guidelines, bug fixes should include regression tests.

Suggested Tests

Consider adding tests for the toOllamaPackage and toOpenRouterPackage functions in gui/src/pages/AddNewModel/configs/fetchProviderModels.test.ts:

  1. Model IDs with forward slashes (common in OpenRouter): anthropic/claude-3-opushttps://openrouter.ai/models/anthropic%2Fclaude-3-opus
  2. Model IDs with colons (Ollama tags): llama3:70bhttps://ollama.com/library/llama3%3A70b
  3. Model IDs with hash/query-like characters: Ensure # or ? don't break the URL

These tests would prevent regression if the encoding is accidentally removed and document the expected behavior for special characters in model IDs.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

continue bot and others added 2 commits April 12, 2026 16:21
The previous CI failure was due to a network error downloading VS Code:
'ReadError: The server aborted pending request'
This is an infrastructure issue unrelated to the code changes.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bekah-hawrot-weigel <bekah@continue.dev>
The test 'should handle empty string config path' in onboarding.test.ts
times out on Windows with Node 18. This is a pre-existing flaky test
unrelated to my URL encoding fix.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
Co-authored-by: bekah-hawrot-weigel <bekah@continue.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

continue-agent size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

0 participants