Skip to content

Code Quality: Introduced IStorageSecurityService #15760

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
merged 3 commits into from
Jul 14, 2024

Conversation

0x5bfa
Copy link
Member

@0x5bfa 0x5bfa commented Jul 4, 2024

Summary

  • Removal of Vanara reference (4 out of 37 files):
    • SecurityViewModel
    • SecurityAdvancedViewModel
    • FileSecurityHelpers (to IStorageSecurityService)
    • AccessControlPrincipal
  • Removal of Utils namespace (9 out of 132 files):
    • Utils/Storage/Security/*
    • Utils/Storage/Helpers/FileSecurityHelpers

Resolved / Related Issues

Steps used to test these changes

  1. Open Files
  2. Go to security and advanced security pages
  3. Confirm no crashes and problems occur
  4. Add a new entry
  5. Delete the entry

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-VanaraRemoval1 branch from a1ccc18 to 3946f99 Compare July 4, 2024 19:58
@0x5bfa 0x5bfa marked this pull request as ready for review July 4, 2024 20:00
@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-VanaraRemoval1 branch from 44fdcd8 to 35161ce Compare July 4, 2024 20:28
@0x5bfa 0x5bfa changed the title Code Quality: Introduced StorageSecurityService Code Quality: Introduced IStorageSecurityService Jul 4, 2024
@0x5bfa 0x5bfa added needs - code review needs - testing Pull request requires testing before being merged labels Jul 4, 2024
@Josh65-2201
Copy link
Member

Compared to 3.5.4, I found

  • Doesn't show principles/users name in both normal and advanced pages when opening properties.
  • Doesn't save principles/users that are added
  • Crashes when changing the owner (Before it shows a UAC for PowerShell admin)

@0x5bfa

This comment was marked as resolved.

@0x5bfa 0x5bfa removed the needs - testing Pull request requires testing before being merged label Jul 8, 2024
@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-VanaraRemoval1 branch from 5c255eb to b159fe4 Compare July 8, 2024 22:13
@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 8, 2024

@Josh65-2201 I fixed everything. Would you mind check on your end as well?

@Josh65-2201
Copy link
Member

I found that it won't save my other local user when added but does add system principles (Administrator and system) but makes them separate entries for the folder I'm applying to and one for subfolders/files. File explorer will include them as one entry.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 8, 2024

You can't add an entry via their name such as '0x5bfa' or 'Josh'? It's weird though I tested.

I'm not sure I get what you meant but merging isn't available for now because it requires additional implementation (this lower layer's Windows API doesn't provide such rich features...)
For the future reference, this is called 'effective access' and ACLUI.DLL which File Explorer shows has this feature with their own implementation checking if the new one can be merged and its target is not inherited one before adding actual one into the DACL.

If you can add/remove an entry and change owner without crash and weird behavior (and try them when you have insufficient permission such as 'Program Files/WindowsApps'), it's enough for this PR.

@Josh65-2201
Copy link
Member

Josh65-2201 commented Jul 8, 2024

I'm using the security principles find now menu to try add a local account but it doesn't save it after clicking save and reopening the properties windows. This works on 3.5.6
image

As for the duplicate entries I found preview only add permission targeting the folder I have selected where now it's adding an entry for sub folders/files too. File Explorer set them all in the same permission but I'd say it fine for now as it better then 3.5.6.

Add/removing entries and changing ownership work with no crash or other things.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 9, 2024

  1. I'll check again
  2. Yeah I tried to make it look alike.

Before:

grfInheritance = INHERIT_FLAGS.NO_INHERITANCE,

After:

isFolder ? ACE_FLAGS.CONTAINER_INHERIT_ACE | ACE_FLAGS.OBJECT_INHERIT_ACE : ACE_FLAGS.NO_INHERITANCE,

Thank you for the testing, it've helped me a lot!

@yaira2
Copy link
Member

yaira2 commented Jul 10, 2024

@Josh65-2201 is your testing complete?

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 10, 2024

They found an issue with adding a new entry via user logon names. I’ll check later but everything else should be fine now.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 10, 2024

All done.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 11, 2024

@Josh65-2201 is it fine for you to review again?

Josh65-2201
Josh65-2201 previously approved these changes Jul 11, 2024
Copy link
Member

@Josh65-2201 Josh65-2201 left a comment

Choose a reason for hiding this comment

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

Working as expected

@yaira2 yaira2 requested a review from hishitetsu July 11, 2024 21:35
yaira2
yaira2 previously approved these changes Jul 11, 2024
@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 11, 2024

Thank you guys!

As a side note for the future reference, I maybe should've used 'Get(Set)SecurityInfo' (File Explorer's dialog ACLUI.dll uses it iirc) but and 'Get(Set)NamedSeucurityInfo' doesn't require a handle of the specified file, which means this function would fail when access denied (not having READ_CONTROL), while CreateFileW to get a handle would fail before GetSecurityInfo.

Copy link
Member

@hishitetsu hishitetsu left a comment

Choose a reason for hiding this comment

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

The Access for the entry I added is "Read and execute" at first, but when I open Advanced permissions again, it is "Special". I think "Special" is correct from the beginning.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 12, 2024

Is it something different from the stable build?

@Josh65-2201
Copy link
Member

It always showing as read and execute for me in Preview and this branch

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 12, 2024

The Access for the entry I added is "Read and execute" at first, but when I open Advanced permissions again, it is "Special". I think "Special" is correct from the beginning.

Please open that entry in File Explorer's dialog and expand permissions list for advanced ones to be shown and send a screenshot of it.

@hishitetsu
Copy link
Member

hishitetsu commented Jul 12, 2024

I added Administrator. (Sorry for Japanese)
スクリーンショット 2024-07-12 105736

The second time I open Advanced permissions, it says Special.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 12, 2024

I mean this window. Make sure to click ‘Show advanced permissions’.

image

@hishitetsu
Copy link
Member

Here it is.
image

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 12, 2024

😩 so this is basically I didn’t include SYNCHRONIZE access mask (?)
It very weird that Josh’s PC shows it Read & execute even after opening again.

@0x5bfa
Copy link
Member Author

0x5bfa commented Jul 12, 2024

@hishitetsu when you have time could you try to change this magic code

0x2000A9 /* READ & EXECUTE */,

to

0x20000000 | 0x80000000 /* GENERIC_EXECUTE and GENERIC_READ */

These generic access masks covers SYNCHRONIZE access mask.


(for me)

  • The permission editor window is included in rshx32.dll as a shell extension.
  • The security property sheet is included in aclui.dll
  • The advanced security window is included in aclui.dll

@hishitetsu
Copy link
Member

@hishitetsu when you have time could you try to change this magic code

It works for me!
image
image

@0x5bfa 0x5bfa dismissed stale reviews from yaira2 and Josh65-2201 via 02a9e0c July 14, 2024 02:15
Copy link
Member

@hishitetsu hishitetsu left a comment

Choose a reason for hiding this comment

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

LGTM

@yaira2 yaira2 merged commit e5ba470 into files-community:main Jul 14, 2024
6 checks passed
@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed needs - code review labels Jul 14, 2024
@0x5bfa 0x5bfa deleted the 5bfa/CQ-VanaraRemoval1 branch July 14, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull requests that are approved and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants