public inbox for netfilter-devel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] security: use secure_getenv() to prevent env-var privilege escalation
@ 2026-02-11 14:19 Alan Ross
  2026-02-11 17:06 ` Florian Westphal
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Ross @ 2026-02-11 14:19 UTC (permalink / raw)
  To: netfilter-devel

Hi netfilter team,

  iptables uses getenv() to read XTABLES_LIBDIR, IPTABLES_LIB_DIR,
  IP6TABLES_LIB_DIR, XTABLES_LOCKFILE, and EBTABLES_SAVE_COUNTER. Since
  iptables runs as root, these become local privilege escalation vectors:

   - XTABLES_LIBDIR controls where extensions are loaded via dlopen().
     A local attacker who can inject this variable forces iptables to
     load arbitrary shared libraries as root (CWE-426, CWE-427).

   - XTABLES_LOCKFILE controls where the lock file is created via
     open(path, O_CREAT, 0600). An attacker can create or clobber
     arbitrary files as root.

  This patch replaces getenv() with secure_getenv() for all 5 variables.
  secure_getenv() returns NULL when AT_SECURE is set by the kernel (for
  setuid, setgid, or capability-elevated binaries), blocking env-var
  injection without affecting normal unprivileged usage.

  A portability shim is included for glibc < 2.17. A test program is
  included at tests/test-secure-getenv.c.

  Patch and full details:
  https://github.com/SleuthCo/iptables/compare/master...security/fix-env-var-privilege-escalation

  Signed-off-by: Alan <alan@sleuthco.ai>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-12  0:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 14:19 [PATCH] security: use secure_getenv() to prevent env-var privilege escalation Alan Ross
2026-02-11 17:06 ` Florian Westphal
     [not found]   ` <CAKgz23Hendu+Y=rhSwupr30Vf0JuJS5b6D-vp8A0TAC2swA-Bw@mail.gmail.com>
2026-02-11 19:03     ` Florian Westphal
     [not found]       ` <CAKgz23GWzqiryJwfjJyf7ObTkAnLciFZ6vKXcxACtm-N8xZi-w@mail.gmail.com>
2026-02-12  0:18         ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox