Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

False positive: go/zipslip when `filepath.IsLocal` is already used

Ouverte
#20,043 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
38/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
go
Domaine
security

Piste de recherche

Commencez par les lignes 89-125 liées de gitcmd.go et l’alerte go/zipslip, puis comparez la guard filepath.IsLocal avec la logique de détection de la requête. Consultez issue 17573 pour le contexte associé. Le travail est terminé lorsque ce cas protégé n’est plus signalé sans supprimer les véritables findings zipslip.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

false-positive

go/zipslip was detected, but the case was already protected by filepath.IsLocal.

Code example:

	r := tar.NewReader(bytes.NewReader(data))
	for {
		hdr, err := r.Next()
		if err != nil {
			if errors.Is(err, io.EOF) {
				break // End of archive.
			}
			return fmt.Errorf("failed to read next tar entry: %v", err)
		}
		name := hdr.Name
		if !filepath.IsLocal(name) {
			continue
		}
		if hdr.FileInfo().IsDir() {
			continue
		}
		// ... Make files/dirs based on name.

https://github.com/microsoft/go-infra/blob/7d114900fe9286d0fa400d02c6c5034b439d955b/gitcmd/gitcmd.go#L89-L125

https://github.com/microsoft/go-infra/security/code-scanning/4

IsLocal (added in go1.20) reports whether path, using lexical analysis only, has all of these properties:

  • is within the subtree rooted at the directory in which path is evaluated
  • is not an absolute path
  • is not empty
  • on Windows, is not a reserved name such as "NUL"

If IsLocal(path) returns true, then Join(base, path) will always produce a path contained within base and Clean(path) will always produce an unrooted path with no ".." path elements.

IsLocal is a purely lexical operation. In particular, it does not account for the effect of any symbolic links that may exist in the filesystem.

https://pkg.go.dev/archive/tar#Reader.Next mentions IsLocal as the way Go may automatically prevent zipslip:

If Next encounters a non-local name (as defined by filepath.IsLocal) and the GODEBUG environment variable contains tarinsecurepath=0, Next returns the header with an ErrInsecurePath error. A future version of Go may introduce this behavior by default. Programs that want to accept non-local names can ignore the ErrInsecurePath error and use the returned header.


I found an existing issue about go/zipslip, but it's about looking inside a func, not IsLocal:

Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 16 h
PR mergées (30 j)
143

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de github/codeql

Toutes les issues de github/codeql

Issues similaires

Plus d'issues Security

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.