Skip to content
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

seccomp-bpf filter violation in sshd #97

Closed
mike2307 opened this issue Aug 22, 2019 · 11 comments
Closed

seccomp-bpf filter violation in sshd #97

mike2307 opened this issue Aug 22, 2019 · 11 comments
Labels

Comments

@mike2307
Copy link

mike2307 commented Aug 22, 2019

After enabling the preload of the libhardened_malloc.so, I'm not able to login any more via SSH. This is the case for a system running the Fedora 30 with all the latest updates as well as RHEL 7.7 with all the latest updates.

What I've done:

  • Compiled libhardened_malloc.so with all default settings.
  • Installed into /usr/local/lib64/
  • Created /etc/ld.so.preload with content /usr/local/lib64/libhardened_malloc.so
  • Created /etc/sysctl.d/51-hardened_malloc.conf with content vm.max_map_count = 524288
  • Rebooted
  • Everything working normal
  • Trying to login via SSH from a different machine (where I'm getting Connection closed by 192.168.0.10 port 22)

I looked through the logs after a failed login and could find something in /var/log/audit/audit.log on the server's side.

...
type=ANOM_ABEND msg=audit(1566493285.761:2070): auid=4294967295 uid=74 gid=74 ses=4294967295 subj=system_u:system_r:sshd_net_t:s0-s0:c0.c1023 pid=56568 comm="sshd" reason="memory violation" sig=31
...
type=USER_LOGIN msg=audit(1566493285.762:2074): pid=56567 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=login acct="(unknown)" exe="/usr/sbin/sshd" hostname=? addr=192.168.0.20 terminal=ssh res=failed'
...

Please help.
Must be caused by libhardened_malloc.so because removing it from /etc/ld.so.preload fixes the problem.

@thestinger
Copy link
Member

I think this is a violation of their seccomp-bpf filter, which doesn't whitelist mprotect. It will need to be addressed like the man-db issue.

@thestinger thestinger changed the title Causes memory access violation in sshd seccomp-bpf filter violation in sshd Aug 22, 2019
@thestinger
Copy link
Member

You can see in https://github.com/openssh/openssh-portable/blob/master/sandbox-seccomp-filter.c that mprotect is not whitelisted.

@mike2307
Copy link
Author

That was a quick response! :)
What is the man-db issue? Maybe I can try to patch/contribute...

@thestinger
Copy link
Member

The same problem with getrandom rather than mprotect.

https://git.savannah.gnu.org/cgit/man-db.git/commit/?id=0951f82c611c4a3c14271b0fa9c4919c84b7afe7

It would technically be possible for hardened_malloc to use mmap with MAP_FIXED instead of mprotect to unprotect slabs, metadata and the non-guard portion of large allocations. However, mprotect makes more sense, is probably somewhat faster and should probably be whitelisted as part of permitted malloc usage. It's used by glibc malloc but they apparently don't trigger it. I think they'd be fine with adding it especially since OpenBSD malloc uses mprotect too.

@mike2307
Copy link
Author

Someone already opened a pull request:
openssh/openssh-portable#142

@lukateras
Copy link

lukateras commented Aug 23, 2019

Fixed upstream in openssh/openssh-portable@f6906f9.

@thestinger
Copy link
Member

It would be good if someone could keep an eye on this and let me know when it's available in a release.

@aclonegeek
Copy link

@thestinger

If I'm not mistaken, it looks like it's available in OpenSSH 8.1.

See:
Release notes
Commit tagged to V_8_1_P1

@thestinger
Copy link
Member

Thanks.

@adrelanos
Copy link

@adrelanos
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants