Skip to content

Bug: bundle catalog add persists un-validated catalog URLs (plain HTTP, host-less) and crashes on malformed IPv6 #3366

Description

@marcelsafin

summary

specify bundle catalog add (add_source in src/specify_cli/bundler/commands_impl/catalog_config.py) persists remote catalog URLs into catalogs.yaml without any HTTPS or host validation, and crashes with a raw ValueError traceback on a malformed IPv6 URL.

The other two catalog-URL validation sites enforce this:

add_source is the third copy of this contract and has neither check, so junk enters the persisted config and only fails later at fetch time, far from the command that caused it.

reproduction

from pathlib import Path
import tempfile
from specify_cli.bundler.commands_impl.catalog_config import add_source

d = Path(tempfile.mkdtemp())
add_source(d, "http://evil.example.com/catalog.json", policy="install-allowed", priority=10)  # accepted; plain HTTP, non-localhost
add_source(d, "https://:8080", policy="install-allowed", priority=10)                          # accepted; no host
add_source(d, "https://user@", policy="install-allowed", priority=10)                          # accepted; no host
add_source(d, "https://[::1/c.json", policy="install-allowed", priority=10)                    # raw ValueError: Invalid IPv6 URL

Via the CLI this is specify bundle catalog add <url>; the first three print ✓ Added catalog ... and write the entry to .specify/catalogs.yaml, the fourth escapes the except BundlerError handler in catalog_add and produces a traceback. remove_source hits the same unguarded urlparse through its _canonicalize_url fallback.

impact

proposed fix

Mirror the catalogs.py validation in add_source for http(s) schemes (HTTPS-only with localhost exception, check parsed.hostname not netloc), and wrap the urlparse calls so malformed URLs raise BundlerError. Fully additive; file://, builtin:// and local paths unaffected. I have a patch with tests ready and can open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions