How to give precedence to OpenFilePath=

Discussion in 'Sandboxie (SBIE Open Source) Plus & Classic' started by Mr.X, Oct 22, 2022.

  1. Mr.X

    Mr.X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    5,258
    Location:
    .
    I have
    ClosedFilePath=D:\Desktop\SecureFolder\
    under
    [GlobalSettings]

    Setting
    OpenFilePath=D:\Desktop\SecureFolder\
    or
    ClosedFilePathDisabled=D:\Desktop\SecureFolder\
    to a specific box does not work

    I need precedence on certain cases...
     
    Last edited: Oct 23, 2022
  2. simbun

    simbun Registered Member

    Joined:
    Jan 29, 2022
    Posts:
    71
    Location:
    United Kingdom
    I asked a similar question recently here; I haven't replied yet as for my use case I can live with what it allows so I don't want to ask for additional development, but it's more limited that I initially thought.

    Firstly, are you in a security hardened sandbox, or do you have 'Prioritize rules based on their Specificity ...' ticked under Resource Access > Access Policies? These are supporter exclusive features I believe.

    It's my understanding (from the aforementioned post) that 'process match level' doesn't really do anything as it only operates on the same Property i.e. "OpenFilePath=notepad.exe,D:\downloads" can only override another OpenFilePath rule...which I think means it doesn't override anything.
    So you're left with rule specificity (the length of the match), which in your case should work if you change your definitions to:
    Code:
    ClosedFilePath=D:\Desktop\SecureFolder
    OpenFilePath=D:\Desktop\SecureFolder\
    
    Basically, the OpenFilePath is a better match because it also matches the \ (more characters matching than the ClosedFilePath). It's a little awkward, but it works.

    The only exception to this is that it doesn't work at the root level for some reason e.g. D:\
     
  3. DavidXanatos

    DavidXanatos Developer

    Joined:
    Sep 6, 2006
    Posts:
    2,524
    Location:
    Viena
    The reason is that DOS paths like C:\ or C: are not used instead they are translated to NT paths like \Device\HarddiskVolume4\ and to open it you need the \ at the end so \Device\HarddiskVolume4\ is C:\ as directory while \Device\HarddiskVolume4 is the volume as a block device i.e. you can write to any offset on the partition.
    So internally C:\ and C: evaluate to the same path which is subsequently used.

    You could however use NT paths in the rules and then the specificity should work.
     
  4. simbun

    simbun Registered Member

    Joined:
    Jan 29, 2022
    Posts:
    71
    Location:
    United Kingdom
    If I don't add the final \ to the global ClosedFilePath then the volume is open. If I add the final \ then it's closed but we're back to the same problem as before.

    My use case is that I just want to be able to open and modify a single file nested below the root, so whilst I currently can't browse to it I can type the full path, so it's not a major problem.

    I was hoping to be able to:

    Global
    ClosedFilePath=E:\
    Local
    WriteFilePath=E:\
    OpenFilePath=E:\documents\..\..\somefile.txt

    With the WriteFilePath giving me the ability to traverse the directories without giving read access to the folders contents. This partially works with non root folders until I get to somefile.txt as it's presented as a folder and if I try and open it I get the message "The directory name is invalid".
     
  5. Mr.X

    Mr.X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    5,258
    Location:
    .
    Yes I am in it and such policy checkbox is ticked. I have a certificate, yes.

    This worked out
    Code:
    ClosedFilePath=D:\Desktop\SecureFolder
    OpenFilePath=D:\Desktop\SecureFolder\
    
    Thank you.
     
  6. soccerfan

    soccerfan Registered Member

    Joined:
    Oct 15, 2007
    Posts:
    585
    Slightly OT maybe. @Mr.X : Your first post has the setting "ClosedFilePathDisabled"
    which I have not seen before. Care to share a link to its description and usage?
    Or, perhaps @DavidXanatos can enlighten us :)
     
  7. Mr.X

    Mr.X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    5,258
    Location:
    .
    It does not exist. It is a n00bish intent to fix my issue, that's it. :argh:
    I'm not well acquainted with all Access Policies and syntax, etc.
     
  8. soccerfan

    soccerfan Registered Member

    Joined:
    Oct 15, 2007
    Posts:
    585
    Oh, OK. I thought I had struck gold ;)
     
  9. simbun

    simbun Registered Member

    Joined:
    Jan 29, 2022
    Posts:
    71
    Location:
    United Kingdom
    If you define a ClosedFilePath rule in the Resource Access tab, and then uncheck it (on the left), it's stored in the ini as ClosedFilePathDisabled. I guess it's a way to keep the definition without it being in effect.
     
  10. soccerfan

    soccerfan Registered Member

    Joined:
    Oct 15, 2007
    Posts:
    585
    Thanks! I was not aware of this at all (n00b that I am).
    I tried creating a ReadFilePath and then unchecking it.
    It indeed shows as ReadFileDisabled in sandboxie.ini :)
     
  11. DavidXanatos

    DavidXanatos Developer

    Joined:
    Sep 6, 2006
    Posts:
    2,524
    Location:
    Viena
    Yes its just a dummy to lot loose it, the cor components are obliviosue to any ...Disabled entries they have no function
     
  12. Mr.X

    Mr.X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    5,258
    Location:
    .
    :argh: this is a * disastrous mess, to me.
    Edit: I am laughing at me and my poor IQ to understand quickly and timely.
    I am not mocking or despising @DavidXanatos work whatsoever.
    I let this clear cause I don't want this comment to be censored.
     
    Last edited: Oct 23, 2022
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.