Skip to content

Insights fetchFile: directory whitelist is a naive prefix match — allows ../ traversal #6057

Backlog

Description

@HusseinAdeiza

InsightsEndpoint.fetchFile authorizes via PathUtil.isFileWhitelisted. For a whitelisted directory (the trailing-slash form the docs support) the check is:

e.endsWith('/') && path.startsWith(e)

That is a raw string prefix with no canonicalization, so a path like /var/log/app/../../etc/passwd passes the check and is then read verbatim via relativePathToPlatformPath.

Preconditions, as noted when this was triaged privately: reaching it requires the Insights service secret (the operator's own management credential) plus a whitelist entry that the default configuration does not include. So this is not remotely exploitable out of the box; it is a defense-in-depth gap in the file-access layer, worth closing because a leaked or rotated-insufficient service credential then turns into arbitrary file reads instead of directory-scoped reads.

  • path_util.dart:9-18 - isFileWhitelisted / relativePathToPlatformPath
  • insights.dart:377-390 - fetchFile reads the raw path (line numbers against current main)

Suggested hardening: canonicalize the resolved path and verify it stays inside the whitelisted directory (containment check); reject .. segments.

Disclosed privately 2026-11-06; the security team confirmed the behavior and will address it as a hardening change. Opening here for the record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions