fix: add URL encoding for model IDs in refUrls#12121
fix: add URL encoding for model IDs in refUrls#12121continue[bot] wants to merge 3 commits intomainfrom
Conversation
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>
Docs ReviewNo documentation updates needed for this PR. Reason: This is an internal security fix that adds URL encoding (
The fix is purely defensive security hardening with no impact on how users configure or use Continue. |
Test Coverage ReviewThis bug fix adds URL encoding for model IDs in Suggested TestsConsider adding tests for the
These tests would prevent regression if the encoding is accidentally removed and document the expected behavior for special characters in model IDs. |
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>
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.tsThe
toOllamaPackageandtoOpenRouterPackagefunctions were constructing URLs using unencoded model names/IDs:If a malicious model name contained special URL characters (e.g.,
../,?,#,/), it could lead to URL path traversal or manipulation.Changes
gui/src/pages/AddNewModel/configs/fetchProviderModels.ts: AddedencodeURIComponent()for model names in URL constructionGenerated 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.
encodeURIComponent()forrefUrlintoOllamaPackageandtoOpenRouterPackageingui/src/pages/AddNewModel/configs/fetchProviderModels.ts.Written for commit 1bb133a. Summary will update on new commits.