Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#20,043 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
security

Hướng nghiên cứu

Bắt đầu với các dòng 89-125 được liên kết trong gitcmd.go và go/zipslip alert, sau đó so sánh guard của filepath.IsLocal với logic phát hiện của query. Xem issue 17573 để biết ngữ cảnh liên quan. Hoàn tất khi trường hợp được bảo vệ này không còn bị báo cáo mà không suppress các zipslip findings thực sự.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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:

Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
143

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/codeql

Tất cả issue của github/codeql

Issue tương tự

Thêm issue về Security

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.