Skip to content

Commit 4d0f6eb

Browse files
committed
restrict agent pipe access to current user on Windows
1 parent 74abed7 commit 4d0f6eb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tsshd/agent_windows.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@ import (
2828
"fmt"
2929
"net"
3030
"os"
31+
"os/user"
3132

3233
"github.com/Microsoft/go-winio"
3334
)
3435

3536
func listenForAgent() (net.Listener, string, error) {
37+
currentUser, err := user.Current()
38+
if err != nil {
39+
return nil, "", fmt.Errorf("get current user failed: %v", err)
40+
}
41+
42+
pipeConfig := &winio.PipeConfig{
43+
SecurityDescriptor: fmt.Sprintf("D:P(A;;GA;;;%s)", currentUser.Uid),
44+
}
3645
pipePath := fmt.Sprintf(`\\.\pipe\tsshd-agent-%d`, os.Getpid())
37-
listener, err := winio.ListenPipe(pipePath, nil)
46+
listener, err := winio.ListenPipe(pipePath, pipeConfig)
3847
if err != nil {
3948
return nil, "", fmt.Errorf("listen on [%s] failed: %v", pipePath, err)
4049
}

0 commit comments

Comments
 (0)