Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Fix protoc install vulnerability #630

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kuksa_go_client/protocInstall/protocInstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
)

const (
Expand Down Expand Up @@ -50,8 +51,11 @@ func UnzipSource(source, destination string) error {
}

for _, f := range reader.File {
if strings.Contains(f.Name, "..") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why .. ? Moving one directory up and installing something weird? I think its not that big of an issue since we get the source from the official website.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As always with security topics it is always a question on how easy it is to take advantage of a vulnerability. We use hard-coded links like https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_32.zip and https, but if an attacker either manages to get write access to the protocolbuffers Github account, or manages to do some form of Man-In-The-Middle attack he could theoretically replace the content with something else.

(As we specify specific version we could theoretically do as in https://github.com/eclipse/kuksa.val/blob/master/kuksa-val-server/boost.cmake and add a SHA256 checksum to make sure we get what we expect)

Here one can argue that the severity of the vulnerability is limited, it might be difficult to find a "good business case" for an attacker, but as it was reported by code scanning, mentioned in https://cwe.mitre.org/data/definitions/22.html and is easy to fix I think it is better to fix it than to dismiss it.

fmt.Println("Ignoring path traversal elements (CWE-22): ", f.Name)
continue
}
filePath := filepath.Join(destination, f.Name)

if f.FileInfo().IsDir() {
err := os.MkdirAll(filePath, os.ModePerm)
if err != nil {
Expand Down