Skip to content

fix(security): keep SkillSpector's nv_build model registry for Build scans - #288

Merged
rng1995 merged 2 commits into
mainfrom
naren/port-skillspector-token-cap
Nov 2, 2026
Merged

rng1995 merged 2 commits into
mainfrom
naren/port-skillspector-token-cap

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Map the nv_build provider to SkillSpector's own nv_build provider (SKILLSPECTOR_PROVIDER=nv_build) instead of openai when SkillEvaluator bridges --llm security scans. SkillSpector then sizes requests from its NVIDIA Build model registry.
  • The credential path does not change. The child environment still has no nv_build credential, so SkillSpector sends requests through its OPENAI_API_KEY / OPENAI_BASE_URL fallback: your NVIDIA_API_KEY goes out as OPENAI_API_KEY, and the base URL is the public Build endpoint. Only the token-budget metadata changes.
  • The same fix applies to an explicit SKILLSPECTOR_PROVIDER=nv_build. The docs already list that value as supported, but until now it was rewritten to openai too.
  • Update the SkillSpector bridge docs (docs/environment-variables.mdx, docs/configuration.mdx) and add a CHANGELOG "Fixed" entry.

Why

SkillSpector reads token budgets from the active provider's model registry. With SKILLSPECTOR_PROVIDER=openai, Build-hosted models are not in that registry. SkillSpector then falls back to a 128,000-token context and a 32,000-token output budget. Its nv_build registry caps models such as openai/gpt-oss-120b and deepseek-ai/deepseek-v4-flash-0731 at 16,384 output tokens. So an NVIDIA Build user who points --llm security at one of these models gets requests for twice the model's output cap. Those requests can exceed what the endpoint accepts and leave the LLM security stage incomplete.

I checked SkillSpector 2.11.2 and 2.12.0 offline (2.13.3 afterwards, see below), with dummy OPENAI_* values and no network:

Model SKILLSPECTOR_PROVIDER=openai (before) SKILLSPECTOR_PROVIDER=nv_build (after)
openai/gpt-oss-120b 32,000 16,384
deepseek-ai/deepseek-v4-flash-0731 32,000 16,384
z-ai/glm-5.2 32,000 32,768
nvidia/nemotron-3-super-120b-a12b (default, not in either registry) 32,000 32,000

I re-ran the same check with SkillSpector v2.13.3, the latest release: SKILLSPECTOR_PROVIDER=nv_build selects NvBuildProvider and caps openai/gpt-oss-120b at 16,384, while SKILLSPECTOR_PROVIDER=openai still does not select it, so the fix is still needed. In all three versions is_llm_available() returns (True, None) with SKILLSPECTOR_PROVIDER=nv_build. The chat model is still ChatOpenAI pointed at the public Build endpoint. The default model's budget does not change. On GitHub, SkillSpector v2.9.5 and v2.9.6, the oldest versions this validator accepts, have the same nv_build OpenAI fallback and the same gpt-oss-120b cap.

Kept from public

  • The invocation-scoped SkillSpector environment is unchanged. It forwards only an allowlist of process variables plus the selected provider's settings, so ambient credentials never reach the child. The fix does not switch to removing named variables from a copy of the parent environment, which would protect less.
  • NVIDIA_API_KEY is still never forwarded under its own name, and no second NVIDIA credential name reaches SkillSpector. The existing assertions for this stay as they are.
  • The model-default precedence stays in place: SKILLSPECTOR_MODEL, then an explicit SKILL_EVAL_LLM_MODEL, then SkillSpector's per-provider default, which deliberately does not follow the chat default. The fix does not fall back to the chat default model.
  • The fixed public Build base URL and the fail-closed handling of unsupported SKILLSPECTOR_PROVIDER values are unchanged.

Tests

  • tests/validators/test_security.py:
    • Changed: the two nv_build routing tests now expect SKILLSPECTOR_PROVIDER=nv_build. Credential and base-URL assertions are unchanged.
    • New: test_explicit_nv_build_skillspector_provider_keeps_build_registry. With an explicit SKILLSPECTOR_PROVIDER=nv_build and ambient OPENAI_*, it checks that the child gets nv_build, the requested model, and the Build key and endpoint, and that NVIDIA_API_KEY is not forwarded.
    • New: test_nv_build_child_environment_applies_skillspector_build_output_cap. It runs an installed SkillSpector in a fresh process with the bridged environment. It checks that the metadata provider is NvBuildProvider, that the LLM is available through the OpenAI fallback, and that the output budget for openai/gpt-oss-120b does not exceed the Build registry cap. The test is skipped when SkillSpector is not installed, which includes CI.
  • All three changed or new routing tests fail with the old mapping. The SkillSpector-backed test passes against SkillSpector 2.11.2 and 2.12.0 with the fix, and fails with the old mapping (AssertionError: OpenAIProvider).
  • With SkillSpector v2.13.3 installed in the test environment, so the SkillSpector-backed test is not skipped, the nv_build, skillspector_child and public_nvidia tests all pass (12 passed).
  • The branch is rebased onto current main. The only conflict was the CHANGELOG, next to the new entry from fix(quality): report the 5,000-token skill budget as advisory #272, and both entries are kept.
  • Before the rebase, pytest tests/validators: 2527 passed, 2 skipped (the SkillSpector-backed test, and one test that needs a case-sensitive filesystem).
  • pytest on the security, OSS packaging/boundary/source-hygiene, provider config/routing and CI change-classifier tests: 871 passed, 1 skipped.
  • ruff check passes on the changed Python files. ruff format --check reports the same pre-existing drift as main and none in the changed lines; CI runs only ruff check.
  • scripts/check_oss_boundary.py: passed.

🤖 Generated with Claude Code

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed the diff plus the SkillSpector bridge in security.py, and verified the claim against a real SkillSpector install (pinned c7958a3, v2.12.0). No P1/P2 findings.

Verified: with the child env this code now builds (SKILLSPECTOR_PROVIDER=nv_build, OPENAI_API_KEY, OPENAI_BASE_URL=https://integrate.api.nvidia.com/v1, no NVIDIA_INFERENCE_KEY), is_llm_available() is (True, None), get_chat_model() returns a ChatOpenAI pointed at the Build URL, and get_max_output_tokens('openai/gpt-oss-120b') is 16384. The explicit SKILLSPECTOR_PROVIDER=nv_build path takes the same route and no extra credential is forwarded. Tests in test_security.py (nv_build / skillspector_child / public_nvidia) pass, 12 passed.

P3 (non-blocking, no change made): test_nv_build_child_environment_applies_skillspector_build_output_cap uses pytest.importorskip('skillspector'). SkillSpector is not a dependency of the project venv (CI installs it only in the separate /opt/skillspector venv), so that test is skipped in the normal Tests jobs and only the env-mapping asserts run there. I ran it manually against an installed SkillSpector and it passes. Consider a note or a CI job that runs it so the registry behavior is actually guarded.

Reviewed with Claude Code.

…scans

`--llm` security scans on the nv_build provider ran SkillSpector with
SKILLSPECTOR_PROVIDER=openai. SkillSpector looks up token budgets in the
active provider's model registry, and its OpenAI registry does not list
Build-hosted models, so it fell back to a 128,000-token context and a
32,000-token output budget. Build models with a smaller output cap, such
as openai/gpt-oss-120b (16,384 tokens), were asked for more output than
SkillSpector's own Build registry allows, which can exceed what the
endpoint accepts and leave the LLM security stage incomplete. An explicit
SKILLSPECTOR_PROVIDER=nv_build, which the docs list as supported, was
rewritten to openai the same way.

Map nv_build to SkillSpector's nv_build provider. The child environment
still carries no nv_build credential, so SkillSpector sends requests
through its OPENAI_API_KEY/OPENAI_BASE_URL fallback with the public Build
endpoint, exactly as before; only the budget metadata changes. Models the
Build registry does not list keep the same 32,000-token default.

Update the two routing tests that pinned openai, add a test for the
explicit nv_build override, and add a check that runs an installed
SkillSpector against the bridged environment (skipped when SkillSpector
is not installed). Update the SkillSpector bridge docs and CHANGELOG.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 force-pushed the naren/port-skillspector-token-cap branch from cbb8a7a to 36400f2 Compare November 2, 2026 07:44
@rng1995
rng1995 merged commit d82cfe0 into main Nov 2, 2026
21 checks passed
@rng1995
rng1995 deleted the naren/port-skillspector-token-cap branch November 2, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant