Skip to content

Replace strings.HasPrefix with os.OpenRoot in driver uninstall #55

Closed

Description

@amoeba

To ensure we are removing a directory that's safe to remove, we currently use a combination of filepath.Clean and strings.HasPrefix,

dbc/config/config.go

Lines 322 to 329 in 845f710

// Run filepath.Clean on sharedPath mainly to catch inner ".." in the path
sharedPath = filepath.Clean(sharedPath)
// Don't remove anything that isn't contained withing the found driver's
// config directory (i.e., avoid malicious driver manifests)
if !strings.HasPrefix(sharedPath, cfg.Location) {
continue
}

Using https://go.dev/blog/osroot is probably even a better way to do this type of protection so we should refactor to use it.

This is a follow-on to #48.

Activity

  1. changed the title [-]replace strings.HasPrefix with os.OpenRoot in driver uninstall[/-] [+]Replace strings.HasPrefix with os.OpenRoot in driver uninstall[/+] on Sep 22, 2025
  2. added
    enhancement
    on Sep 23, 2025
  3. added this to the 0.2.0 milestone on Feb 4, 2026
  4. added a commit that references this issue on Feb 6, 2026
    d14bf91
  5. added 2 commits that reference this issue on Apr 17, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions