Skip to content

Improve checks for relative paths in static resource handling #33689

Closed

Description

@rstoyanchev

Going forward with #33687 we are going to drop support for relative paths entirely. For the current 6.1.x branch, we can revise handling with the understanding that while the use case is still supported it is also likely not very common.

Activity

  1. added
    in: web
    type: enhancement
    on Oct 11, 2024
  2. added this to the 6.1.14 milestone on Oct 11, 2024
  3. self-assigned this
    on Oct 11, 2024
  4. added 2 commits that reference this issue on Oct 14, 2024
    3bfbe30
    fb7890d
  5. added 4 commits that reference this issue on Oct 30, 2024
    0270f00
    6f22dbb
    c3187ec
    bf44f69
  6. added 2 commits that reference this issue on Nov 26, 2024
    720a15a
    e40f0ae
  7. added 2 commits that reference this issue on Dec 4, 2024
    ba05787
    17b6a1e
  8. andreybpanfilov commented on Feb 10, 2025

    @andreybpanfilov

    @rstoyanchev

    it seems the initial issue (path traversal via symlinks) was caused by the fact the FileSystemResource class does not keep in sync path, file and filePath fields:

    	public FileSystemResource(String path) {
    		Assert.notNull(path, "Path must not be null");
    		this.path = StringUtils.cleanPath(path);
    		this.file = new File(path);  <---- should be new File(this.path)
    		this.filePath = this.file.toPath();
    	}
    

    compare with:

    	public FileSystemResource(FileSystem fileSystem, String path) {
    		Assert.notNull(fileSystem, "FileSystem must not be null");
    		Assert.notNull(path, "Path must not be null");
    		this.path = StringUtils.cleanPath(path);
    		this.file = null;
    		this.filePath = fileSystem.getPath(this.path).normalize();
    	}
    
  9. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions