Skip to content

The Filesystem Scope Glob Pattern is too Permissive

Moderate
lucasfernog published GHSA-6mv3-wm7j-h4w5 Dec 22, 2022

Package

Tauri (Tauri-Apps)

Affected versions

>= 1.0.0, <1.0.8
>= 1.1.0, <1.1.3
>= 1.2.0, <1.2.3
>= 2.0.0-alpha.0, <2.0.0-alpha.2

Patched versions

>= 1.0.8
>= 1.1.3
>= 1.2.3
>= 2.0.0-alpha.2

Description

Impact

The filesystem glob pattern wildcards *, ?, and [...] match file path literals and leading dots by default, which unintentionally exposes sub folder content of allowed paths.

Example: The fs scope $HOME/*.key would also allow $HOME/.ssh/secret.key to be read even though it is in a sub directory of $HOME and is inside a hidden folder.

Scopes without the wildcards are not affected. As ** allows for sub directories the behavior there is also as expected.

Patches

The issue has been patched in the latest release and was backported into the currently supported 1.x branches.

Workarounds

No workaround is known at the time of publication.

References

The original report contained information that the dialog.open component automatically allows one sub directory to be read, regardless of the recursive option.

Imagine a file system looking like

 o ../
 o documents/
    - file.txt
    - deeper/
       o deep_file.txt

Reproduction steps:

  1. Trying to load “file.txt” or “deep_file.txt” doesn’t work. Expected
  2. Select “documents” as folder to open(ie. with window.TAURI.dialog.open)
  3. Trying to load “file.txt” works. Expected
  4. Trying to load “deep_file.txt” also works, which isn’t expected

The recursive flag is used in

escaped_pattern_with(p, if recursive { "**" } else { "*" })
to scope the filesystem access to either files in the folder or to also include sub directories.

The original issue was replicated and further investigated.

The root cause was triaged to the glob crate facilitating defaults, which allow the * and [...] to also match path literals.

MatchOptions {
    case_sensitive: true,
    require_literal_separator: false,
    require_literal_leading_dot: false
}

This implicated that not only the dialog.open component was affected but rather all fs scopes containing the * or [...] glob.
During this investigation it became obvious that the current glob matches would also match hidden folder (e.g: .ssh) content by default, without explicitly allowing hidden folders to be matched. This is not commonly expected behavior in comparison to for example bash.

The new default Match options are:

MatchOptions {
    case_sensitive: true,
    require_literal_separator: true,
    require_literal_leading_dot: true
}

Another note security relevant for developers building applications interacting with case sensitive filesystems is, that the case_sensitive option only affects ASCII file paths and is not valid in Unicode based paths. This is considered a known risk until the glob crate supports non-ASCII file paths for this type of case sensitive matching.

For more Information

If you have any questions or comments about this advisory:

Open an issue in tauri
Email us at [email protected]

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Adjacent
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N

CVE ID

CVE-2022-46171

Weaknesses

No CWEs

Credits