Skip to content

Commit 528b83d

Browse files
authored
Merge pull request #5 from ImageMarkup/lockdown-zipstreamer
2 parents d93fc00 + 1bb06e1 commit 528b83d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

zip_streamer/server.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ func NewServer() *Server {
4141

4242
sentryHandler := sentryhttp.New(sentryhttp.Options{})
4343

44-
r.HandleFunc("/download", server.HandlePostDownload).Methods("POST")
44+
//r.HandleFunc("/download", server.HandlePostDownload).Methods("POST")
45+
//r.HandleFunc("/create_download_link", server.HandleCreateLink).Methods("POST")
46+
//r.HandleFunc("/download_link/{link_id}", server.HandleDownloadLink).Methods("GET")
47+
/*
48+
NOTE: Given that the zipstreamer server has unlimited access to private data, we have to disable every endpoint
49+
that could allow users with the correct URLs to private data to exfiltrate it through the zipstreamer service.
50+
This also includes modifying the server.HandleGetDownload such that it *only* supports listfile IDs, and not URLs.
51+
*/
4552
r.HandleFunc("/download", sentryHandler.HandleFunc(server.HandleGetDownload)).Methods("GET")
46-
r.HandleFunc("/create_download_link", server.HandleCreateLink).Methods("POST")
47-
r.HandleFunc("/download_link/{link_id}", server.HandleDownloadLink).Methods("GET")
4853

4954
return &server
5055
}
@@ -102,11 +107,9 @@ func (s *Server) HandlePostDownload(w http.ResponseWriter, req *http.Request) {
102107

103108
func (s *Server) HandleGetDownload(w http.ResponseWriter, req *http.Request) {
104109
params := req.URL.Query()
105-
listfileUrl := params.Get("zsurl")
106110
listFileId := params.Get("zsid")
107-
if listfileUrl == "" && s.ListfileUrlPrefix != "" && listFileId != "" {
108-
listfileUrl = s.ListfileUrlPrefix + listFileId
109-
}
111+
listfileUrl := s.ListfileUrlPrefix + listFileId
112+
110113
if listfileUrl == "" {
111114
w.WriteHeader(http.StatusBadRequest)
112115
w.Write([]byte(`{"status":"error","error":"invalid parameters"}`))

zip_streamer/zip_streamer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func getS3Object(urlStr string) (*http.Response, error) {
6161
// Extract bucket name from hostname (bucket.s3.region.amazonaws.com format)
6262
host := parsedURL.Host
6363
key := strings.TrimPrefix(parsedURL.Path, "/")
64-
64+
6565
parts := strings.Split(host, ".")
6666
bucket := parts[0]
6767

@@ -73,7 +73,7 @@ func getS3Object(urlStr string) (*http.Response, error) {
7373
if region == "" {
7474
region = "us-east-1"
7575
}
76-
76+
7777
cfg, err := config.LoadDefaultConfig(context.TODO(),
7878
config.WithRegion(region),
7979
)
@@ -116,7 +116,7 @@ func retryableGet(urlStr string) (*http.Response, error) {
116116
sleepDuration = time.Duration(math.Min(math.Pow(float64(2), float64(i)), float64(30))) * time.Second
117117

118118
var resp *http.Response
119-
119+
120120
if isS3URL {
121121
resp, err = getS3Object(urlStr)
122122
} else {

0 commit comments

Comments
 (0)