Skip to content

Commit

Permalink
[WIP/DNM] CVE: Fix Receiver malicious tenant
Browse files Browse the repository at this point in the history
If running as root or with enough privileges, receiver can create a
directory outside of the configured TenantHeader.

This commit fixes it up by sanitizing the user input and explicity not
allowing such behavior.

Signed-off-by: Daniel Mellado <[email protected]>
  • Loading branch information
danielmellado committed Dec 19, 2022
1 parent a89dd0c commit 92c8fc1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
1 change: 0 additions & 1 deletion internal/cortex/querier/queryrange/queryrange.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ import (
stdlog "log"
"net"
"net/http"
"path"
"sort"
"strconv"
"sync"
"time"

"github.com/mwitkow/go-conntrack"
"github.com/opentracing/opentracing-go"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/gogo/protobuf/proto"
"github.com/jpillora/backoff"
"github.com/klauspost/compress/s2"
"github.com/mwitkow/go-conntrack"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
Expand Down Expand Up @@ -413,6 +415,11 @@ func (h *Handler) receiveHTTP(w http.ResponseWriter, r *http.Request) {
tenant = h.options.DefaultTenantID
}

if tenant != path.Base(tenant) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

if h.options.TenantField != "" {
tenant, err = h.getTenantFromCertificate(r)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/rules/rulespb/rpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/store/storepb/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 92c8fc1

Please sign in to comment.