Skip to content

hardening: sanitize the process's own environment, not only children's #314

Description

@pierre-warnier

harden_process() clears core dumps, raises the file-size limit and applies Landlock, but leaves the process's own environment as the caller set it. In-process PAM and NSS modules therefore run with the caller's LD_*-free but otherwise arbitrary variables (PAM_*, locale, TZ, anything a module reads). Children get a clean environment where they are spawned; the tool itself does not.

docs/SECURITY-HARDENING.md lists this under Not yet implemented and pointed at #249, which was closed on 2026-09-04 without doing it.

What it would take: at the top of harden_process(), replace the environment with the sanitized set sanitized_env() already computes (PATH to a fixed value, TERM, LANG/LC_* kept), the way sudo-rs does, and drop the caller's copy. Setuid tools already ignore LD_* through the loader, so the visible change is confined to what PAM and NSS modules see. Needs a decision on which variables PAM conversations legitimately need (LANG for messages at least), and a test in the deployment suite that a variable set by the caller is not visible to a PAM module.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions