Skip to content

spored never starts on SELinux-enforcing AMIs (Rocky 9): installed with cloud_init_tmp_t label, so no TTL/cost-limit #1052

Closed

Description

@scttfrdmn

Summary

On Rocky Linux 9 (SELinux enforcing), spored never starts, so TTL, cost-limit and on-complete are not enforced. spawn launch reports a launched instance, and that instance runs until someone terminates it by hand.

Evidence

spawn v0.128.2 (38b2d66), AMI ami-00c356e7c787b9fc0 (Rocky-9-EC2-Base-9.8-20260525.0.x86_64), us-west-2, t3.small.

$ systemctl status spored
Active: activating (auto-restart) (Result: exit-code)
Process: 15279 ExecStart=/usr/local/bin/spored (code=exited, status=203/EXEC)
spored.service: Failed to locate executable /usr/local/bin/spored: Permission denied   (restart counter 32)

$ ls -Z /usr/local/bin/spored
system_u:object_r:cloud_init_tmp_t:s0 /usr/local/bin/spored
$ matchpathcon /usr/local/bin/spored
/usr/local/bin/spored	system_u:object_r:bin_t:s0

/tmp/SPAWN_COMPLETE existed from 20:33, but the instance was still running at 20:39 with --on-complete terminate, because nothing was there to act on it.

Cause

pkg/sporedinstall/install.go:135 downloads into mktemp /tmp/spored.XXXXXX, which cloud-init labels cloud_init_tmp_t. Then install.go:219 does mv -f "$tmp" /usr/local/bin/spored. mv keeps the source label, and systemd (init_t) can't exec a cloud_init_tmp_t file.

Minimal repro

spawn launch selinux-repro --region us-west-2 --instance-type t3.small \
  --ami ami-00c356e7c787b9fc0 --ttl 20m --cost-limit 0.10 --on-complete terminate \
  --command 'true' -y
spawn connect <id> -- 'ls -Z /usr/local/bin/spored; systemctl is-active spored'
# instance is NOT terminated at TTL; terminate manually

Suggested fix

After the mv at install.go:219, run command -v restorecon >/dev/null && restorecon -F /usr/local/bin/spored || true. Alternatively, use install -m 0755 "$tmp" /usr/local/bin/spored, which creates a new file that gets the default bin_t label. Also consider making spawn launch exit non-zero, or terminate the instance, when spored isn't active. Today the only signal is the SSM check, and on non-AL AMIs that check fails for a different reason (see the companion issue on the SSM agent).

Workaround in use downstream

spore-host/sclero runs restorecon -F /usr/local/bin/spored && systemctl restart spored via --user-data, which runs as root after the bootstrap. The workaround is marked and removable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions