Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 8, 2025

This PR implements a new security rule Azure.ACR.ExportPolicy (AZR-000403) that ensures Azure Container Registry exports are disabled to prevent data exfiltration.

What this rule does

The rule validates that:

  • properties.policies.exportPolicy.status is set to "disabled"
  • properties.publicNetworkAccess is set to "Disabled" (required for export policy)

This prevents data movement via acr import or acr transfer commands, ensuring registry data is accessed solely through the data plane (docker pull).

Changes made

  • Rule implementation: Added Azure.ACR.ExportPolicy rule in Azure.ACR.Rule.ps1
  • Localization: Added error messages in PSRule-rules.psd1
  • Test coverage: Added 3 test scenarios in Azure.ACR.Tests.ps1 and Resources.ACR.json
  • Documentation: Created comprehensive documentation with examples for ARM templates, Bicep, CLI, and PowerShell

Test scenarios

Registry Export Policy Public Access Result Reason
registry-K enabled Enabled ❌ FAIL Export policy enabled
registry-L disabled Enabled ❌ FAIL Public access must be disabled
registry-M disabled Disabled ✅ PASS Correctly configured

References

Fixes #3444.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: pwsh ./build.ps1 -Build (dns block)
    • Triggering command: pwsh -c Install-Module PSRule -Force -Scope CurrentUser (dns block)
    • Triggering command: pwsh -c Install-Module Pester -Force -Scope CurrentUser (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…xports

Co-authored-by: BernieWhite <13513058+BernieWhite@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [RULE] Disable export of artifacts from an Azure container registry Add Azure.ACR.ExportPolicy rule to disable container registry exports Jul 8, 2025
@Copilot Copilot AI requested a review from BernieWhite July 8, 2025 13:52
Copilot finished work on behalf of BernieWhite July 8, 2025 13:52
Co-authored-by: BernieWhite <13513058+BernieWhite@users.noreply.github.com>
@Copilot Copilot AI requested a review from BernieWhite July 9, 2025 02:42
Copilot finished work on behalf of BernieWhite July 9, 2025 02:42
$ruleResult | Should -Not -BeNullOrEmpty;
$ruleResult.Length | Should -Be 2;
$ruleResult.TargetName | Should -BeIn 'registry-K', 'registry-L';
$ruleResult.Detail.Reason.Path | Should -BeIn 'properties.policies.exportPolicy.status', 'properties.publicNetworkAccess';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ruleResult.Detail.Reason.Path | Should -BeIn 'properties.policies.exportPolicy.status', 'properties.publicNetworkAccess';
$ruleResult.Detail.Reason.Path | Should -BeIn 'properties.policies.exportPolicy.status';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated test assertion to only check for export policy path since public network access check was removed. Commit: f3da01b

Comment on lines 95 to 96
az acr update --name MyRegistry --public-network-enabled false
az acr config export-policy update --registry MyRegistry --status disabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of MyRegistry use a placeholder <name>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced "MyRegistry" with "" placeholder in CLI examples. Commit: f3da01b

To deploy registries that pass this rule:

- Set `properties.policies.exportPolicy.status` to `disabled`.
- Set `properties.publicNetworkAccess` to `Disabled`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove setting properties.publicNetworkAccess to Disabled for both Azure template and Bicep examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed publicNetworkAccess settings from both Azure template and Bicep examples. Commit: f3da01b

reviewed: 2025-07-09
severity: Important
pillar: Security
category: DP:02 Data Protection
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
category: DP:02 Data Protection
category: SE:08 Hardening resources

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed category from "DP:02 Data Protection" to "SE:08 Hardening resources". Commit: f3da01b


## LINKS

- [Data loss prevention for Azure Container Registry](https://learn.microsoft.com/en-gb/azure/container-registry/data-loss-prevention)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an additional link first in the list for: [SE:08 Hardening resources](https://learn.microsoft.com/en-us/azure/well-architected/security/harden-resources) which is the reference for the WAF pillar this aligns to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added SE:08 Hardening resources link as the first link in the LINKS section. Commit: f3da01b

### Configure with Azure PowerShell

```powershell
Update-AzContainerRegistry -Name MyRegistry -ResourceGroupName MyResourceGroup -PublicNetworkAccess Disabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use placeholders for name and resource group name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated PowerShell example to use placeholders and corrected to use Azure CLI since PowerShell doesn't have direct export policy support. Commit: f3da01b

Co-authored-by: BernieWhite <13513058+BernieWhite@users.noreply.github.com>
@Copilot Copilot AI requested a review from BernieWhite July 9, 2025 03:57
Copilot finished work on behalf of BernieWhite July 9, 2025 03:57

## LINKS

- [SE:08 Hardening resources](https://learn.microsoft.com/en-us/azure/well-architected/security/harden-resources)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [SE:08 Hardening resources](https://learn.microsoft.com/en-us/azure/well-architected/security/harden-resources)
- [SE:08 Hardening resources](https://learn.microsoft.com/azure/well-architected/security/harden-resources)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed URL format to remove the locale prefix. Commit: febb866


## SYNOPSIS

Disable export of artifacts from Azure container registry to ensure data is accessed solely via the data plane.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In one sentence, update this synopsis to reflect what the problem is instead of what the resolution is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated synopsis to describe the problem (data exfiltration risk) instead of the solution. Commit: febb866

…ution

Co-authored-by: BernieWhite <13513058+BernieWhite@users.noreply.github.com>
@Copilot Copilot AI requested a review from BernieWhite July 9, 2025 06:57
Copilot finished work on behalf of BernieWhite July 9, 2025 06:57
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.

[RULE] Disable export of artifacts from an Azure container registry
2 participants