Skip to content

Commit dbca4df

Browse files
committed
orchestrator: warn when elevated privileges discard the environment
A privilege-gaining exec — set-uid, set-gid, or one carrying file capabilities — has its KASLD_* settings dropped before main() runs, and nothing in the run said so. The difference is not cosmetic: a discarded KASLD_SYSROOT means the readout describes the machine doing the analysis while the caller named a captured tree, and the default output mentions no sysroot at all, so there was nothing to notice. The same command against the same absent sysroot resolves 3 facts unprivileged and 141 set-gid, the gap being the whole live host. Print one line on stderr beside the environment snapshot when the exec gained privilege, naming the consequence rather than only the cause: this readout describes the local system. It goes out even under --quiet, which suppresses progress noise rather than a caveat on the answer, matching the component-limit warning already there. Unconditional on a privileged exec, because the variables are gone by the time main() could ask which of them were set, and true whichever were: the sysroot is dropped on every such run. kasld(1) records that the run reports this, beside the env_reset note it already carried.
1 parent eb0c940 commit dbca4df

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

man/kasld.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ privilege-gaining \(em a set-uid or set-gid binary, or one carrying file
193193
capabilities \(em every
194194
.B KASLD_*
195195
variable is dropped before it is read, and the run proceeds on its own
196-
configuration.
196+
configuration, reporting that it did so on standard error.
197197
.TP
198198
.B KASLD_COMPONENT_DIR
199199
Directory to load component binaries from, overriding the default search

src/orchestrator.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,6 +4749,20 @@ int main(int argc, char *argv[]) {
47494749
color_output = isatty(STDOUT_FILENO);
47504750
}
47514751

4752+
/* A privilege-gaining exec had its KASLD_* settings dropped before main()
4753+
* ran. Nothing else in the run says so, and the difference is not cosmetic:
4754+
* a discarded KASLD_SYSROOT means the readout describes this machine rather
4755+
* than the captured tree the caller named.
4756+
*
4757+
* Printed even under --quiet, which suppresses progress noise rather than a
4758+
* caveat on the answer, and unconditional because the variables are gone by
4759+
* the time this could ask which of them were set. */
4760+
if (kasld_exec_gained_privilege())
4761+
fprintf(stderr,
4762+
"warning: elevated privileges (set-uid, set-gid or file "
4763+
"capabilities); KASLD_* environment settings are not honoured, so "
4764+
"this readout describes the local system\n");
4765+
47524766
/* Take the environment before anything else looks at the system: every
47534767
* format's readout, the "KASLR disabled" branch and the hardening advisor
47544768
* read it, and the advisor weighs a component's denial against the settings

0 commit comments

Comments
 (0)