Skip to content

PhysicalFileProvider allows access to files inside excluded directories #107299

@rameel

Description

@rameel

Description

The current implementation of PhysicalFileProvider checks exclusion filters only for the requested file or directory and ignores that this file or directory may be located inside the excluded directory (e.g., .hidden/data/config.json).

Reproduction Steps

[Test]
public void Sample()
{
    var root = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
    var path = Path.Join(root, ".hidden/data/config.json");

    Directory.CreateDirectory(Path.GetDirectoryName(path)!);

    File.WriteAllText(path, "Hello World!");

    var provider = new PhysicalFileProvider(root, ExclusionFilters.Sensitive);
    var file = provider.GetFileInfo(".hidden/data/config.json");

    Assert.That(file.Exists, Is.False);
}

Expected behavior

The file .hidden/data/config.json should not be accessible when ExclusionFilters.Sensitive is applied.

Actual behavior

The file .hidden/data/config.json is accessible even with ExclusionFilters.Sensitive applied.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions