Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
strategy:
fail-fast: false
matrix:
mcp-version: ["1.28.1", "2.3.0"]
mcp-version: ["1.30.0", "2.3.0"]
env:
MCP_SDK_VERSION: ${{ matrix.mcp-version }}
steps:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to SkillEvaluator are documented in this file.

## Unreleased

### Security

- Update LiteLLM and the minimum AWS SDK version in the optional LLM and
Tier 3 installs. Bedrock preflight and host inference reject HTTP endpoint
overrides when bearer authentication is configured.
- Update aiohttp, fsspec, msgpack, OAuthLib, and urllib3 in the optional
installs to include upstream security fixes.
- Raise the Tier 3 MCP Python SDK floor to 1.30.0 for upstream security fixes.
- Update filelock, multidict, and pip in the optional LLM, Tier 2, Tier 3,
and dependency audit installs to include upstream security fixes.

### Changed

- Claude Code log recovery pairs batched and delayed tool results without repeatedly
Expand Down Expand Up @@ -38,6 +49,14 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Bedrock preflight and host inference now sign requests with IAM credentials
when `AWS_BEARER_TOKEN_BEDROCK` is empty or whitespace-only, for example when
a CI job exports an unset secret. Previously the Tier 3 preflight sent a blank
`Authorization: Bearer` header, and host inference failed with an illegal
header value. This includes models called through the Bedrock Responses
route.
- Bedrock inference checks HTTPS on the endpoint selected for the request,
so an unused HTTP override no longer blocks a valid HTTPS route.
- `tier3 validate` now exits nonzero when `evals/` is missing, matching the
error it reports.
- Scanner install hints in `health-check` and `doctor` now match the host:
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#
# The image installs every public optional dependency. Tier 3 still requires
# credentials for the selected provider and agent at runtime.
FROM python:3.12-slim
# Use a Python TLS stack that rejects the affected certificates during pip bootstrap.
FROM python:3.12.16-slim@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b

ENV PIP_NO_INPUT=1 \
PYTHONDONTWRITEBYTECODE=1
Expand Down
6 changes: 3 additions & 3 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ records the exact resolved dependency set used for this release.
| Dependency group | Packages and licenses |
| --- | --- |
| Base | Bandit (Apache-2.0), Click (BSD-3-Clause), IDNA (BSD-3-Clause), Jinja2 (BSD-3-Clause), Markdown-It-Py (MIT), Packaging (Apache-2.0 or BSD-2-Clause), Pydantic (MIT), PyYAML (MIT), regex (Apache-2.0 AND CNRI-Python), Rich (MIT), uv (Apache-2.0 or MIT) |
| LLM | Anthropic (MIT), Boto3 (Apache-2.0), LiteLLM (MIT), OpenAI (Apache-2.0) |
| LLM | aiohttp (Apache-2.0 AND MIT), Anthropic (MIT), Boto3 (Apache-2.0), filelock (MIT), fsspec (BSD-3-Clause), LiteLLM (MIT), multidict (Apache-2.0), OpenAI (Apache-2.0), urllib3 (MIT) |
| Tier 3 | Harbor (Apache-2.0), MCP (MIT), OAuthLib (BSD-3-Clause), PyJWT (MIT), python-dotenv (BSD-3-Clause) |
| Security | pip-audit (Apache-2.0) |
| Dashboard | Streamlit (Apache-2.0) |
| Security | filelock (MIT), msgpack (Apache-2.0), pip (MIT), pip-audit (Apache-2.0), urllib3 (MIT) |
| Dashboard | Streamlit (Apache-2.0), urllib3 (MIT) |

## Embedded report charts

Expand Down
2 changes: 1 addition & 1 deletion ci/gitlab/all-tiers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ skill-evaluation:
- when: on_success

.skill-evaluation-tools:
image: python:3.12.12-slim
image: python:3.12.16-slim@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
before_script:
- |
if ! command -v git >/dev/null 2>&1; then
Expand Down
2 changes: 1 addition & 1 deletion ci/gitlab/feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
skill-evaluation-feedback:
# Serializes comment updates; each job checks its own MR and current commit.
resource_group: skillevaluator-feedback
image: python:3.12.12-slim
image: python:3.12.16-slim@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
stage: test
# The protected environment scopes the publisher token and restricts who can
# run this job. `prepare` records no deployment, so "Prevent outdated
Expand Down
10 changes: 7 additions & 3 deletions docs/tier3-runtime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,13 @@ The exact Harbor pin is deliberate: its CLI, Python models, result artifacts,
and environment/agent subclass interfaces form one compatibility surface. This
release targets stable Harbor 0.25.0 rather than unreleased `main`. Harbor stays
behind the operator-selected `tier3` extra, so static Tier 1 installs do not pull
it in. The shared LLM client window (`litellm>=1.92.0,<1.94.0.dev0`) admits
patched 1.92 and 1.93 releases validated with this integration while excluding
prerelease and as-yet unvalidated 1.94 behavior.
it in. The shared LLM client uses `litellm>=1.110.2,<1.111.0.dev0` with
`boto3>=1.44.0`. When you set `AWS_BEARER_TOKEN_BEDROCK`, use HTTPS for the
Bedrock catalog and runtime endpoints checked by preflight and for the
endpoint used by the selected LiteLLM route. The runtime uses
`AWS_BEDROCK_RUNTIME_ENDPOINT`, Mantle uses `BEDROCK_MANTLE_API_BASE`, and
Claude Platform uses `ANTHROPIC_AWS_BASE_URL` or falls back to
`ANTHROPIC_AWS_API_BASE`.

The integration preserves SkillEvaluator's runtime and artifact contracts while
using Harbor 0.25:
Expand Down
28 changes: 22 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ dependencies = [
[project.optional-dependencies]
# Shared public LLM / embedding clients used by LLM-backed checks, Tier 2, and Tier 3.
llm = [
# Security floors for dependencies installed through LiteLLM and boto3.
"aiohttp>=3.14.4,<4",
"anthropic>=0.83.0",
"boto3>=1.34.0",
"litellm>=1.92.0,<1.94.0.dev0",
# Botocore 1.44 introduced HTTPS enforcement for bearer authentication.
"boto3>=1.44.0",
# The LLM stack and Harbor use filelock; aiohttp uses multidict.
"filelock>=4.2.1,<5",
"fsspec>=2026.6.0",
"litellm>=1.110.2,<1.111.0.dev0",
"multidict>=6.9.1,<7",
"openai>=2.21.0",
"urllib3>=2.8.0,<3",
]
# Tier 2 intra-skill deduplication and local-catalog inter-skill similarity.
tier2 = [
Expand All @@ -71,18 +79,25 @@ tier2 = [
tier3 = [
"skillevaluator[llm]",
"harbor[gke]==0.25.0",
# CVE-2026-59950, CVE-2026-52870, and CVE-2026-52869 fixed floor.
"mcp>=1.28.1,<2",
# MCP 1.30 fixes the server-authentication, client-transport, and session limit advisories.
"mcp>=1.30.0,<2",
# CVE-2026-48522 through CVE-2026-48526 fixed floor.
"pyjwt[crypto]>=2.13.0",
# GHSA-hj66-6f7g-4r5v and GHSA-xpv3-w29h-x7cv fixed floor (via harbor[gke]).
"oauthlib>=4.0.0",
# The 4.0.1 release includes the device grant security fix (via harbor[gke]).
"oauthlib>=4.0.1",
# PYTHON_DOTENV_DISABLED, which keeps Harbor from loading .env files, needs 1.2.0.
"python-dotenv>=1.2.0",
]
# Scanner for the opt-in Dependency Vulnerability Audit (`--check dependency`).
security = [
# Security floor for CacheControl's file-backed cache.
"filelock>=4.2.1,<5",
# CVE-2026-114613 fixed floor for pip-audit's CacheControl dependency.
"msgpack>=1.2.3",
# pip 26.2.2 removes trust for the affected eMudhra certificate chain.
"pip>=26.2.2",
"pip-audit>=2.10.0",
"urllib3>=2.8.0,<3",
]
# Verify GitHub-signed execution receipts for the optional CI report publisher.
publisher = [
Expand All @@ -92,6 +107,7 @@ publisher = [
dashboard = [
# server.allowedHosts, which limits the dashboard to loopback host names, needs 1.61.
"streamlit>=1.61,<2",
"urllib3>=2.8.0,<3",
]
# Full public install convenience bundle.
all = [
Expand Down
157 changes: 147 additions & 10 deletions src/skillevaluator/inference/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class supports two usage patterns:
import re
import threading
import urllib.error
from collections.abc import Callable, Mapping, Sequence
from collections.abc import Callable, Iterator, Mapping, Sequence
from contextlib import contextmanager, nullcontext
from dataclasses import replace
from typing import Any, NamedTuple
from urllib.parse import urlsplit
Expand Down Expand Up @@ -56,6 +57,7 @@ class supports two usage patterns:
anthropic_refusal_fallback_model,
completion_token_limit,
effective_reasoning_effort,
has_bedrock_bearer_token,
is_claude_5_5_or_later,
is_openai_reasoning_model,
resolve_llm_provider,
Expand All @@ -66,6 +68,122 @@ class supports two usage patterns:
_NATIVE_OPENAI_AUTHORITIES = frozenset({"api.openai.com", "api.openai.com:443"})
_NATIVE_OPENAI_PATHS = frozenset({"/v1", "/v1/"})

_BEDROCK_BEARER_TOKEN_ENV = "AWS_BEARER_TOKEN_BEDROCK"


class _BedrockTokenWindow:
"""Blank AWS_BEARER_TOKEN_BEDROCK while Bedrock calls are in flight, then restore it exactly.

LiteLLM's Bedrock Responses route picks its token as `api_key or <this variable>`, so an empty
`api_key` still falls back to a whitespace-only value and sends it as a Bearer header. LiteLLM
has no per-call setting that skips that fallback. Concurrent calls share one blanked window:
the first saves the value and the last puts it back.
"""

def __init__(self) -> None:
self._lock = threading.Lock()
self._holders = 0
self._saved: str | None = None

@contextmanager
def blank(self) -> Iterator[None]:
with self._lock:
if self._holders == 0:
self._saved = os.environ.get(_BEDROCK_BEARER_TOKEN_ENV)
os.environ[_BEDROCK_BEARER_TOKEN_ENV] = ""
self._holders += 1
try:
yield
finally:
with self._lock:
self._holders -= 1
if self._holders == 0:
if self._saved is None:
os.environ.pop(_BEDROCK_BEARER_TOKEN_ENV, None)
else:
os.environ[_BEDROCK_BEARER_TOKEN_ENV] = self._saved
self._saved = None


_bedrock_token_window = _BedrockTokenWindow()

_BEDROCK_RUNTIME_ENDPOINT = "AWS_BEDROCK_RUNTIME_ENDPOINT"
_BEDROCK_MANTLE_ENDPOINT = "BEDROCK_MANTLE_API_BASE"
_BEDROCK_PLATFORM_ENDPOINTS = ("ANTHROPIC_AWS_BASE_URL", "ANTHROPIC_AWS_API_BASE")


def _require_https_for_bedrock_bearer_endpoint(setting: str, endpoint: str | None) -> None:
"""Reject an active override before LiteLLM can send bearer credentials."""
if not endpoint:
return
try:
target = urlsplit(endpoint)
uses_https = target.scheme == "https" and target.hostname is not None
except ValueError:
uses_https = False
if not uses_https:
raise LLMClientError(f"{setting} must use HTTPS with a Bedrock bearer token.")


def _bedrock_bearer_runtime_override(
model: str,
*,
aliases: Mapping[str, str],
sdk_api_base: str | None,
has_fallbacks: bool,
) -> str | None:
"""Validate the active LiteLLM route and return its explicit runtime override."""
from litellm.llms.bedrock.common_utils import BedrockModelInfo
from litellm.responses.bridge_check import responses_api_bridge_check
from litellm.secret_managers.main import get_secret_str
from litellm.utils import ProviderConfigManager, get_llm_provider

if has_fallbacks:
# A LiteLLM fallback can select a different route from the initial request.
for setting in (_BEDROCK_RUNTIME_ENDPOINT, _BEDROCK_MANTLE_ENDPOINT, *_BEDROCK_PLATFORM_ENDPOINTS):
_require_https_for_bedrock_bearer_endpoint(setting, get_secret_str(setting))
_require_https_for_bedrock_bearer_endpoint("LiteLLM api_base", sdk_api_base)

model, provider, _, api_base = get_llm_provider(model=aliases.get(model, model))
if provider not in {"bedrock", "bedrock_mantle"}:
return None

# LiteLLM can select Responses first and fall back to chat for a chat-only model.
model_info, model = responses_api_bridge_check(model, provider, api_base=api_base)
native_responses = False
if model_info.get("mode") == "responses":
model, provider, _, api_base = get_llm_provider(model=model, custom_llm_provider=provider, api_base=api_base)
native_responses = (
ProviderConfigManager.get_provider_responses_api_config(provider, model=model, api_base=api_base)
is not None
)
if not native_responses and model in aliases:
# The reverse bridge calls completion again with the stripped model and provider.
model, provider, _, api_base = get_llm_provider(
model=aliases[model], custom_llm_provider=provider, api_base=api_base
)
route = BedrockModelInfo.get_bedrock_route(model) if not native_responses else None

if provider == "bedrock_mantle" or route == "mantle":
settings = (_BEDROCK_MANTLE_ENDPOINT,)
if provider == "bedrock_mantle" and not native_responses:
api_base = api_base or sdk_api_base
elif route == "claude_platform":
settings = _BEDROCK_PLATFORM_ENDPOINTS
api_base = api_base or sdk_api_base
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
else:
settings = (_BEDROCK_RUNTIME_ENDPOINT,)

if api_base:
_require_https_for_bedrock_bearer_endpoint("LiteLLM api_base", api_base)
return None
for setting in settings:
if endpoint := get_secret_str(setting):
_require_https_for_bedrock_bearer_endpoint(setting, endpoint)
# Leave URL normalization to the SDK for Mantle and Claude Platform.
return endpoint if setting == _BEDROCK_RUNTIME_ENDPOINT else None
return None


def _effective_openai_base_url(explicit_base_url: str | None) -> str:
if explicit_base_url is not None:
Expand Down Expand Up @@ -777,19 +895,38 @@ def _anthropic_kwargs(include_schema: bool) -> dict[str, Any]:
return _checked_content(content.strip(), getattr(response, "stop_reason", None))
if config.provider == "bedrock":
try:
from litellm import completion
import litellm

completion = litellm.completion
except ImportError as exc:
raise LLMClientError(
"The 'litellm' package is required for Bedrock LLM operations. Install with: pip install 'skillevaluator[llm]'"
) from exc
response = completion(
model=config.litellm_model,
messages=_chat_messages(system_prompt, turns),
aws_region_name=config.region,
**_temperature_kwargs(config.model, self._temperature),
**({"max_tokens": max_tokens} if max_tokens is not None else {}),
**({"timeout": self._timeout} if self._timeout is not None else {}),
)
# LiteLLM can load environment variables on its first import.
has_bearer_token = has_bedrock_bearer_token()
endpoint = None
if has_bearer_token:
endpoint = _bedrock_bearer_runtime_override(
config.litellm_model,
aliases=litellm.model_alias_map or {},
sdk_api_base=litellm.api_base,
has_fallbacks=bool(litellm.model_fallbacks),
)
# LiteLLM sends a whitespace-only AWS_BEARER_TOKEN_BEDROCK as a blank Bearer header.
# An empty key makes it sign with the IAM credentials, as it does for an unset variable.
# The Responses route also reads the variable itself, so hide it for the call.
ignore_blank_token = _BEDROCK_BEARER_TOKEN_ENV in os.environ and not has_bearer_token
with _bedrock_token_window.blank() if ignore_blank_token else nullcontext():
response = completion(
model=config.litellm_model,
messages=_chat_messages(system_prompt, turns),
aws_region_name=config.region,
**({"aws_bedrock_runtime_endpoint": endpoint} if endpoint else {}),
**({"api_key": ""} if ignore_blank_token else {}),
**_temperature_kwargs(config.model, self._temperature),
**({"max_tokens": max_tokens} if max_tokens is not None else {}),
**({"timeout": self._timeout} if self._timeout is not None else {}),
)
return _extract_choice_content(response)

def _openai_kwargs(include_schema: bool) -> dict[str, Any]:
Expand Down
12 changes: 10 additions & 2 deletions src/skillevaluator/provider_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
_HEX_DIGIT_BYTES = frozenset(b"0123456789abcdefABCDEF")
_UNRESERVED_BYTES = frozenset(b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~")
_NO_CUSTOM_TEMPERATURE_MODEL_IDS = frozenset({"claude-mythos-preview"})
_ANTHROPIC_BEDROCK_PREFIX_RE = re.compile(r"^(?:(?:[a-z]{2}|global)\.)?anthropic\.")
_BEDROCK_VENDOR_PREFIX_RE = re.compile(r"^(?:(?:[a-z]{2}|global)\.)?(?:anthropic|openai)\.")
# Gateway catalogs can put vendor words before the model name, as in
# ``aws/anthropic/bedrock-claude-opus-5-5``.
_GATEWAY_LEAF_PREFIX_RE = re.compile(r"^(?:[a-z]+-)+?(?=(?:claude|gpt)-)")
Expand Down Expand Up @@ -148,7 +148,7 @@ def _model_leaf(model: str) -> str:
"""Return a normalized model ID for capability checks only."""
leaf = str(model or "").strip().casefold().rsplit("/", 1)[-1]
leaf = _GATEWAY_LEAF_PREFIX_RE.sub("", leaf, count=1)
return _ANTHROPIC_BEDROCK_PREFIX_RE.sub("", leaf, count=1)
return _BEDROCK_VENDOR_PREFIX_RE.sub("", leaf, count=1)


def _claude_version(model: str) -> tuple[int, int] | None:
Expand Down Expand Up @@ -677,6 +677,14 @@ def _environment(environ: Mapping[str, str] | None) -> Mapping[str, str]:
return os.environ if environ is None else environ


def has_bedrock_bearer_token(environ: Mapping[str, str] | None = None) -> bool:
"""Return whether AWS_BEARER_TOKEN_BEDROCK holds a real token.

An unset, empty, or whitespace-only value means no token, so Bedrock calls use IAM credentials.
"""
return bool(_environment(environ).get("AWS_BEARER_TOKEN_BEDROCK", "").strip())


def _required(environ: Mapping[str, str], variable: str) -> str:
value = environ.get(variable, "").strip()
if not value:
Expand Down
Loading
Loading