fix(tools): normalize media model lookups#66422
Conversation
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Potential log forging/CRLF injection via unsanitized provider/model in resolveModelFromRegistry error
Description
Vulnerable code: if (!model) {
throw new Error(`Unknown model: ${resolvedRef.provider}/${resolvedRef.model}`);
}While the change replaced raw inputs with normalized ones, normalization here does not provide output neutralization; it may still contain CR/LF and other control chars and can reveal canonicalized identifiers. RecommendationDo not embed untrusted strings directly into error messages that may be logged or returned to clients. Options:
function safeOneLine(value: string): string {
return value.replace(/[\r\n\t\u0000-\u001f\u007f]/g, "").slice(0, 200);
}
if (!model) {
throw new Error(
`Unknown model: ${safeOneLine(resolvedRef.provider)}/${safeOneLine(resolvedRef.model)}`,
);
}
Analyzed PR: #66422 at commit Last updated on: 2026-04-14T08:24:09Z |
Greptile SummaryThis PR fixes a normalization mismatch in the shared media-tool registry lookup helper: Confidence Score: 5/5
Reviews (1): Last reviewed commit: "Merge branch 'main' into kitsune/pr-6616..." | Re-trigger Greptile |
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
* fix(tools): normalize media model lookups * Update CHANGELOG.md
Summary
Unknown model, which broke the built-in image tool and the PDF path that shares the same lookup helper.resolveModelFromRegistry()now normalizes the provider/model pair before registry lookup and error reporting, and a focused unit test locks that seam in.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
src/agents/tools/media-tool-shared.tscalledmodelRegistry.find()with raw tool-path refs, while the discovered-model registry expects the same normalized provider/model identity used elsewhere.src/media-understanding/image.tsalready normalized before registry lookup; the shared media-tool helper had drifted from that working pattern.Regression Test Plan (if applicable)
src/agents/tools/media-tool-shared.model-resolution.test.tsUser-visible / Behavior Changes
Unknown modelwhen the ref only differs by normalization.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Unknown modeleven when the configured model existed.Evidence
Attach at least one:
Human Verification (required)
pnpm test:serial src/agents/tools/media-tool-shared.test.ts src/agents/tools/media-tool-shared.model-resolution.test.ts;pnpm test:serial src/agents/tools/image-tool.test.ts src/agents/tools/pdf-tool.test.ts src/agents/tools/pdf-tool.model-config.test.ts src/agents/tools/pdf-tool.model-catalog.test.ts src/agents/tools/pdf-tool.helpers.test.ts;pnpm buildReview Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations