Skip to content

x/crypto/ssh: Marshal silently ignores fields with unsupported types #69944

Open
@libmonsoon-dev

Description

@libmonsoon-dev

Go version

go version go1.23.1 linux/amd64

Output of go env in your module/workspace:

$ go env
GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/daniil_stepanenko/.cache/go-build'
GOENV='/home/daniil_stepanenko/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/daniil_stepanenko/go/pkg/mod'
GOOS='linux'
GOPATH='/home/daniil_stepanenko/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/daniil_stepanenko/go/go1.23.1'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/daniil_stepanenko/go/go1.23.1/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/daniil_stepanenko/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/daniil_stepanenko/work/upstream/gomplate/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2364282043=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/D6fgIrq7PpV

What did you see happen?

Marshal succeeds, but its result cannot be used. Unmarshal returns an error.

prog.go:24: ssh: unmarshal error for field E of type PublicKey: unsupported type: int
prog.go:25: ssh: short read
prog.go:36: ssh: unmarshal error for field E of type PublicKey: unsupported type: int
prog.go:37: ssh: short read

What did you expect to see?

ssh.Marshal+ssh.Unmarshal work successfully with rsa.PublicKey (and keys of other algorithms)

Or at least Marshal panics when it encounters a public field without the ssh:"skip" tag on an unsupported type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions