-
Notifications
You must be signed in to change notification settings - Fork 33
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
sshd scoping #1006
Comments
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
Issue status: With amazing help from @jrcheli and @iapaddler we find the root cause of the issue. Thee root cause is described below:
Current limitation: |
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
There is one limitation that I encounter while working on the First execv - rootexecv /usr/sbin/sshd uid 0
Second exec - rootexecve /usr/bin/env uid 0
Third exec - ssh session userThese environment variables will be used to execute ( execve /bin/bash uid 1000
In the scenario above during calling
other user:
|
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
Update regarding passing environment variables for forked process executed by
Without passing
|
// try to resolve the cmd from PATH env variable | |
char *path_env_ptr = getenv("PATH"); |
And we start to run bin/bash
with our loader with ldscope
found in the PATH
:
Line 2679 in 100734d
return g_fn.execve(pathname, argv, envp); |
Here is the summary of work.
Scenario 1-
Not impacted - everything works fine. Scenario 2-
The possible workaround is to pass the Scenario 3-
The possible workaround is to pass the The one thing worth mentioning is that |
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` use the function which impacts our library
- `sshd` server process use `fork` + `execv` to create ssh session for connected client Ref: https://github.com/openssh/openssh-portable/blob/16ea8b85838dd7a4dbeba4e51ac4f43fd68b1e5b/sshd.c#L2112
- `sshd` use the function which impacts our library
- `sshd` use the function which impacts our library
There are two issues related to scoping sshd.
After attaching to
sshd
we don't see that libscope.so is loaded in child process.This is related to fact that
sshd
useexecv
for starting a new processIssue when scoping
sshd
and connecting via ssh.Log message from sshd:
The last message comes from the following logic:
https://github.com/openssh/openssh-portable/blob/715c892f0a5295b391ae92c26ef4d6a86ea96e8e/atomicio.c#L81-L83
The text was updated successfully, but these errors were encountered: