Skip to content

Security Enforcement for Trusted Registries: Only allow module restore from trusted registries#19395

Open
jiangmingzhe wants to merge 2 commits intoAzure:mainfrom
jiangmingzhe:mingzhejiang/module-restore-guard
Open

Security Enforcement for Trusted Registries: Only allow module restore from trusted registries#19395
jiangmingzhe wants to merge 2 commits intoAzure:mainfrom
jiangmingzhe:mingzhejiang/module-restore-guard

Conversation

@jiangmingzhe
Copy link
Copy Markdown
Member

@jiangmingzhe jiangmingzhe commented Apr 11, 2026

Description: Block credential exfiltration via untrusted OCI registry restore

Problem

Opening an untrusted .bicep file triggers automatic OCI module restore, which sends Azure credentials to any referenced registry — including attacker-controlled ones — via the authenticate challenge. Simply opening a file is sufficient to exfiltrate credentials.

Solution

A registry trust allowlist enforced before any network I/O. Restore is blocked entirely for registries not on the list — no connection, no credential challenge.

Built-in trusted registries (*.azurecr.io, *.azurecr.cn, *.azurecr.us, mcr.microsoft.com, mcr.azure.cn, ghcr.io) are hardcoded. Users extend the list via security.trustedRegistries in bicepconfig.json.

Two new diagnostics: BCP446 (registry not trusted) and BCP447 (invalid pattern in config). Invalid patterns fail closed — all restore blocked until fixed.

Trust is checked against the literal hostname string in the source file. No DNS resolution is performed, preventing DNS rebinding attacks.

Checklist

Microsoft Reviewers: Open in CodeFlow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant