Repository navigation
Restrict the CodeDeploy on-premises config file on Windows - #10891
Open
nathan-inge wants to merge 1 commit into
Open
nathan-inge wants to merge 1 commit into
nathan-inge wants to merge 1 commit into
Conversation
luigi617
approved these changes
Nov 12, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
On Windows,
aws deploy installwrites the on-premises instance configuration file toC:\ProgramData\Amazon\CodeDeploy\conf.onpremises.yml. The0o600mode used when the file is written only applies on POSIX: on Windows,os.openandos.chmoddon't set ACLs, so the file inherits its ACL from its directory.This change creates the file on Windows with its own access control list, so its permissions don't depend on the directory:
Windows.create_config_file(), which creates the file withCreateFileW(CREATE_NEW)and a security descriptor with a protected DACL (D:P(A;;FA;;;SY)(A;;FA;;;BA)), granting full control only to LocalSystem and Administrators. Nothing is inherited from the directory.--config-fileis the installed path; the contents are read first.CREATE_NEWfails if the file reappears between the delete and the create. If the file can't be replaced (for example, another process has it open) or created,installstops with a clear error before writing the config.os.chmodis skipped for it, since on Windows it only toggles the read-only attribute.ctypes.Linux behavior is unchanged.
Behavior changes
--override-configand--config-fileset to the installed path, Windows now rewrites the file (same contents) instead of leaving it untouched.Testing
installstopping if the file can't be replaced.TestInstallConfigFileWindowsAcl, run in an elevated session) read the DACL back withGetNamedSecurityInfoWand check that it is protected and only contains SYSTEM and Administrators, for a new file, an existing file with an explicitEveryoneentry, and that file passed as--config-file.tests/unit/customizations/codedeployandscripts/ci/run-testson Windows Server 2022, andtests/unit/customizations/codedeployon Windows Server 2016 (Python 3.12, elevated). All passed, including the new Windows tests.aws deploy installend to end on both versions and checked the resulting file ACL withicacls, including after the agent MSI was installed and the agent service started. The agent reads the file.ruff checkandruff format --checkare clean on the changed files.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.