-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix parsing of received environment variables from SSH clients #1935
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
Conversation
The inbuilt SSH server supports setting environment variable received from SSH clients. However, parsing of those variables was completely broken and success depended on chance. This new implementation uses standard operations from the crypto/ssh module to parse the SSH wire format. Signed-off-by: Dennis Keitzel <[email protected]>
@cybe maybe you could add some tests for this PR? it's difficult to review. |
@lunny: I'll look into it. |
How did this code even work in the first place? I don't see how executing In order to make this work correctly, you'd need to unmarshal the environment variables properly (as in this PR) and add them to a map, then pass them along when |
can you add copyright for Gitea to header |
This removes the environment variable parsing code from the SSH server, which never worked in the first place. Since environment variable passing doesn't appear to be necessary for the built-in SSH server to work properly, it's removed to reduce attack surface rather than fixing it. The current code processes (untrusted) input in a buggy manner and passes it to a process invocation which doesn't actually do anything. I don't *think* this is an exploitable vulnerability but I haven't looked at it in detail, and it wouldn't really surprise me if it was. Closes go-gitea#1935, an alternative proposal which which partially fixes the environment variable handling but ultimately still leaves it broken. Signed-off-by: Hugo Landau <[email protected]>
@hlandau |
Closing this in favour of #4266 |
The inbuilt SSH server supports setting environment variable received from SSH clients. However, parsing of those variables was completely broken and ignored the actual SSH protocol wire format, thus was only successful by chance.
This new implementation uses standard operations from the crypto/ssh module to parse the SSH wire format.