Summary
sigstore-js used substring matching when selecting Docker registry credentials, causing credentials intended for one registry to be sent to another registry with a similar hostname.
If an attacker controls or can influence connections to such a registry, they may receive valid credentials for a different registry, potentially enabling unauthorized access or account takeover.
Affected context
This issue affects applications that:
- Use sigstore-js versions prior to 0.7.1
- Rely on
getRegistryCredentials()to obtain Docker registry authentication - Have multiple registry credentials stored in the Docker config file (e.g.,
config.json) - Interact with registries whose hostnames may be substrings or supersets of each other
The risk is elevated in environments where private registries coexist with public or third-party registries that share partial hostname patterns.
Exploit preconditions
- Attack surface: Outbound connections from applications using sigstore-js to container registries.
- Required access: Ability to:
- Operate or control a registry whose hostname overlaps by substring with a configured registry, or
- Influence application configuration or target registry endpoints to direct traffic to such a hostname.
- Trigger point: When
getRegistryCredentials()is called, it reads the Docker config and picks credentials whose auth key contains the target registry string. - Why exploitation is possible: The selection logic performs a substring match rather than an exact host match, so credentials for one registry may be incorrectly selected and sent to a different registry with a partially matching hostname.
Why this happens
The root cause is a flawed credential selection algorithm that uses substring matching on registry hostnames when reading entries from the Docker configuration.
Instead of enforcing strict, canonical, host-equivalent matching, the implementation checks whether an auth key contains the target registry string, which can misassociate credentials between registries whose hostnames partially overlap.
This maps to CWE-522: Insufficiently Protected Credentials, as credentials are not properly bound to the intended authentication scope and can be disclosed to unintended parties due to weak association logic.
Potential impact
- Leakage of valid Docker registry credentials to an unintended or attacker-controlled registry
- Unauthorized access to private container images or repositories
- Potential modification, deletion, or tampering with images stored in the affected registry
- Lateral movement if the leaked credentials are reused across environments or services
- Compromise of software supply chain via malicious image replacement or poisoning
General mitigation guidance
Defensive measures should focus on correct scoping and handling of credentials and hostname verification:
- Ensure credential lookup uses exact, canonical host matching (including port and scheme where applicable) rather than substring or prefix checks.
- Normalize and validate registry hostnames before performing any lookup, applying consistent rules for trailing slashes, ports, and case sensitivity.
- Restrict the number of registries and credentials stored in shared Docker configuration files, separating highly sensitive registries into distinct contexts where feasible.
- Apply least privilege to registry accounts: limit permissions to read-only where possible and avoid reusing the same credentials across multiple registries or environments.
- Treat outbound connections to registries as sensitive operations, layering network policies, TLS verification, and explicit allowlists for trusted registry hosts.
How teams detect issues like this
Detection can center on code-level review and runtime observation:
- Use static analysis or manual review to flag credential selection logic that:
- Uses substring, prefix, or suffix matching for hostnames
- Compares registry identifiers without normalization or canonicalization
- Enforce code review checklists that explicitly ask how credentials are bound to hosts and whether lookups are exact-match and case-aware.
- Deploy logging around credential retrieval paths, including the requested registry host and the matched config entry, then review for mismatches or unexpected associations.
- Monitor registry access logs for anomalous authentication patterns, such as valid credentials being used from unexpected registries or IP ranges.
- Consider automated security tools that scan dependencies for known credential-handling issues and highlight uses of registry helpers with weak matching logic.

