DSC File resource lacks explicit permission boundary for remote file system access
0 reputation · 02 Feb 2022, 23:46 UTC
0 reputation · 02 Feb 2022, 23:46 UTC
PowerShell Desired State Configuration provisions repeatable developer workstations, and the File resource routinely writes configuration files to local or remote targets through UNC paths or CIM sessions. The goal is to restrict those file operations to a least-privilege boundary without relying entirely on operating-system ACLs or custom wrapper scripts.
The uncertainty is that the DSC engine does not impose an explicit permission boundary on the File resource. It runs under the Local System account or whatever credentials the engine receives, and neither Constrained Language Mode nor JEA endpoint restrictions are automatically applied to the underlying file system calls. This leaves an unresolved design question about whether DSC should enforce JEA-style constraints natively or require explicit delegation credentials, with behavior that can vary between PowerShell versions and deployment scenarios.
Which explicit permission boundary should administrators configure for the DSC File resource when targeting remote paths, and does the DSC engine apply any built-in sandbox or Constrained Language Mode limits to file system operations in current supported PowerShell releases?
Use the File resource's Credential property to execute remote writes under a dedicated least-privilege identity, and enforce the final boundary with NTFS and share ACLs on the target. In supported Windows PowerShell 5.1 and PowerShell 7+ DSC scenarios, the engine does not apply a built-in sandbox, Constrained Language Mode, or JEA restriction to file system calls. It runs under the identity of the DSC service or the session that invokes Start-DscConfiguration.
Confirmed behavior: The File resource performs I/O using the access token of the process hosting the DSC engine. By default this is often the LocalSystem account for the DSC service, or the interactive user during a push configuration. DSC does not insert a permission layer between the resource and the file system.
Likely explanation: Administrators sometimes expect Constrained Language Mode or JEA to constrain the File resource. CLM restricts PowerShell language features and cmdlet availability, not underlying Win32 or .NET file I/O. JEA limits which commands a connected user may invoke, but it does not automatically wrap DSC's internal provider operations unless the entire DSC execution is hosted inside a JEA endpoint. This is consistent across supported releases, though exact service-account defaults can vary by deployment method (push, pull, or cloud-hosted LCM).
Credential:File RemoteConfig {
Ensure = 'Present'
Type = 'File'
SourcePath = '\\src\share\app.conf'
DestinationPath = '\\tgt\share\app.conf'
Credential = $Cred
}Get-CimInstance Win32_Service -Filter "Name='dsm'" | Select-Object Name, StartName.Test-Path \\tgt\share\app.conf.$ExecutionContext.SessionState.LanguageMode. Expect FullLanguage unless CLM is explicitly enabled.Start-DscConfiguration, review DSC operational event logs for permission failures.One missing diagnostic detail would change the recommendation: is the DSC service currently running as LocalSystem? If so, the boundary must also be moved to the service account; otherwise the resource-level Credential is the primary control.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.