False positive: go/zipslip when `filepath.IsLocal` is already used
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
Inizia dalle righe 89-125 collegate di gitcmd.go e dall'alert go/zipslip, quindi confronta la guardia filepath.IsLocal con la logica di rilevamento della query. Esamina issue 17573 per il contesto correlato. Il lavoro è completato quando questo caso protetto non viene più segnalato senza sopprimere i genuine findings di zipslip.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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/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:
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 16h
- PR unite (30g)
- 143
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/codeql
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
false-positive javascript
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
false-positive
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Tutte le issue di github/codeql
Issue simili
-
Theme loads third-party resources on every page (jsdelivr web font, cdnjs Font Awesome) – GDPR Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
docToolchain/docToolchain#1705 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modelcontextprotocol/python-sdk#3566 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
carbon-design-system/ibm-products#9907 ·
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
canonical/paas-charm#368 · 1 commento ·