Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Zip Decryption auth check. #3151

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
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 accessors/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ func (self *CollectorAccessor) maybeSetZipPassword(
}

self.scope.SetContext(constants.ZIP_PASSWORDS, string(zip_pass))

value, pres := self.scope.Resolve(constants.REPORT_ZIP_PASSWORD)
if pres && self.scope.Bool(value) {
self.scope.Log("CollectorAccessor: X509 Decrypted password is %q",
string(zip_pass))
}
// Transform the path so it can be used by the zip
// collector.
return collectorPathToDelegatePath(full_path), nil
Expand Down
6 changes: 6 additions & 0 deletions accessors/zip/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ func (self *ZipFileCache) Open(full_path *accessors.OSPath) (
return nil, err
}

// Disable stream authentication because the library unpacks the
// entire stream into memory to verify it. In practice, the
// embedded data.zip file provides sufficient authentication
// anyway. See https://github.com/Velocidex/velociraptor/issues/3150
info.member_file.DeferAuth = true

fd, err := info.member_file.Open()
if err == zip.ErrPassword {
password := self.maybeGetPassword()
Expand Down
9 changes: 6 additions & 3 deletions bin/unzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/Velocidex/ordereddict"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/constants"
logging "www.velocidex.com/golang/velociraptor/logging"
"www.velocidex.com/golang/velociraptor/reporting"
"www.velocidex.com/golang/velociraptor/services"
Expand All @@ -18,8 +19,9 @@ import (
)

var (
unzip_cmd = app.Command("unzip", "Unzip a container file")
unzip_cmd_filter = unzip_cmd.Flag("where", "A WHERE condition for the query").String()
unzip_cmd = app.Command("unzip", "Unzip a container file")
unzip_cmd_report_password = unzip_cmd.Flag("report_password", "Log the X509 session password").Bool()
unzip_cmd_filter = unzip_cmd.Flag("where", "A WHERE condition for the query").String()

unzip_path = unzip_cmd.Flag("dump_dir", "Directory to dump output files.").
Default(".").String()
Expand Down Expand Up @@ -77,7 +79,8 @@ func doUnzip() error {
Env: ordereddict.NewDict().
Set("ZipPath", filename).
Set("DumpDir", *unzip_path).
Set("MemberGlob", *unzip_cmd_member),
Set("MemberGlob", *unzip_cmd_member).
Set(constants.REPORT_ZIP_PASSWORD, *unzip_cmd_report_password),
}

if *unzip_cmd_list {
Expand Down
3 changes: 3 additions & 0 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ const (
// accessor to open password protected zip files.
ZIP_PASSWORDS = "ZIP_PASSWORDS"

// If this is set, the logs will report the decrypted password
REPORT_ZIP_PASSWORD = "REPORT_ZIP_PASSWORD"

// If this is set we always copy SQLite files to a tempfile. Used
// by the sqlite() plugin.
SQLITE_ALWAYS_MAKE_TEMPFILE = "SQLITE_ALWAYS_MAKE_TEMPFILE"
Expand Down