Skip to content

Behaviors declare exact sudo calls; osapi generates and checks the sudoers rules #1907

Done

Description

@retr0h

Today a behavior declares only a program name for sudo (osapi dsl behavior get --name netplan --json prints "sudo":["netplan"]). The sudoers lines are written by hand in docs/docs/sidebar/operate/secure/agent-hardening.md, nothing ties them to the code, and the build-a-behavior skill does not mention sudo. An agent that builds a behavior from source or through the DSL must guess a rule. Review of #1707 found a wildcard rule that matched more than its unit for this reason.

Build:

  • One source. A behavior declares each sudo call as a program and an argument shape, for example systemctl start on units from a fixed set. osapi generates the sudoers lines from these declarations. The hardening page, the agent preflight and osapi dsl behavior get print the same data.
  • A check. osapi dsl behavior validate and a test refuse a rule with * or ? in its arguments, a shell or an interpreter, and a command that takes a free path or free options as root. The test runs known attack strings through a matcher with sudo's glob rules. A call with a variable argument goes through a small root-owned helper that checks its input.
  • The written rule. A short section in specs, in CONTRIBUTING.md and in the build-a-behavior skill, read through the DSL commands.

Order: after #1707 merges (it edits the same hardening page and the netplan sudo declaration), before the round 1 cherry-picks of #1900. Findings about the current rules go in a private draft advisory, not here.

Activity

  1. added
    enhancement
    component/behavior-dsl
    component/agent
    on Dec 5, 2026
  2. retr0h commented on Dec 5, 2026

    @retr0h
    CollaboratorAuthor

    Owner, 5 Dec 2026: every lab VM runs the agent as the unprivileged osapi user with privilege escalation on and the rendered sudoers drop-in, with no ambient capabilities. Thus just int tests the real rules, and each rule or command that does not fit gets fixed here. The image makes the user and the unit; just bump installs the drop-in from the new build after visudo -c. The osapi-lab change goes with this issue.

  3. retr0h commented on Dec 5, 2026

    @retr0h
    CollaboratorAuthor

    Owner, 5 Dec 2026: osapi-lab gets a flag, lab_least_privilege. When it is on, the lab installs each component by osapi's least-privilege rules, each as its own system user: NATS, the controller and each agent. The lab follows the rules that osapi documents; where osapi has no rule yet for the controller or NATS, the rule goes into osapi's docs first.

  4. 8 remaining items

  5. retr0h commented on Dec 5, 2026

    @retr0h
    CollaboratorAuthor

    Owner decisions, 5 Dec 2026:

    1. A root broker replaces sudo. A socket-activated root service accepts requests only from the agent's user, matches them exactly against the behavior's declaration, and runs each one in a transient systemd unit with only that behavior's paths and capabilities. The agent unit gets NoNewPrivileges=yes, an empty bounding set and no sudo rules. The design change goes in docs(osapi): a root broker for declared work specs#756 first.
    2. osapi start is for tests only: it runs in the foreground as the person who runs it, refuses root and has no service install. A real single-host install is three services under three users.
    3. gohai v1.22.0 is tagged with feat(collector): say what each needs privilege for gohai#821.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component/agentcomponent/behavior-dslenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions