main: _exit() if setuid
Florian Westphal
maintainerPATCH 1/1 main: _exit() if setuid
Apparently some people think its a good idea to make nft setuid so unrivilged users can change settings.
"nft -f /etc/shadow" is just one example of why this is a bad idea. Disable this. Do not print anything, fd cannot be trusted.
--- src/main.c | 4 ++++ 1 file changed, 4 insertions(+)
src/main.c +4 -0
@@ -363,6 +363,10 @@ int main(int argc, char * const *argv)unsigned int len;int i, val, rc; +/* nftables cannot be used with setuid in a safe way. */ +if (getuid () !=geteuid ()) +_exit (111 ); +if (!nft_options_check (argc, argv))exit (EXIT_FAILURE );
Signature · 1 line
2.31.1
Pablo Neira Ayuso
maintainerQuoted 16 lines · Florian Westphal
Apparently some people think its a good idea to make nft setuid so unrivilged users can change settings.
"nft -f
/etc/shadow" is just one example of why this is a bad idea. Disable this. Do not print anything, fd cannot be trusted.Signed-off-by Florian Westphal <[email protected]>--- src/main.c | 4 ++++ 1 file changed, 4 insertions(+)src/main.c +0
-0
src/main.c int main(int argc, char * const *argv) · line 368
Quoted 6 lines
src/main.c +3
-0@@ -363,6 +363,10 @@ int main(int argc, char * const *argv)unsigned int len;int i, val, rc; +/* nftables cannot be used with setuid in a safe way. */ +if (getuid () !=geteuid ()) +_exit (111 );
Applications using libnftables would still face the same issue.
Quoted 6 lines
src/main.c +0
-0if (!nft_options_check (argc, argv))exit (EXIT_FAILURE );Signature · 1 line
2.31.1
Florian Westphal
maintainerQuoted 20 lines · Pablo Neira Ayuso
Quoted 19 lines · Florian Westphal
Apparently some people think its a good idea to make nft setuid so unrivilged users can change settings.
"nft -f
/etc/shadow" is just one example of why this is a bad idea. Disable this. Do not print anything, fd cannot be trusted.Signed-off-by Florian Westphal <[email protected]>--- src/main.c | 4 ++++ 1 file changed, 4 insertions(+)src/main.c +0
-0@@ -363,6 +363,10 @@ int main(int argc, char * const *argv)unsigned int len;int i, val, rc;
Quoted 5 lines
src/main.c int main(int argc, char * const *argv) · line 368
Quoted 3 lines
src/main.c +3
-0+/* nftables cannot be used with setuid in a safe way. */ +if (getuid () !=geteuid ()) +_exit (111 );Applications using libnftables would still face the same issue.
Yes, but there is an off-chance they know what they are doing.
Pablo Neira Ayuso
maintainerQuoted 21 lines · Florian Westphal
Quoted 20 lines · Pablo Neira Ayuso
Quoted 19 lines · Florian Westphal
Apparently some people think its a good idea to make nft setuid so unrivilged users can change settings.
"nft -f
/etc/shadow" is just one example of why this is a bad idea. Disable this. Do not print anything, fd cannot be trusted.Signed-off-by Florian Westphal <[email protected]>--- src/main.c | 4 ++++ 1 file changed, 4 insertions(+)src/main.c +0
-0@@ -363,6 +363,10 @@ int main(int argc, char * const *argv)unsigned int len;int i, val, rc;
Quoted 7 lines
Quoted 5 lines
src/main.c int main(int argc, char * const *argv) · line 368
Quoted 3 lines
src/main.c +3
-0+/* nftables cannot be used with setuid in a safe way. */ +if (getuid () !=geteuid ()) +_exit (111 );Applications using libnftables would still face the same issue.
Yes, but there is an off-chance they know what they are doing.
Sounds sensible, I'd suggest you document this in the commit before pushing.