Skip to content

fix(captures): never quote a bad store netloc; keep Azure reads inside the prefix - #76

Merged
babaliauskas merged 1 commit into
mainfrom
fix/store-uri-hardening
Nov 17, 2026
Merged

babaliauskas merged 1 commit into
mainfrom
fix/store-uri-hardening

Conversation

@babaliauskas

Copy link
Copy Markdown
Collaborator

Brings the CLI's own copy of the store code in line with two evalshift-sdk fixes, so both sides behave and word their errors the same way:

What changes

captures/store_uri.py

  • urlsplit rejects some netlocs on its own (a bracketed host that is not an IP address, a character that NFKC-normalises to /), and two of those errors quote the netloc, which can hold a pasted secret. The parser now catches that and raises store URI names an invalid bucket or account; accepted forms: .... It raises outside the except, so no exception is chained (__cause__ and __context__ are both None).
  • New has_unsafe_segment(path), copied from the SDK. An az:// container or prefix with an empty, . or .. segment is rejected with the SDK's message. S3 and GCS keep such prefixes literal and still accept them.

captures/stores/azure.py

  • AzureBlobStore raises ValueError for such a container or prefix at construction, and for such a key in get(), before any client call. The Azure client resolves dot segments in the request URL, even across containers, so az://acct/evals/../other used to read from container other. list() is not checked because its prefix is sent as a query parameter, not in the URL path. The keys capture sync downloads were already filtered to the SDK's layout, so the get check is a second safeguard. The exposure that actually happened was through the configured prefix.

evalshift.yaml loading picks this up through the existing captures.store validator: both new errors fail at load, and the config test now checks that neither leaks the secret.

Tests (written first, watched fail)

  • test_captures_store_uri.py: the SDK's bad-netloc vectors (fixed message, netloc absent, nothing chained), the exact message, the SDK's Azure dot-segment vectors, a check that S3/GCS keep dots literal, and has_unsafe_segment vectors.
  • test_captures_stores.py: AzureBlobStore.get refuses unsafe keys with no client call, keeps ordinary dots, and refuses unsafe containers and prefixes. Prefix slashes are still stripped.
  • test_config_captures.py: the loader error for s3://[SUPERSECRET]/key and az://acct/evals/../SUPERSECRET never contains the secret.

Docs

CHANGELOG ## [Unreleased] → ### Fixed. DOCS.md (captures sync paragraph), llms-full.txt (captures: block) and docs/configuration.md#captures now state the rules.

Verification

make ci: ruff check, ruff format check and mypy --strict are clean. pytest: 3564 passed, 1 skipped, coverage 95.39%. pre-commit run --all-files passes.

Not merged, per the request.

🤖 Generated with Claude Code

…e the prefix

Port evalshift-sdk #20 and #21 to the CLI's copy of the store grammar and
Azure reader.

- parse_store_uri catches urlsplit's own ValueError (two of which quote the
  netloc) and raises "store URI names an invalid bucket or account; accepted
  forms: ..." outside the except, so nothing is chained.
- has_unsafe_segment(): an az:// container or prefix with an empty, "." or
  ".." segment is rejected, and AzureBlobStore refuses such a container or
  prefix at construction and such a key on get. The Azure client resolves
  dot segments in the request URL, even across containers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@babaliauskas
babaliauskas merged commit 1204674 into main Nov 17, 2026
4 checks passed
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