aws / aws/aws-ec2-instance-connect-config

Need appropriate SELinux type enforcement profile to work on hardened EL7 instances

Open
#2 13 comments 11 reactions 1 assignee Claimed by @LordAlfredo View on GitHub
Dominant language
Shell
Stars
88
Forks
39
PR merge metrics
No merged PRs in 30d

Description

Our compliance requirements include need for signed RPMs that are compatible with SELinux in targeted enforcement-mode. Had put together a process to download SRPMs from the Amazon Linux 2 AMIs whenever the "new AMI" SNS notice would hit. Found that `ec2-instance-connect` SRPM started showing up in the 20190612 AMI. After repackaging for Enterprise Linux 7, found that service wasn't working with our AMIs. After some investigation, determined issue was lack of SELinux compatibility. Used the AVC denials to put together a provisional SELinux exclusion.

Currently am using the following in my (ad hoc) UserData to allow use of the `ec2-instance-connect` (but would obviously prefer this just live in the RPM):

~~~
# Write an uncompiled SELinux type-definition to disk
cat > /root/instance-connect.te << EOF
module instance-connect 1.0;

require {
type ssh_keygen_exec_t;
type http_port_t;
type sshd_t;
class process setpgid;
class tcp_socket name_connect;
class file { execute execute_no_trans open read };
}

#============= sshd_t ==============

#!!!! This avc can be allowed using one of the these booleans:
# authlogin_yubikey, nis_enabled
allow sshd_t http_port_t:tcp_socket name_connect;
allow sshd_t self:process setpgid;
allow sshd_t ssh_keygen_exec_t:file { execute execute_no_trans open read };
EOF

# Compile and SELinux module for EC2 Instance Connect
checkmodule -M -m -o /root/instance-connect.mod /root/instance-connect.te
semodule_package -o /root/instance-connect2.pp -m /root/instance-connect.mod
semodule -i /root/instance-connect2.pp
~~~

Am looking to submit a PR, but wanted to know if the above (the policy-def in the HERE document; the rest is just a way to activate it outside of a managed packaging) is sufficient. The PR would include the compiled policie files and appropriate `%post` script (updates) to ensure they're activated. Is there a preference on priority level that they should be activated to (i.e., is `400` ok, or would there be a preference for a different level?).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.