-
Notifications
You must be signed in to change notification settings - Fork 18k
x/crypto/ssh: Marshal silently ignores fields with unsupported types #69944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
This normal for Go marshal/unmarshal functions, because of the way that the reflect package is implemented: you can't unmarshal into an unexported field. We should just document this restriction. |
Apologies, I think I misunderstood the issue here. I don't think it has to do with unexported types. The playground example is failing because CC @golang/security |
In my example there are two options. In the first case, as you said, the reason is that there is a field with the int type, in the second because there is a field with the struct type. In both cases, ssh.Marshal simply ignores them. But at the same time, if you pass a structure with a pointer or slice of an inappropriate type, a panic will occur. I suggest considering 2 proposals:
|
This code can be used to implement ssh.Marshaler and ssh.Unmarshaler interfaces. |
Go version
go version go1.23.1 linux/amd64
Output of
go env
in your module/workspace: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.
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.The text was updated successfully, but these errors were encountered: