Skip to content

File resource access behavior of 'NormalFilePath' is not as expected #5001

@SOLEADO20

Description

@SOLEADO20

Describe what you noticed and did

Issue description

The file resource access behavior of Sandboxie-Plus (v1.16.3) is inconsistent with expectations.

This primarily concerns access issues with folders configured as NormalFilePath , specifically:

  • For a folder configured as NormalFilePath , if its parent folder is ClosedFilePath , the sandbox program is unable to access it.

  • For a folder configured as NormalFilePath , if its parent folder is WriteFilePath , the sandbox program can only read files within the sandbox; if its parent folder is OpenFilePath or OpenPipePath , the sandbox program can only read files outside the sandbox.

    • This also raises another problem: for folders configured as NormalFilePath whose parent folder is OpenFilePath or OpenPipePath, the sandbox program can write files to them normally and get feedback that the write is successful, but these files can no longer be read or deleted.

According to the documentation of NormalFilePath, it allows to restore default sandboxing behaviour for paths whose parents have been configured as Open, WriteOnly, or even Closed. Therefore, I believe the above behavior is abnormal and does not match expectations.

Example steps

  • Execute the following commands on the host to create a series of identical folder structures for both outside and inside the sandbox, and create identifier files.

    01_[Host]_Init-files.bat :

    @REM Specifying test folder
    set "OUTER_FOLDER=C:\test"
    set "INNER_FOLDER=C:\Sandbox\%USERNAME%\DefaultBox\drive\C\test"
    
    @REM Initialize the test files (folders) outside the sandbox
    mkdir "%OUTER_FOLDER%\Closed\Normal"
    mkdir "%OUTER_FOLDER%\Write\Normal"
    mkdir "%OUTER_FOLDER%\Open\Normal"
    mkdir "%OUTER_FOLDER%\OpenPipe\Normal"
    type nul > "%OUTER_FOLDER%\Closed\Normal\outer.txt"
    type nul > "%OUTER_FOLDER%\Write\Normal\outer.txt"
    type nul > "%OUTER_FOLDER%\Open\Normal\outer.txt"
    type nul > "%OUTER_FOLDER%\OpenPipe\Normal\outer.txt"
    
    @REM Initialize the test files (folders) inside the sandbox
    mkdir "%INNER_FOLDER%\Closed\Normal"
    mkdir "%INNER_FOLDER%\Write\Normal"
    mkdir "%INNER_FOLDER%\Open\Normal"
    mkdir "%INNER_FOLDER%\OpenPipe\Normal"
    type nul > "%INNER_FOLDER%\Closed\Normal\inner.txt"
    type nul > "%INNER_FOLDER%\Write\Normal\inner.txt"
    type nul > "%INNER_FOLDER%\Open\Normal\inner.txt"
    type nul > "%INNER_FOLDER%\OpenPipe\Normal\inner.txt"
    
    @REM Wait for a keypress and exit
    pause
    exit
    
  • Apply the following configuration to the sandbox to apply the relevant file resource access configuration.

    ClosedFilePath=C:\test\Closed\*
    WriteFilePath=C:\test\Write\*
    OpenFilePath=C:\test\Open\*
    OpenPipePath=C:\test\OpenPipe\*
    
    NormalFilePath=C:\test\Closed\Normal\*
    NormalFilePath=C:\test\Write\Normal\*
    NormalFilePath=C:\test\Open\Normal\*
    NormalFilePath=C:\test\OpenPipe\Normal\*
    
  • Execute the following command inside the sandbox to attempt to traverse these folders within the sandbox.

    02_[Sandboxie]_List-files.bat :

    @REM Specifying test folder
    set "TEST_FOLDER=C:\test"
    
    @REM Expected: outer.txt, inner.txt; Actual: File not found
    dir "%TEST_FOLDER%\Closed\Normal\" /b
    @REM Expected: outer.txt, inner.txt; Actual: inner.txt
    dir "%TEST_FOLDER%\Write\Normal\" /b
    @REM Expected: outer.txt, inner.txt; Actual: outer.txt
    dir "%TEST_FOLDER%\Open\Normal\" /b
    @REM Expected: outer.txt, inner.txt; Actual: outer.txt
    dir "%TEST_FOLDER%\OpenPipe\Normal\" /b
    
    @REM Wait for a keypress and exit
    pause
    exit
    
  • Execute the following command inside the sandbox to attempt to create a series of new files and delete them.

    03_[Sandboxie]_Create-and-delete-new-files.bat:

    @REM Specifying test folder
    set "TEST_FOLDER=C:\test"
    
    @REM Expected: Successfully created file; Actual: Access denied
    type nul > "%TEST_FOLDER%\Closed\Normal\NEW.txt"
    @REM Expected: Successfully created file; Actual: As expected
    type nul > "%TEST_FOLDER%\Write\Normal\NEW.txt"
    @REM Expected: Successfully created file; Actual: As expected
    type nul > "%TEST_FOLDER%\Open\Normal\NEW.txt"
    @REM Expected: Successfully created file; Actual: As expected
    type nul > "%TEST_FOLDER%\OpenPipe\Normal\NEW.txt"
    
    @REM pause
    pause
    
    @REM Expected: File deleted successfully; Actual: File not found
    del /q "%TEST_FOLDER%\Closed\Normal\NEW.txt"
    @REM Expected: File deleted successfully; Actual: As expected
    del /q "%TEST_FOLDER%\Write\Normal\NEW.txt"
    @REM Expected: File deleted successfully; Actual: File not found
    del /q "%TEST_FOLDER%\Open\Normal\NEW.txt"
    @REM Expected: File deleted successfully; Actual: File not found
    del /q "%TEST_FOLDER%\OpenPipe\Normal\NEW.txt"
    
    @REM Wait for a keypress and exit
    pause
    exit
    
  • Execute the following command on the host to check if there are any new files that have not been deleted.

    04_[Host]_List-new-files.bat:

    @REM Specifying test folder
    set "OUTER_FOLDER=C:\test"
    set "INNER_FOLDER=C:\Sandbox\%USERNAME%\DefaultBox\drive\C\test"
    
    @REM Expected: No matching files; Actual: As expected
    dir "%OUTER_FOLDER%" /b /s | findstr "NEW.txt"
    @REM Expected: No matching files; Actual: "%INNER_FOLDER%\Open\Normal\NEW.txt", "%INNER_FOLDER%\OpenPipe\Normal\NEW.txt"
    dir "%INNER_FOLDER%" /b /s | findstr "NEW.txt"
    
    @REM Wait for a keypress and exit
    pause
    exit
    

问题描述

Sandboxie-Plus(v1.16.3)的文件资源访问行为与预期不一致。

主要关系到被配置为 NormalFilePath 的文件夹的访问问题,具体表现为:

  • 对于一个被配置为 NormalFilePath 的文件夹,若其父文件夹为 ClosedFilePath,则沙箱程序无法对其进行访问。
  • 对于一个被配置为 NormalFilePath 的文件夹,若其父文件夹为 WriteFilePath,则沙箱程序只能读取到沙箱内部的文件;若其父文件夹为 OpenFilePathOpenPipePath,则沙箱程序只能读取到沙箱外部的文件。
    • 这还引发了另一个问题:对于父文件夹为 OpenFilePathOpenPipePathNormalFilePath文件夹,沙箱程序向其中写入文件,可以正常写入,同时也能得到写入成功的反馈,但无法再读取或删除这些文件。

而根据 NormalFilePath 的文档,NormalFilePath 可用于为那些父路径已经被配置为开放、仅写或甚至封禁的路径恢复默认的沙箱行为。故我认为上述表现不正常,与预期不符。

示例操作步骤

  • 在主机上执行如下命令,为沙箱外部、内部分别建立一系列相同的文件夹结构,并创建标识文件。
    01_[Host]_Init-files.bat

    @REM 指定测试文件夹
    set "OUTER_FOLDER=C:\test"
    set "INNER_FOLDER=C:\Sandbox\%USERNAME%\DefaultBox\drive\C\test"
    
    @REM 初始化沙箱外部测试文件(夹)
    mkdir "%OUTER_FOLDER%\Closed\Normal"
    mkdir "%OUTER_FOLDER%\Write\Normal"
    mkdir "%OUTER_FOLDER%\Open\Normal"
    mkdir "%OUTER_FOLDER%\OpenPipe\Normal"
    type nul > "%OUTER_FOLDER%\Closed\Normal\outer.txt"
    type nul > "%OUTER_FOLDER%\Write\Normal\outer.txt"
    type nul > "%OUTER_FOLDER%\Open\Normal\outer.txt"
    type nul > "%OUTER_FOLDER%\OpenPipe\Normal\outer.txt"
    
    @REM 初始化沙箱内部测试文件(夹)
    mkdir "%INNER_FOLDER%\Closed\Normal"
    mkdir "%INNER_FOLDER%\Write\Normal"
    mkdir "%INNER_FOLDER%\Open\Normal"
    mkdir "%INNER_FOLDER%\OpenPipe\Normal"
    type nul > "%INNER_FOLDER%\Closed\Normal\inner.txt"
    type nul > "%INNER_FOLDER%\Write\Normal\inner.txt"
    type nul > "%INNER_FOLDER%\Open\Normal\inner.txt"
    type nul > "%INNER_FOLDER%\OpenPipe\Normal\inner.txt"
    
    @REM 等待按键并退出
    pause
    exit
    
  • 对沙箱应用如下配置,以应用相关文件资源访问配置。

    ClosedFilePath=C:\test\Closed\*
    WriteFilePath=C:\test\Write\*
    OpenFilePath=C:\test\Open\*
    OpenPipePath=C:\test\OpenPipe\*
    
    NormalFilePath=C:\test\Closed\Normal\*
    NormalFilePath=C:\test\Write\Normal\*
    NormalFilePath=C:\test\Open\Normal\*
    NormalFilePath=C:\test\OpenPipe\Normal\*
    
  • 在沙箱内部执行如下命令,以在沙箱内部尝试遍历这些文件夹。
    02_[Sandboxie]_List-files.bat

    @REM 指定测试文件夹
    set "TEST_FOLDER=C:\test"
    
    @REM 期待结果:outer.txt, inner.txt;实际结果:找不到文件
    dir "%TEST_FOLDER%\Closed\Normal\" /b
    @REM 期待结果:outer.txt, inner.txt;实际结果:inner.txt
    dir "%TEST_FOLDER%\Write\Normal\" /b
    @REM 期待结果:outer.txt, inner.txt;实际结果:outer.txt
    dir "%TEST_FOLDER%\Open\Normal\" /b
    @REM 期待结果:outer.txt, inner.txt;实际结果:outer.txt
    dir "%TEST_FOLDER%\OpenPipe\Normal\" /b
    
    @REM 等待按键并退出
    pause
    exit
    
  • 在沙箱内部执行如下命令,以在沙箱内部尝试建立一系列新文件,并将其删除。
    03_[Sandboxie]_Create-and-delete-new-files.bat

    @REM 指定测试文件夹
    set "TEST_FOLDER=C:\test"
    
    @REM 期待结果:成功创建文件;实际结果:拒绝访问
    type nul > "%TEST_FOLDER%\Closed\Normal\NEW.txt"
    @REM 期待结果:成功创建文件;实际结果:与预期一致
    type nul > "%TEST_FOLDER%\Write\Normal\NEW.txt"
    @REM 期待结果:成功创建文件;实际结果:与预期一致
    type nul > "%TEST_FOLDER%\Open\Normal\NEW.txt"
    @REM 期待结果:成功创建文件;实际结果:与预期一致
    type nul > "%TEST_FOLDER%\OpenPipe\Normal\NEW.txt"
    
    @REM 暂停
    pause
    
    @REM 期待结果:成功删除文件;实际结果:找不到文件
    del /q "%TEST_FOLDER%\Closed\Normal\NEW.txt"
    @REM 期待结果:成功删除文件;实际结果:与预期一致
    del /q "%TEST_FOLDER%\Write\Normal\NEW.txt"
    @REM 期待结果:成功删除文件;实际结果:找不到文件
    del /q "%TEST_FOLDER%\Open\Normal\NEW.txt"
    @REM 期待结果:成功删除文件;实际结果:找不到文件
    del /q "%TEST_FOLDER%\OpenPipe\Normal\NEW.txt"
    
    @REM 等待按键并退出
    pause
    exit
    
  • 在主机上执行如下命令,检查是否存在未被删除的新文件。
    04_[Host]_List-new-files.bat

    @REM 指定测试文件夹
    set "OUTER_FOLDER=C:\test"
    set "INNER_FOLDER=C:\Sandbox\%USERNAME%\DefaultBox\drive\C\test"
    
    @REM 期待结果:无匹配文件;实际结果:与预期一致
    dir "%OUTER_FOLDER%" /b /s | findstr "NEW.txt"
    @REM 期待结果:无匹配文件;实际结果:"%INNER_FOLDER%\Open\Normal\NEW.txt", "%INNER_FOLDER%\OpenPipe\Normal\NEW.txt"
    dir "%INNER_FOLDER%" /b /s | findstr "NEW.txt"
    
    @REM 等待按键并退出
    pause
    exit
    

How often did you encounter it so far?

No response

Expected behavior

The behavior of the NormalFilePath subpath completely overrides the behavior of the ClosedFilePath, WriteFilePath, OpenFilePath, and OpenPipePath parent paths.

Affected program

Not relevant

Download link

Not relevant

Where is the program located?

The program is installed both inside and outside the sandbox.

Did the program or any related process close unexpectedly?

No, not at all.

Crash dump

No response

What version of Sandboxie are you running now?

Sandboxie-Plus v1.16.3 x64

Is it a new installation of Sandboxie?

I recently did a new clean installation.

Is it a regression from previous versions?

No response

In which sandbox type you have this problem?

In a standard isolation sandbox (yellow sandbox icon).

Can you reproduce this problem on a new empty sandbox?

I can confirm it also on a new empty sandbox.

What is your Windows edition and version?

Windows 11 23H2 ( in VMware )

In which Windows account you have this problem?

Not relevant to my request.

Please mention any installed security software

Default

Did you previously enable some security policy settings outside Sandboxie?

No response

Trace log

No response

Sandboxie.ini configuration

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions