logo

Database

Go Zip Slip Path Traversal

Description

Detects Zip Slip path traversal vulnerabilities in Go applications that handle zip/tar archives. This security issue occurs when malicious archive files can write to arbitrary locations on the filesystem during extraction due to insufficient path validation, potentially allowing attackers to overwrite critical files.

Weakness:

063 - Lack of data validation - Path Traversal

Category: Unexpected Injection

Detection Strategy

    • Verifies that archive/zip or archive/tar packages are imported in the Go code

    • Identifies file operation methods that are used to extract or write files from archives

    • Checks if the file paths from the archive are properly validated before extraction

    • Reports a vulnerability when file operations use unsanitized paths from archive entries

Vulnerable code example

package main

import (
    "archive/zip"
    "io"
    "os"
    "path/filepath"
)...

✅ Secure code example

package main

import (
    "archive/zip"
    "io"
    "os"
    "path/filepath"
    "strings"...