Automation Security – Alle Macro’s Blokkeren

💼 Management Samenvatting

De AutomationSecurity-instelling legt vast dat Office geen enkele macro meer uitvoert, ook niet wanneer een gebruiker probeert de blokkade te omzeilen.

Aanbeveling
IMPLEMENT
Risico zonder
High
Risk Score
8/10
Implementatie
8u (tech: 6u)
Van toepassing op:
Windows

Macro’s blijven een favoriete aanvalsvector voor dreigingsactoren die via phishing berichten of malafide documenten initiële toegang willen verkrijgen; het afdwingen van de waarde “3” (Disable all macros) op elke endpoint sluit dit venster.

PowerShell Modules Vereist
Primary API: Graph
Connection: Connect-MgGraph
Required Modules: Microsoft.Graph.DeviceManagement

Implementatie

Deze control beschrijft hoe je met Microsoft Intune, Configuration Manager, groepsbeleid en het bijbehorende PowerShell-script een uniform beleid uitrolt, valideert en auditeert zodat alle Office-applicaties binnen de Nederlandse Baseline voor Veilige Cloud macro-uitvoer blokkeren en forensisch bewijs leveren.

Dreigingsbeeld en beleidskaders

Macro-aanvallen vormen nog steeds het grootste aandeel in geautomatiseerde phishingcampagnes tegen Nederlandse overheidsorganisaties; elke bijlage die Visual Basic for Applications of XLM-scriptjes bevat, kan ongezien code uitvoeren wanneer de standaardinstelling “Enable all macros” per ongeluk is ingeschakeld. Binnen de Nederlandse Baseline voor Veilige Cloud vereist dit dat AutomationSecurity in de registry op waarde “3” staat. Die waarde zorgt ervoor dat Office geen enkele macro uitvoert, zelfs niet in documenten die vanaf een SharePoint-site of vertrouwde e-maildomeinen worden geopend. Omdat aanvallers steeds vaker gebruikmaken van geavanceerde social-engineering technieken, zoals het meegeven van overtuigende overheidslogo’s en referentiecodes, volstaat gebruikersbewustzijn niet. Een technische blokkade verkleint de aanvalsvector drastisch, voorkomt privilege escalation via malafide COM-objecten en houdt laterale beweging tegen voordat Defender of Sentinel een signaal hoeft te genereren.

Deze control sluit aan op verschillende beleidsdocumenten. De Baseline Informatiebeveiliging Overheid (BIO) hoofdstuk 12 en 16 schrijft voor dat scripting alleen is toegestaan wanneer een vooraf goedgekeurde uitzondering bestaat en audit-trails aantoonbaar zijn. NIS2 artikel 21 eist dat essentiële diensten maatregelen nemen om aanvallen die via kantoortoepassingen verlopen onmiddellijk te blokkeren. Ook de AVG verlangt dat persoonsgegevens niet onverwacht kunnen worden geëxfiltreerd uit Office-documenten; macro’s vormen daar een direct risico op, omdat ze zonder verdere interactie bestanden kunnen versleutelen of naar command-and-controlservers kopiëren. Door automation security centraal te verankeren, toon je richting toezichthouders aan dat het bestuur daadwerkelijk de benodigde organisatorische en technische maatregelen heeft genomen om dit risico te mitigeren.

Naast regelgeving speelt de samenhang met andere controls een grote rol. Deze instelling bouwt voort op modern authenticatie in Microsoft 365, Conditional Access die legacy clients blokkeert en Defender for Office policies die risicovolle bijlagen in quarantaine plaatsen. Toch kan een enkele foutieve lokale wijziging de deur weer openen. Daarom combineer je deze control met Device Health Attestations, Endpoint Privilege Management en een streng wijzigingsproces waarin beheerders wijzigingen aan het Trust Center alleen via change-records mogen indienen. Organisaties die afhankelijk zijn van macro’s, bijvoorbeeld voor archiefkoppelingen of fiscale rapportages, documenteren een gecontroleerde uitzonderingsroute waarbij de macro cryptografisch wordt ondertekend, in een sandbox wordt getest en via Intune App Protection Policies alleen op specifieke, geïsoleerde werkstations wordt toegestaan. Op die manier blijft de standaardconfiguratie zero trust: niets draait automatisch, en elke afwijking is traceerbaar, beperkt in scope en gekoppeld aan aanvullende compensating controls zoals Just-In-Time toegang, netwerkisolatie en near-real-time logging.

De maatregel sluit direct aan op de doelstellingen rond digitale soevereiniteit. Rijkscloudomgevingen bevatten vaak vertrouwelijke beleidsstukken, onderhandelingsstandpunten of persoonsgegevens met hoge beschermingsniveaus. Wanneer die documenten via macro’s kunnen communiceren met externe endpoints, verlies je controle over de dataflow en wordt het onmogelijk om aan de Woo, Archiefwet en AVG-transparantie-eisen te voldoen. Door macro’s standaard uit te schakelen ontstaat een stabiele basis waarop verdere governancecomponenten kunnen steunen: classificatie-labels hoeven niet langer rekening te houden met embedded scripts, Data Loss Prevention hoeft minder uitzonderingen te bevatten en het forensische team weet dat elke macro-uitvoering het resultaat is van een expliciete, gelogde uitzondering. Deze voorspelbaarheid maakt het eenvoudiger om maturity-scores voor de Nederlandse Baseline voor Veilige Cloud te verhogen en om tijdens ketenbrede oefeningen van het NCSC aan te tonen dat Office-documenten niet langer het zwakste schakelpunt vormen.

Implementatie en hardening

Een succesvolle implementatie begint met het uniformiseren van configuratiebronnen. Inventariseer welke Intune Configuration Profiles, Group Policy Objects en lokale scripts momenteel macrobeleid instellen. Consolidatie voorkomt dat verouderde sjablonen waarde “1” (low security) opnieuw pushen. Gebruik vervolgens de Office 2016 ADMX-templates, stel de instelling “Disable all macros without notification” in voor alle Office-applicaties en target de policy op risicovolle gebruikersgroepen zoals finance, beleidsafdelingen en projectorganisaties die vaak documenten van externe leveranciers ontvangen. Binnen Intune configureer je een Settings Catalog-profiel onder Administrative Templates > Microsoft Office 2016 > Security Settings > “Automation Security” en zet je de waarde op “Disable all macros except signed macros”. Om een strikt zero-macro beleid af te dwingen kies je echter voor de optie “Disable all macros” en combineer je deze met Attack Surface Reduction rule “Block all Office applications from creating child processes”, zodat ook fallback-technieken geblokkeerd blijven. Leg deze ontwerpkeuzes vast in solution design-documenten en change-voorstellen zodat toekomstige beheerders exact begrijpen waarom voor deze combinaties is gekozen en welke afhankelijkheden (zoals licenties en Defender-profielen) daarbij horen.

Het PowerShell-script `code/office/office-shared/automation-security-disable-macros.ps1` biedt twee functies: `Invoke-Monitoring` leest de actuele registry-waarde onder `HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security` en vergelijkt die met de gewenste configuratie, terwijl `Invoke-Remediation` de waarde instelt, een logboekitem in het Windows Event Log schrijft en optioneel een Intune remediation script-status terugkoppelt via Graph. Plaats het script binnen een Intune Remediation Package, stel de frequentie op vier uur en maak gebruik van Azure AD Dynamic Groups zodat apparaten met afwijkende status automatisch worden opgenomen. Voeg tijdens het change-proces een rollbackplan toe: exporteer bestaande macro-instellingen, documenteer compatibiliteitstests en plan een communicatiepakket voor functioneel beheerders zodat zij weten hoe uitzonderingen ingediend worden wanneer kritieke processen vastlopen. Betrek hier ook de communicatie- en trainingsteams bij, zodat gebruikers ruim vóór de wijziging begrijpen waarom macro’s worden geblokkeerd en welke alternatieve werkvormen, zoals Power Automate-flows of gescripte imports, beschikbaar komen.

Borg dat uitzonderingen daadwerkelijk uitzonderingen blijven. Richt een “Macro Governance Board” in waarin architectuur, security en proces-eigenaren beslissen over aanvragen. Elke aanvraag bevat een kosten-batenanalyse, een beschrijving van gevoelige gegevens, een verwijzing naar BIO-controles en een plan voor het digitaal ondertekenen van de macro. Organiseer een geautomatiseerde CI/CD-pijplijn op basis van Microsoft Power Platform Build Tools of Azure DevOps waarin macro’s statisch worden geanalyseerd met YARA-regels, gecheckt op verdachte Win32 API-calls en vervolgens ondertekend met een HSM-beheerd certificaat. Alleen wanneer alle controles slagen, wordt de macro gepubliceerd naar een gecontroleerde SharePoint-locatie die via Application Control op allowlist staat. Documenteer ten slotte elke geïmplementeerde policy in het Configuratieregister van de Nederlandse Baseline voor Veilige Cloud met versiebeheer, zodat audits kunnen herleiden wanneer welke waarde is ingesteld. Gebruik daarbij gestandaardiseerde sjablonen voor risicoafweging, autorisatie en evaluatie zodat iedere uitzondering dezelfde stappen doorloopt en beslissingen later transparant kunnen worden toegelicht aan auditors en toezichthouders.

Test alle wijzigingen altijd lokaal voordat ze breed worden uitgerold. Gebruik de debugmodus van het PowerShell-script met de parameter `-WhatIf` om te verifiëren dat geen onvoorziene registry-takken worden aangepast en houd de uitvoeringstijd onder de vijftien seconden zodat Intune remediations binnen het beleid van de organisatie blijven. Log testresultaten in een apart Change Evaluation-rapport met screenshots van de Intune console, hashwaarden van de scripts en bewijs dat de policy correct wordt toegepast op minstens één reguliere werkplek, één beheerderswerkplek en één VDI-sessie. Door deze gecontroleerde aanpak ontstaat vertrouwen bij zowel functioneel beheer als eindgebruikers; zij zien dat macro’s alleen worden geblokkeerd na grondige validatie, inclusief communicatie over impact, fallback-scenario’s en supportkanalen voor het indienen van tickets. Plan na iedere uitrol een korte evaluatie met vertegenwoordigers van de belangrijkste businessdomeinen om gebruikservaringen, incidenten en verbeterpunten te verzamelen en waar nodig in de volgende change-cyclus te verwerken.

Gebruik PowerShell-script automation-security-disable-macros.ps1 (functie Invoke-Remediation) – Gebruik de remediation-functie voor het afdwingen van de registry-waarde AutomationSecurity=3 en log elke wijziging..

Monitoring, auditing en continue verbetering

Monitoring voor deze control draait om drie sporen: configuratiestatus, gebruikersgedrag en dreigingsinformatie. Plan een dagelijkse export van Intune compliance-rapporten naar Microsoft Sentinel of Purview Compliance Manager en corrigeer apparaten die meer dan vier uur afwijken. Combineer dit met Defender for Office rapportages: wanneer een gebruiker toch op “Enable Content” klikt binnen een document dat in Protected View is geopend, moet direct een incidentticket worden aangemaakt. Zet daarom een Logic App of Sentinel Automation Rule klaar die een melding vanuit Defender of Compliance Center verrijkt met apparaatnaam, gebruiker, documentherkomst en de actuele AutomationSecurity-status. Zo kan het Computer Emergency Response Team binnen dertig minuten bepalen of er sprake is van een daadwerkelijke compromise of slechts een uitzonderingsaanvraag die nog niet volledig is afgehandeld.

Auditability is cruciaal. Registreer elke uitvoering van het PowerShell-script in een dedicated event log bron, bij voorkeur `Application and Services Logs\Baseline\OfficeHardening`. Voeg hierin de registry-waarde, gebruiker, timestamp en Intune policy GUID toe. Gebruik vervolgens Microsoft Purview Audit (Premium) om queries te draaien op `Set-IntuneDeviceConfigurationPolicy` en `Update-MgDeviceManagementDeviceConfiguration` zodat auditors kunnen bevestigen dat alleen geautoriseerde beheerders wijzigingen hebben aangebracht. Bewaar de auditbestanden minimaal twaalf maanden om aan BIO 16.01 te voldoen en koppel de logs aan een immutable storage-account met Azure Storage S3 versiebeheer. Maak daarnaast gebruik van Configuration Drift dashboards binnen Azure Monitor om trends zichtbaar te maken: stijgt het aantal uitzonderingen? zijn er specifieke businessunits waar drift vaker optreedt? Deze signalen voeden de kwartaalrapportages richting CISO en CIO.

Continue verbetering vraagt om periodieke testen. Voer elk kwartaal een gecontroleerde phishing-simulatie uit waarbij gebruikers een macrodocument ontvangen; valideer dat het document niet kan draaien en dat Defender de bijlage markeert. Laat ook het Red Team simuleren dat een aanvaller via een legacy OLE-object of COM-registratie probeert macro’s te activeren en bevestig dat Attack Surface Reduction in combinatie met AutomationSecurity de aanval blokkeert. Documenteer lessons learned in het security change register en update het standaard operating procedure-document. Tot slot rapporteer je tijdens de NIS2 management review hoe deze control bijdraagt aan het reduceren van incidentresponse-tijd, welke kostenbesparingen zijn gerealiseerd doordat ransomwareketens vroegtijdig worden gestopt en hoeveel gebruikerssessies zijn geblokkeerd. Zo blijft duidelijk dat het blokkeren van macro’s niet slechts een technische instelling is, maar een strategische maatregel die governance, awareness en forensische betrouwbaarheid versterkt.

Gebruik tenslotte opleidings- en communicatieprogramma’s om de maatregel te verankeren. Werk met korte leerblokken waarin functioneel beheerders leren hoe zij macro’s kunnen herschrijven naar goedgekeurde alternatieven zoals Power Automate of Azure Functions, en koppel elk trainingsmoment aan praktijkcases uit Nederlandse overheidsorganisaties. Publiceer maandelijks een “macro hygiene” dashboard dat aangeeft hoeveel documenten door Defender zijn geblokkeerd, hoeveel uitzonderingen actief zijn en welke businessunits exemplary gedrag vertonen. Deze transparantie verhoogt de accountability bij directies en maakt het eenvoudiger om budget vrij te spelen voor aanvullende automatisering, bijvoorbeeld het gebruik van GitOps om alle Office-security instellingen als code te beheren. Wanneer gebruikers en bestuurders begrijpen dat macroblokkades directe bijdragen leveren aan continuïteit, reputatiebescherming en naleving van BIO, NIS2 en AVG, neemt de bereidheid toe om strikt te blijven en worden shadow IT pogingen vroegtijdig gesignaleerd.

Gebruik PowerShell-script automation-security-disable-macros.ps1 (functie Invoke-Monitoring) – Integreer de monitoringfunctie in Intune remediation packages en stuur resultaten door naar Sentinel dashboards..

Compliance & Frameworks

Automation

Gebruik het onderstaande PowerShell script om deze security control te monitoren en te implementeren. Het script bevat functies voor zowel monitoring (-Monitoring) als remediation (-Remediation).

PowerShell
# Control: O365-CO-000006 - Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level #Requires -Version 5.1 # DISA STIG Microsoft Office 365 ProPlus v3r3 param( [string]$RegistryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security", [switch]$Monitoring, [switch]$Remediation, [switch]$Revert, [switch]$WhatIf ) # Function for monitoring the control function Invoke-Monitoring { Write-Host "Monitoring O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Green try { $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default # Check if registry path exists if (-not (Test-Path $RegistryPath)) { Write-Host "✗ Registry path does not exist: $RegistryPath" -ForegroundColor Red return $false } # Check the current value $currentValue = Get-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue if ($currentValue -and $currentValue.$valueName -eq $expectedValue) { Write-Host "✓ Control compliant: AutomationSecurity = $expectedValue (Disable macros by default)" -ForegroundColor Green return $true } else { $actualValue = if ($currentValue) { $currentValue.$valueName } else { "Not Set" } Write-Host "✗ Control non-compliant: AutomationSecurity = $actualValue (Expected: $expectedValue - Disable macros by default)" -ForegroundColor Red return $false } } catch { Write-Host "✗ Error checking registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Function for remediation function Invoke-Remediation { Write-Host "Remediating O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Yellow try { # Check if registry path exists, create if not if (-not (Test-Path $RegistryPath)) { Write-Host "Creating registry path: $RegistryPath" -ForegroundColor Yellow New-Item -Path $RegistryPath -Force | Out-Null } # Set the registry value to disable macros by default for automation $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default Set-ItemProperty -Path $RegistryPath -Name $valueName -Value $expectedValue -Type DWord -Force Write-Host "✓ Registry value set successfully: $valueName = $expectedValue (Disable macros by default)" -ForegroundColor Green # Verify the setting Start-Sleep -Seconds 1 $complianceResult = Invoke-Monitoring return $complianceResult } catch { Write-Host "✗ Error configuring registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Main execution function Invoke-Revert { Write-Host "Reverting O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level " -ForegroundColor Yellow try { if ($WhatIf) { Write-Host " [WhatIf] Would remove registry value" -ForegroundColor Cyan return $true } $valueName = "AutomationSecurity" if (Test-Path $RegistryPath) { Remove-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue Write-Host " Removed registry value: $valueName" -ForegroundColor Green } return $true } catch { Write-Host " Error during revert: # Control: O365-CO-000006 - Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level #Requires -Version 5.1 # DISA STIG Microsoft Office 365 ProPlus v3r3 param( [string]$RegistryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security", [switch]$Monitoring, [switch]$Remediation, [switch]$Revert, [switch]$WhatIf ) # Function for monitoring the control function Invoke-Monitoring { Write-Host "Monitoring O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Green try { $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default # Check if registry path exists if (-not (Test-Path $RegistryPath)) { Write-Host "✗ Registry path does not exist: $RegistryPath" -ForegroundColor Red return $false } # Check the current value $currentValue = Get-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue if ($currentValue -and $currentValue.$valueName -eq $expectedValue) { Write-Host "✓ Control compliant: AutomationSecurity = $expectedValue (Disable macros by default)" -ForegroundColor Green return $true } else { $actualValue = if ($currentValue) { $currentValue.$valueName } else { "Not Set" } Write-Host "✗ Control non-compliant: AutomationSecurity = $actualValue (Expected: $expectedValue - Disable macros by default)" -ForegroundColor Red return $false } } catch { Write-Host "✗ Error checking registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Function for remediation function Invoke-Remediation { Write-Host "Remediating O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Yellow try { # Check if registry path exists, create if not if (-not (Test-Path $RegistryPath)) { Write-Host "Creating registry path: $RegistryPath" -ForegroundColor Yellow New-Item -Path $RegistryPath -Force | Out-Null } # Set the registry value to disable macros by default for automation $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default Set-ItemProperty -Path $RegistryPath -Name $valueName -Value $expectedValue -Type DWord -Force Write-Host "✓ Registry value set successfully: $valueName = $expectedValue (Disable macros by default)" -ForegroundColor Green # Verify the setting Start-Sleep -Seconds 1 $complianceResult = Invoke-Monitoring return $complianceResult } catch { Write-Host "✗ Error configuring registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Main execution if ($Monitoring) { $result = Invoke-Monitoring exit $(if ($result) { 0 } else { 1 }) } elseif ($Remediation) { $result = Invoke-Remediation exit $(if ($result) { 0 } else { 1 }) } elseif ($Revert) { $result = Invoke-Revert exit $(if ($result) { 0 } else { 1 }) } else { Write-Host "Usage: [-Monitoring] [-Remediation] [-Revert] [-WhatIf]" -ForegroundColor Yellow } } catch { Write-Host "Script execution error: # Control: O365-CO-000006 - Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level #Requires -Version 5.1 # DISA STIG Microsoft Office 365 ProPlus v3r3 param( [string]$RegistryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security", [switch]$Monitoring, [switch]$Remediation, [switch]$Revert, [switch]$WhatIf ) # Function for monitoring the control function Invoke-Monitoring { Write-Host "Monitoring O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Green try { $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default # Check if registry path exists if (-not (Test-Path $RegistryPath)) { Write-Host "✗ Registry path does not exist: $RegistryPath" -ForegroundColor Red return $false } # Check the current value $currentValue = Get-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue if ($currentValue -and $currentValue.$valueName -eq $expectedValue) { Write-Host "✓ Control compliant: AutomationSecurity = $expectedValue (Disable macros by default)" -ForegroundColor Green return $true } else { $actualValue = if ($currentValue) { $currentValue.$valueName } else { "Not Set" } Write-Host "✗ Control non-compliant: AutomationSecurity = $actualValue (Expected: $expectedValue - Disable macros by default)" -ForegroundColor Red return $false } } catch { Write-Host "✗ Error checking registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Function for remediation function Invoke-Remediation { Write-Host "Remediating O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Yellow try { # Check if registry path exists, create if not if (-not (Test-Path $RegistryPath)) { Write-Host "Creating registry path: $RegistryPath" -ForegroundColor Yellow New-Item -Path $RegistryPath -Force | Out-Null } # Set the registry value to disable macros by default for automation $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default Set-ItemProperty -Path $RegistryPath -Name $valueName -Value $expectedValue -Type DWord -Force Write-Host "✓ Registry value set successfully: $valueName = $expectedValue (Disable macros by default)" -ForegroundColor Green # Verify the setting Start-Sleep -Seconds 1 $complianceResult = Invoke-Monitoring return $complianceResult } catch { Write-Host "✗ Error configuring registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Main execution function Invoke-Revert { Write-Host "Reverting O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level " -ForegroundColor Yellow try { if ($WhatIf) { Write-Host " [WhatIf] Would remove registry value" -ForegroundColor Cyan return $true } $valueName = "AutomationSecurity" if (Test-Path $RegistryPath) { Remove-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue Write-Host " Removed registry value: $valueName" -ForegroundColor Green } return $true } catch { Write-Host " Error during revert: # Control: O365-CO-000006 - Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level #Requires -Version 5.1 # DISA STIG Microsoft Office 365 ProPlus v3r3 param( [string]$RegistryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security", [switch]$Monitoring, [switch]$Remediation, [switch]$Revert, [switch]$WhatIf ) # Function for monitoring the control function Invoke-Monitoring { Write-Host "Monitoring O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Green try { $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default # Check if registry path exists if (-not (Test-Path $RegistryPath)) { Write-Host "✗ Registry path does not exist: $RegistryPath" -ForegroundColor Red return $false } # Check the current value $currentValue = Get-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue if ($currentValue -and $currentValue.$valueName -eq $expectedValue) { Write-Host "✓ Control compliant: AutomationSecurity = $expectedValue (Disable macros by default)" -ForegroundColor Green return $true } else { $actualValue = if ($currentValue) { $currentValue.$valueName } else { "Not Set" } Write-Host "✗ Control non-compliant: AutomationSecurity = $actualValue (Expected: $expectedValue - Disable macros by default)" -ForegroundColor Red return $false } } catch { Write-Host "✗ Error checking registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Function for remediation function Invoke-Remediation { Write-Host "Remediating O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Yellow try { # Check if registry path exists, create if not if (-not (Test-Path $RegistryPath)) { Write-Host "Creating registry path: $RegistryPath" -ForegroundColor Yellow New-Item -Path $RegistryPath -Force | Out-Null } # Set the registry value to disable macros by default for automation $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default Set-ItemProperty -Path $RegistryPath -Name $valueName -Value $expectedValue -Type DWord -Force Write-Host "✓ Registry value set successfully: $valueName = $expectedValue (Disable macros by default)" -ForegroundColor Green # Verify the setting Start-Sleep -Seconds 1 $complianceResult = Invoke-Monitoring return $complianceResult } catch { Write-Host "✗ Error configuring registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Main execution if ($Monitoring) { $result = Invoke-Monitoring exit $(if ($result) { 0 } else { 1 }) } elseif ($Remediation) { $result = Invoke-Remediation exit $(if ($result) { 0 } else { 1 }) } else { Write-Host "Usage: .\automation-security-disable-macros.ps1 [-Monitoring] [-Remediation]" -ForegroundColor Yellow Write-Host " -Monitoring: Check current compliance status" -ForegroundColor White Write-Host " -Remediation: Apply recommended configuration" -ForegroundColor White Write-Host "" Write-Host "Manual configuration:" -ForegroundColor Cyan Write-Host "Group Policy: User Configuration > Administrative Templates > Microsoft Office 2016" -ForegroundColor White Write-Host "> Application Settings > Security Settings" -ForegroundColor White Write-Host "> Automation Security: Enabled, Value = 3 (Disable macros by default)" -ForegroundColor White }" -ForegroundColor Red return $false } } # Main execution try { if ($Monitoring) { $result = Invoke-Monitoring exit $(if ($result) { 0 } else { 1 }) } elseif ($Remediation) { $result = Invoke-Remediation exit $(if ($result) { 0 } else { 1 }) } else { Write-Host "Usage: .\automation-security-disable-macros.ps1 [-Monitoring] [-Remediation]" -ForegroundColor Yellow Write-Host " -Monitoring: Check current compliance status" -ForegroundColor White Write-Host " -Remediation: Apply recommended configuration" -ForegroundColor White Write-Host "" Write-Host "Manual configuration:" -ForegroundColor Cyan Write-Host "Group Policy: User Configuration > Administrative Templates > Microsoft Office 2016" -ForegroundColor White Write-Host "> Application Settings > Security Settings" -ForegroundColor White Write-Host "> Automation Security: Enabled, Value = 3 (Disable macros by default)" -ForegroundColor White }" -ForegroundColor Red exit 1 }" -ForegroundColor Red return $false } } # Main execution try { if ($Monitoring) { $result = Invoke-Monitoring exit $(if ($result) { 0 } else { 1 }) } elseif ($Remediation) { $result = Invoke-Remediation exit $(if ($result) { 0 } else { 1 }) } elseif ($Revert) { $result = Invoke-Revert exit $(if ($result) { 0 } else { 1 }) } else { Write-Host "Usage: [-Monitoring] [-Remediation] [-Revert] [-WhatIf]" -ForegroundColor Yellow } } catch { Write-Host "Script execution error: # Control: O365-CO-000006 - Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level #Requires -Version 5.1 # DISA STIG Microsoft Office 365 ProPlus v3r3 param( [string]$RegistryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security", [switch]$Monitoring, [switch]$Remediation, [switch]$Revert, [switch]$WhatIf ) # Function for monitoring the control function Invoke-Monitoring { Write-Host "Monitoring O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Green try { $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default # Check if registry path exists if (-not (Test-Path $RegistryPath)) { Write-Host "✗ Registry path does not exist: $RegistryPath" -ForegroundColor Red return $false } # Check the current value $currentValue = Get-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue if ($currentValue -and $currentValue.$valueName -eq $expectedValue) { Write-Host "✓ Control compliant: AutomationSecurity = $expectedValue (Disable macros by default)" -ForegroundColor Green return $true } else { $actualValue = if ($currentValue) { $currentValue.$valueName } else { "Not Set" } Write-Host "✗ Control non-compliant: AutomationSecurity = $actualValue (Expected: $expectedValue - Disable macros by default)" -ForegroundColor Red return $false } } catch { Write-Host "✗ Error checking registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Function for remediation function Invoke-Remediation { Write-Host "Remediating O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Yellow try { # Check if registry path exists, create if not if (-not (Test-Path $RegistryPath)) { Write-Host "Creating registry path: $RegistryPath" -ForegroundColor Yellow New-Item -Path $RegistryPath -Force | Out-Null } # Set the registry value to disable macros by default for automation $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default Set-ItemProperty -Path $RegistryPath -Name $valueName -Value $expectedValue -Type DWord -Force Write-Host "✓ Registry value set successfully: $valueName = $expectedValue (Disable macros by default)" -ForegroundColor Green # Verify the setting Start-Sleep -Seconds 1 $complianceResult = Invoke-Monitoring return $complianceResult } catch { Write-Host "✗ Error configuring registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Main execution function Invoke-Revert { Write-Host "Reverting O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level " -ForegroundColor Yellow try { if ($WhatIf) { Write-Host " [WhatIf] Would remove registry value" -ForegroundColor Cyan return $true } $valueName = "AutomationSecurity" if (Test-Path $RegistryPath) { Remove-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue Write-Host " Removed registry value: $valueName" -ForegroundColor Green } return $true } catch { Write-Host " Error during revert: # Control: O365-CO-000006 - Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level #Requires -Version 5.1 # DISA STIG Microsoft Office 365 ProPlus v3r3 param( [string]$RegistryPath = "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Security", [switch]$Monitoring, [switch]$Remediation, [switch]$Revert, [switch]$WhatIf ) # Function for monitoring the control function Invoke-Monitoring { Write-Host "Monitoring O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Green try { $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default # Check if registry path exists if (-not (Test-Path $RegistryPath)) { Write-Host "✗ Registry path does not exist: $RegistryPath" -ForegroundColor Red return $false } # Check the current value $currentValue = Get-ItemProperty -Path $RegistryPath -Name $valueName -ErrorAction SilentlyContinue if ($currentValue -and $currentValue.$valueName -eq $expectedValue) { Write-Host "✓ Control compliant: AutomationSecurity = $expectedValue (Disable macros by default)" -ForegroundColor Green return $true } else { $actualValue = if ($currentValue) { $currentValue.$valueName } else { "Not Set" } Write-Host "✗ Control non-compliant: AutomationSecurity = $actualValue (Expected: $expectedValue - Disable macros by default)" -ForegroundColor Red return $false } } catch { Write-Host "✗ Error checking registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Function for remediation function Invoke-Remediation { Write-Host "Remediating O365-CO-000006: Macros in all Office applications that are opened programmatically by another application must be opened based upon macro security level" -ForegroundColor Yellow try { # Check if registry path exists, create if not if (-not (Test-Path $RegistryPath)) { Write-Host "Creating registry path: $RegistryPath" -ForegroundColor Yellow New-Item -Path $RegistryPath -Force | Out-Null } # Set the registry value to disable macros by default for automation $valueName = "AutomationSecurity" $expectedValue = 3 # 3 = Disable macros by default Set-ItemProperty -Path $RegistryPath -Name $valueName -Value $expectedValue -Type DWord -Force Write-Host "✓ Registry value set successfully: $valueName = $expectedValue (Disable macros by default)" -ForegroundColor Green # Verify the setting Start-Sleep -Seconds 1 $complianceResult = Invoke-Monitoring return $complianceResult } catch { Write-Host "✗ Error configuring registry setting: $($_.Exception.Message)" -ForegroundColor Red return $false } } # Main execution if ($Monitoring) { $result = Invoke-Monitoring exit $(if ($result) { 0 } else { 1 }) } elseif ($Remediation) { $result = Invoke-Remediation exit $(if ($result) { 0 } else { 1 }) } else { Write-Host "Usage: .\automation-security-disable-macros.ps1 [-Monitoring] [-Remediation]" -ForegroundColor Yellow Write-Host " -Monitoring: Check current compliance status" -ForegroundColor White Write-Host " -Remediation: Apply recommended configuration" -ForegroundColor White Write-Host "" Write-Host "Manual configuration:" -ForegroundColor Cyan Write-Host "Group Policy: User Configuration > Administrative Templates > Microsoft Office 2016" -ForegroundColor White Write-Host "> Application Settings > Security Settings" -ForegroundColor White Write-Host "> Automation Security: Enabled, Value = 3 (Disable macros by default)" -ForegroundColor White }" -ForegroundColor Red return $false } } # Main execution try { if ($Monitoring) { $result = Invoke-Monitoring exit $(if ($result) { 0 } else { 1 }) } elseif ($Remediation) { $result = Invoke-Remediation exit $(if ($result) { 0 } else { 1 }) } else { Write-Host "Usage: .\automation-security-disable-macros.ps1 [-Monitoring] [-Remediation]" -ForegroundColor Yellow Write-Host " -Monitoring: Check current compliance status" -ForegroundColor White Write-Host " -Remediation: Apply recommended configuration" -ForegroundColor White Write-Host "" Write-Host "Manual configuration:" -ForegroundColor Cyan Write-Host "Group Policy: User Configuration > Administrative Templates > Microsoft Office 2016" -ForegroundColor White Write-Host "> Application Settings > Security Settings" -ForegroundColor White Write-Host "> Automation Security: Enabled, Value = 3 (Disable macros by default)" -ForegroundColor White }" -ForegroundColor Red exit 1 }

Risico zonder implementatie

Risico zonder implementatie
High: Macro-malware kan zich ongehinderd nestelen in overheidsnetwerken en data exfiltreren voordat detectievoorzieningen reageren.

Management Samenvatting

Forceer AutomationSecurity=3, beheer uitzonderingen strikt en leg elk bewijs vast binnen Intune, Sentinel en Purview.