Skip to content

Commit

Permalink
Merge pull request #12491 from gyuho/better-exec
Browse files Browse the repository at this point in the history
*: validate exec command args, remove unused "iptables" wrapper
  • Loading branch information
gyuho authored Nov 25, 2020
2 parents b5cefb5 + b40b46f commit 64c409e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 117 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG-3.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,24 @@ The minimum recommended etcd versions to run in **production** are 3.2.28+, 3.3.

See [code changes](https://github.com/etcd-io/etcd/compare/v3.4.13...v3.4.14) and [v3.4 upgrade guide](https://github.com/etcd-io/etcd/blob/master/Documentation/upgrades/upgrade_3_4.md) for any breaking changes.

### Package `clientv3`

- Fix [auth token invalid after watch reconnects](https://github.com/etcd-io/etcd/pull/12264). Get AuthToken automatically when clientConn is ready.

### etcd server

- [Fix server panic](https://github.com/etcd-io/etcd/pull/12288) when force-new-cluster flag is enabled in a cluster which had learner node.

### Package `netutil`

- Remove [`netutil.DropPort/RecoverPort/SetLatency/RemoveLatency`](https://github.com/etcd-io/etcd/pull/12491).
- These are not used anymore. They were only used for older versions of functional testing.
- Removed to adhere to best security practices, minimize arbitrary shell invocation.

### `tools/etcd-dump-metrics`

- Implement [input validation to prevent arbitrary shell invocation](https://github.com/etcd-io/etcd/pull/12491).



<hr>
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG-3.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ Note that any `etcd_debugging_*` metrics are experimental and subject to change.
- Add [`/v3/auth/status`](https://github.com/etcd-io/etcd/pull/11536) endpoint to check if authentication is enabled
- [Add `Linearizable` field to `etcdserverpb.MemberListRequest`](https://github.com/etcd-io/etcd/pull/11639).

### Package `netutil`

- Remove [`netutil.DropPort/RecoverPort/SetLatency/RemoveLatency`](https://github.com/etcd-io/etcd/pull/12491).
- These are not used anymore. They were only used for older versions of functional testing.
- Removed to adhere to best security practices, minimize arbitrary shell invocation.

### `tools/etcd-dump-metrics`

- Implement [input validation to prevent arbitrary shell invocation](https://github.com/etcd-io/etcd/pull/12491).

### Dependency

- Upgrade [`google.golang.org/grpc`](https://github.com/grpc/grpc-go/releases) from [**`v1.23.0`**](https://github.com/grpc/grpc-go/releases/tag/v1.23.0) to [**`v1.26.0`**](https://github.com/grpc/grpc-go/releases/tag/v1.26.0).
Expand Down
82 changes: 0 additions & 82 deletions pkg/netutil/isolate_linux.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/netutil/isolate_stub.go

This file was deleted.

24 changes: 17 additions & 7 deletions tools/etcd-dump-metrics/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"time"

"go.etcd.io/etcd/client/v3"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/server/v3/embed"

"go.uber.org/zap"
Expand Down Expand Up @@ -61,12 +61,22 @@ func setupEmbedCfg(cfg *embed.Config, curls, purls, ics []url.URL) {
cfg.InitialCluster = cfg.InitialCluster[1:]
}

func getCommand(exec, name, dir, cURL, pURL, cluster string) string {
s := fmt.Sprintf("%s --name %s --data-dir %s --listen-client-urls %s --advertise-client-urls %s ",
exec, name, dir, cURL, cURL)
s += fmt.Sprintf("--listen-peer-urls %s --initial-advertise-peer-urls %s ", pURL, pURL)
s += fmt.Sprintf("--initial-cluster %s ", cluster)
return s + "--initial-cluster-token tkn --initial-cluster-state new"
func getCommand(exec, name, dir, cURL, pURL, cluster string) (args []string) {
if !strings.Contains(exec, "etcd") {
panic(fmt.Errorf("%q doesn't seem like etcd binary", exec))
}
return []string{
exec,
"--name", name,
"--data-dir", dir,
"--listen-client-urls", cURL,
"--advertise-client-urls", cURL,
"--listen-peer-urls", pURL,
"--initial-advertise-peer-urls", pURL,
"--initial-cluster", cluster,
"--initial-cluster-token=tkn",
"--initial-cluster-state=new",
}
}

func write(ep string) {
Expand Down
3 changes: 2 additions & 1 deletion tools/etcd-dump-metrics/install_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func install(ver, dir string) (string, error) {
return "", err
}

if err = exec.Command("bash", "-c", fmt.Sprintf("tar xzvf %s -C %s --strip-components=1", tarPath, dir)).Run(); err != nil {
// parametrizes to prevent attackers from adding arbitrary OS commands
if err = exec.Command("tar", "xzvf", tarPath, "-C", dir, "--strip-components=1").Run(); err != nil {
return "", err
}
return filepath.Join(dir, "etcd"), nil
Expand Down
4 changes: 2 additions & 2 deletions tools/etcd-dump-metrics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func main() {
rc := make(chan run)

cs1 := getCommand(bp, "s1", d1, "http://localhost:2379", "http://localhost:2380", cluster)
cmd1 := exec.Command("bash", "-c", cs1)
cmd1 := exec.Command(cs1[0], cs1[1:]...)
go func() {
if *debug {
cmd1.Stderr = os.Stderr
Expand All @@ -101,7 +101,7 @@ func main() {
rc <- run{cmd: cmd1}
}()
cs2 := getCommand(bp, "s2", d2, "http://localhost:22379", "http://localhost:22380", cluster)
cmd2 := exec.Command("bash", "-c", cs2)
cmd2 := exec.Command(cs2[0], cs2[1:]...)
go func() {
if *debug {
cmd2.Stderr = os.Stderr
Expand Down

0 comments on commit 64c409e

Please sign in to comment.