Skip to content

review fixes for #598: Scalar SRI pin, buy-x402 guard order, 402 token sanitization#599

Merged
bussyjd merged 3 commits into
integration/pr-593-plusfrom
fix/integration-593plus-review
Jun 5, 2026
Merged

review fixes for #598: Scalar SRI pin, buy-x402 guard order, 402 token sanitization#599
bussyjd merged 3 commits into
integration/pr-593-plusfrom
fix/integration-593plus-review

Conversation

@bussyjd

@bussyjd bussyjd commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review fixes for the #593-plus integration branch

Targets integration/pr-593-plus. Addresses the three findings from the multi-agent review of the consolidated diff. No blockers were found; these are the hardening follow-ups.

1. security(x402) — SRI-pin the Scalar bundle on the public /api page (MED)

internal/serviceoffercontroller/scalar_html.go

The /api OpenAPI reference is served over the public tunnel and pulls @scalar/api-reference@1.34.0 from jsDelivr. scalarBundleSRI was empty, so the browser executed whatever the CDN returned, unverified. Populated with the sha384 of the pinned bundle.

Pre-merge check: the hash is taken over the exact (jsDelivr-minified) bytes the pinned URL serves today. Load /api once in a browser and confirm no console SRI error before this rides to main; re-derive on every scalarBundleVersion bump.

2. fix(buy-x402) — guard before warning (MED)

internal/embed/skills/buy-x402/scripts/buy.py

The paid/<model> existence guard ran after the no-auto-refill WARNING, so a model LiteLLM would refuse still printed a "your chat will brick" warning describing a failure mode that can't happen when the default is never switched. Reordered: refuse first, warn only when actually adopting.

3. security(x402) — sanitize ServiceOffer-sourced tokens in copy-paste commands (LOW)

internal/x402/paymentrequired.go (+ tests)

spec.model.name / metadata.name flow from the CR into copy-pasteable obol buy inference … commands on the public 402 page. Added sanitizeDisplayToken at the render boundary — CR tokens must match ^[A-Za-z0-9._:/-]+$ or collapse to the existing safe placeholder. Real ids (qwen3.5:9b, anthropic/claude-3-5-sonnet-latest) pass through unchanged; shell metacharacters cannot.

Verification

  • python3 -m py_compile buy.py OK
  • go build ./..., go vet, gofmt -l clean
  • full unit suite green; new tests TestSanitizeDisplayToken + TestInferenceCopy_StripsShellMetacharsFromCommand

bussyjd added 3 commits June 5, 2026 11:45
The /api OpenAPI reference is served over the public tunnel and pulls the
@scalar/api-reference bundle from jsdelivr. The integrity hash was left empty
in phase 1, so the browser executed whatever the CDN returned, unverified.

Populate scalarBundleSRI with the sha384 of the pinned 1.34.0 bundle so a
tampered CDN response is blocked. Comment updated to stress the hash must be
re-derived in lockstep with every scalarBundleVersion bump.
…arning

The 'paid/<model> not selectable in LiteLLM' guard ran *after* the
no-auto-refill WARNING. A model that LiteLLM would refuse still printed a
scary 'every chat turn fails when the pool empties' warning describing a
primary-model failure mode that cannot occur when the default was never
switched. Reorder so we refuse first and only warn when we are actually
about to adopt the model.
…e commands

spec.model.name and metadata.name flow from the ServiceOffer CR into
copy-pasteable 'obol buy inference ...' commands rendered on the public 402
page. A hostile or fat-fingered offer could smuggle shell metacharacters into
a command a reader might paste. Add sanitizeDisplayToken at the render
boundary: CR-sourced tokens must match the model-id/k8s-name charset
(^[A-Za-z0-9._:/-]+$) or collapse to the existing safe placeholder. Real ids
like qwen3.5:9b and anthropic/claude-3-5-sonnet-latest pass through unchanged.
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