Repository navigation
fix(worktree): clear genuine ACL denials on orphaned worktree cleanup #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: getappz/agentflare
Length of output: 6659
🌐 Web query:
icacls /grant explicit deny ace does not remove deny delete child permission parent delete-child documentation💡 Result:
The behavior you are observing is a documented limitation of the icacls command-line tool, compounded by how NTFS handles specific permission masks and ACE removal. 1. Lack of granular removal: There is no command in icacls to remove a single, specific ACE (such as Deny Delete Child) [1][2]. The /remove command only operates at the SID (User/Group) level [1][3]. Using /remove:d [User] will remove all Deny ACEs for that user, not just the one you intended to target [1][2]. 2. Precedence and Side Effects: When you use /deny, icacls may include additional implicit permissions like Synchronize (S) in the ACE mask [4][5]. Consequently, simply granting a permission does not automatically "remove" the corresponding Deny ACE; the Deny ACE remains in the Access Control List (ACL) [1]. Because Windows processes the DACL in a specific order—typically evaluating explicit Deny ACEs before explicit Grant ACEs—the Deny ACE will continue to take precedence and block the action, even if you subsequently attempt to grant that same permission [6][7]. 3. Recommended Workarounds: - To effectively manage specific permissions without unintended side effects, avoid using /deny if possible. Instead, structure your permissions using Allow ACEs only [6][7]. - If you must remove a specific Deny ACE created by icacls, you may need to use third-party tools (such as SetACL) that provide granular control over ACE manipulation [5]. - If you must continue using native tools, you may have to remove all permissions for the user using /remove:d and then re-apply the desired Grant ACEs to reconstruct the ACL correctly [1][2]. For further technical context, Microsoft has documented that the icacls program manages permission masks (like Delete vs. Delete Child) in ways that can differ from the GUI, sometimes including Synchronize (S) automatically, which can lead to unexpected access blocks (e.g., inability to traverse a folder) [4][5].
Citations:
🌐 Web query:
Microsoft NTFS delete child explicit deny delete permission child file parent directory access check💡 Result:
In the Microsoft NTFS file system, the ability to delete a file or directory is governed by a dual-path authorization mechanism [1][2][3]. A user can successfully delete a child object if they satisfy either of the following conditions: 1. They have the DELETE permission explicitly granted on the child object itself [1][2][3]. 2. They have the DELETE_CHILD (also known as "Delete subfolders and files") permission granted on the parent directory [4][5][3]. If either of these conditions is met, the file system will typically allow the delete operation [1][2][3]. Consequently, if a user has DELETE_CHILD access on a parent directory, this permission effectively overrides a specific "Deny Delete" ACE (Access Control Entry) applied to the child file itself [6][2]. Because the system verifies security descriptors for both the parent and the object to determine if the deletion is authorized, an explicit "Deny" on the object does not necessarily block the operation if the parent's "Allow" (DELETE_CHILD) remains in effect [6]. To effectively prevent a user from deleting a file, you must ensure that both paths are restricted [1][2]. This requires: - Denying the DELETE permission on the child file itself [1][2]. - Denying the DELETE_CHILD permission on the parent directory [1][7]. If only one of these paths is restricted, the other will continue to provide the necessary authorization for the deletion to occur [1][2]. Documentation and technical analysis confirm that this behavior is by design, as the "Delete" operation is fundamentally treated as an action performed on the parent directory container, not solely on the child object itself [8][7].
Citations:
🌐 Web query:
site:learn.microsoft.com delete child permission delete file even if file has deny delete Windows ACL💡 Result:
In Windows, the ability to delete a file is governed by two distinct sets of permissions: those assigned to the file itself (Delete permission) and those assigned to the parent directory (Delete Child permission) [1][2][3]. Because these are independent mechanisms, a user can delete a file if they possess either: 1. Delete permission on the file itself [1][3] 2. Delete Child permission on the parent directory [1][4][3] If a user is explicitly denied "Delete" access on a file, they can still successfully delete that file if they have "Delete Child" permission on the parent directory [4][3]. This occurs because the system evaluates these permissions independently; the "Delete Child" right on the directory grants the user authority over the directory's contents, which bypasses the restrictive ACL placed directly on the file [4][5][3]. To effectively prevent a user from deleting a file, you must ensure that they are denied the necessary permissions at both levels [4][3]: - File level: Explicitly deny "Delete" access [3]. - Directory level: Explicitly deny "Delete Child" (or "Delete subfolders and files") access on the parent directory [4][6][3]. Because "Delete Child" is a powerful privilege that can override file-level protections, it is standard security practice to carefully restrict who holds this permission on directories [4]. Furthermore, because the Windows security system evaluates access based on the first applicable "Deny" or "Allow" rule encountered (based on the Discretionary Access Control List (DACL) order), it is critical that "Deny" entries are properly configured and prioritized [7][8][9]. Note also that users with administrative privileges or those who hold the "Take Ownership" right can modify these permissions to regain access, regardless of existing Deny rules [3].
Citations:
icacls /grantdoesn’t clear a deny ACE.The retry can still fail on a real ACL denial because
/grantleaves the explicit deny in place; clear the deny ACE first or rebuild the ACL before retrying.The test also only denies
Deleteonlocked.txt, which can still allow tree deletion via the parent directory’s delete-child right, so it doesn’t reliably exercise the fallback.📍 Affects 1 file
crates/flare-git-core/src/worktree.rs#L622-L636(this comment)crates/flare-git-core/src/worktree.rs#L709-L724🤖 Prompt for AI Agents