mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Small security option
@ 2003-09-18  0:55 John R Moser
  2003-09-18  1:11 ` Rene Rebe
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: John R Moser @ 2003-09-18  0:55 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 367 bytes --]

Why wasn't this done in the first place anyway? 

Some sysadmins like to disable the other boot devices and password-protect
the bios.  Good, but if the person can pass init=, you're screwed. 

Here's a small patch that does a very simple thing: Disables "init=" and
using /bin/sh for init. That'll stop people from rooting the box from grub. 

The file is attatched.

[-- Attachment #2: Type: TEXT/PLAIN, Size: 3098 bytes --]

diff -ur linux-2.4.22/Documentation/Configure.help linux-2.4.22-secureinit/Documentation/Configure.help
--- linux-2.4.22/Documentation/Configure.help	2003-08-25 07:44:39.000000000 -0400
+++ linux-2.4.22-secureinit/Documentation/Configure.help	2003-09-17 20:38:19.000000000 -0400
@@ -2529,6 +2529,32 @@
   behaviour is platform-dependent, but normally the flash frequency is
   a hyperbolic function of the 5-minute load average.
 
+Secure init
+CONFIG_SECURE_INIT
+  Under normal circumstances, the kernel tries the following at boot
+  as init:
+
+    /sbin/init
+    /etc/init
+    /bin/init
+    /bin/sh
+
+  This can be overridden by passing init= to the kernel command line.
+  This is a security hazard.  If you say 'Y' here, init= will be
+  ignored (actually it will flash a warning at boot time), and /bin/sh
+  will also never be used as init.  This prevents users with physical
+  access to the machine from gaining root access by passing
+  init=/bin/bash to the kernel.
+
+  It is common to pass init=/bin/bash to the kernel to fix really
+  messed up machines.  If you say 'Y' here, you should make sure you
+  have a boot floppy with a kernel compiled with normal init code, OR
+  a rescue system such as a boot/root floppy or a Knoppix CD.
+
+  Most users should say 'Y' here, unless you know you will not have
+  access to alternate recovery methods as listed in the above
+  paragraph.
+
 Networking support
 CONFIG_NET
   Unless you really know what you are doing, you should say Y here.
diff -ur linux-2.4.22/arch/i386/config.in linux-2.4.22-secureinit/arch/i386/config.in
--- linux-2.4.22/arch/i386/config.in	2003-08-25 07:44:39.000000000 -0400
+++ linux-2.4.22-secureinit/arch/i386/config.in	2003-09-17 20:39:58.000000000 -0400
@@ -261,6 +261,7 @@
 mainmenu_option next_comment
 comment 'General setup'
 
+bool 'Secure init' CONFIG_SECURE_INIT
 bool 'Networking support' CONFIG_NET
 
 # Visual Workstation support is utterly broken.
diff -ur linux-2.4.22/init/main.c linux-2.4.22-secureinit/init/main.c
--- linux-2.4.22/init/main.c	2003-08-25 07:44:44.000000000 -0400
+++ linux-2.4.22-secureinit/init/main.c	2003-09-17 20:35:59.000000000 -0400
@@ -574,11 +574,28 @@
 	 * trying to recover a really broken machine.
 	 */
 
+	/*
+	 * init= is a security hazzard.  Let's configure it out.
+	 */
+
 	if (execute_command)
+#ifndef CONFIG_SECURE_INIT
 		execve(execute_command,argv_init,envp_init);
+#else
+	{
+		printk("WARNING:  kernel parameter:  {init=");
+		printk(execute_command);
+		printk("} passed, but CONFIG_SECURE_INIT set.  init= parameter IGNORED\n");
+	}
+#endif
 	execve("/sbin/init",argv_init,envp_init);
 	execve("/etc/init",argv_init,envp_init);
 	execve("/bin/init",argv_init,envp_init);
+#ifndef CONFIG_SECURE_INIT
 	execve("/bin/sh",argv_init,envp_init);
 	panic("No init found.  Try passing init= option to kernel.");
+#else
+	printk("CONFIG_SECURE_INIT defined, and init not found.\n");
+	panic("No init found.  Init must be in /sbin/init, /etc/init, or /bin/init");
+#endif
 }

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

* Re: Small security option
  2003-09-18  0:55 Small security option John R Moser
@ 2003-09-18  1:11 ` Rene Rebe
  2003-09-18  1:25 ` Mitchell Blank Jr
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Rene Rebe @ 2003-09-18  1:11 UTC (permalink / raw)
  To: jmoser5; +Cc: linux-kernel

Hi,

On: Wed, 17 Sep 2003 20:55:44 -0400 (EDT),
    John R Moser <jmoser5@student.ccbc.cc.md.us> wrote:
> Why wasn't this done in the first place anyway? 
> 
> Some sysadmins like to disable the other boot devices and password-protect
> the bios.  Good, but if the person can pass init=, you're screwed. 
> 
> Here's a small patch that does a very simple thing: Disables "init=" and
> using /bin/sh for init. That'll stop people from rooting the box from grub. 

+  will also never be used as init.  This prevents users with physical
+  access to the machine from gaining root access by passing
+  init=/bin/bash to the kernel.
+
+  It is common to pass init=/bin/bash to the kernel to fix really
+  messed up machines.  If you say 'Y' here, you should make sure you
+  have a boot floppy with a kernel compiled with normal init code, OR
+  a rescue system such as a boot/root floppy or a Knoppix CD.

Erhm this adds no security - you know most people always have a USB
stick or Credit Card CD with a tiny Linux in the pocket? Or just take
the HD out of your box?

Maybe you should configure GRUB to need a password to change the
config on-the-fly to gain the same amount of "security"?

> The file is attatched.

Sincerely yours,
  René Rebe

--  
René Rebe - Europe/Germany/Berlin
  rene@rocklinux.org rene@rocklinux-consulting.de
http://www.rocklinux.org http://www.rocklinux-consulting.de
http://gsmp.tfh-berlin.de/gsmp http://gsmp.tfh-berlin.de/rene


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

* Re: Small security option
  2003-09-18  0:55 Small security option John R Moser
  2003-09-18  1:11 ` Rene Rebe
@ 2003-09-18  1:25 ` Mitchell Blank Jr
  2003-09-18  1:25 ` Chris Wright
  2003-09-18 11:15 ` Richard B. Johnson
  3 siblings, 0 replies; 6+ messages in thread
From: Mitchell Blank Jr @ 2003-09-18  1:25 UTC (permalink / raw)
  To: John R Moser; +Cc: linux-kernel

John R Moser wrote:
> Some sysadmins like to disable the other boot devices and password-protect
> the bios.  Good, but if the person can pass init=, you're screwed. 

1. If you have physical access to the machine you're screwed anyway (boot
   from a CD... if BIOS is password-protected just temporarily put the
   harddrive in another machine)

2. In the relatively rare cases that you have physical access to the console
   but not the machine (locked down kiosks or secured lab settings) you can
   (and should) secure the bootloader.  This prevents any malicious command
   line options (think "root=my.nfs.server:/toolkit") not just "init=".

So this patch is basically pointless.

-Mitch

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

* Re: Small security option
  2003-09-18  0:55 Small security option John R Moser
  2003-09-18  1:11 ` Rene Rebe
  2003-09-18  1:25 ` Mitchell Blank Jr
@ 2003-09-18  1:25 ` Chris Wright
  2003-09-18  6:11   ` bert hubert
  2003-09-18 11:15 ` Richard B. Johnson
  3 siblings, 1 reply; 6+ messages in thread
From: Chris Wright @ 2003-09-18  1:25 UTC (permalink / raw)
  To: John R Moser; +Cc: linux-kernel

* John R Moser (jmoser5@student.ccbc.cc.md.us) wrote:
> Why wasn't this done in the first place anyway? 
> 
> Some sysadmins like to disable the other boot devices and password-protect
> the bios.  Good, but if the person can pass init=, you're screwed. 
> 
> Here's a small patch that does a very simple thing: Disables "init=" and
> using /bin/sh for init. That'll stop people from rooting the box from grub. 

If you have this access, you already own the box.
-chris
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net

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

* Re: Small security option
  2003-09-18  1:25 ` Chris Wright
@ 2003-09-18  6:11   ` bert hubert
  0 siblings, 0 replies; 6+ messages in thread
From: bert hubert @ 2003-09-18  6:11 UTC (permalink / raw)
  To: Chris Wright; +Cc: John R Moser, linux-kernel

On Wed, Sep 17, 2003 at 06:25:43PM -0700, Chris Wright wrote:
> * John R Moser (jmoser5@student.ccbc.cc.md.us) wrote:
> > Why wasn't this done in the first place anyway? 
> > 
> > Some sysadmins like to disable the other boot devices and password-protect
> > the bios.  Good, but if the person can pass init=, you're screwed. 
> > 
> > Here's a small patch that does a very simple thing: Disables "init=" and
> > using /bin/sh for init. That'll stop people from rooting the box from grub. 
> 
> If you have this access, you already own the box.
> -chris

Not *entirely* true. I know of hardware that would scream if it were opened
and refuse to boot the next time, unless a bios password would be entered.
Sure, it can be circumvented, but allowing software to bypass such measures
seems silly.

However, in this case, lilo or grub or whatever should prevent the user from
entering kernel parameters if they aren't authorized, not the kernel.

	Bert.

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO

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

* Re: Small security option
  2003-09-18  0:55 Small security option John R Moser
                   ` (2 preceding siblings ...)
  2003-09-18  1:25 ` Chris Wright
@ 2003-09-18 11:15 ` Richard B. Johnson
  3 siblings, 0 replies; 6+ messages in thread
From: Richard B. Johnson @ 2003-09-18 11:15 UTC (permalink / raw)
  To: John R Moser; +Cc: linux-kernel

On Wed, 17 Sep 2003, John R Moser wrote:

> Why wasn't this done in the first place anyway?
>
> Some sysadmins like to disable the other boot devices and password-protect
> the bios.  Good, but if the person can pass init=, you're screwed.
>
> Here's a small patch that does a very simple thing: Disables "init=" and
> using /bin/sh for init. That'll stop people from rooting the box from grub.
>
> The file is attatched.

No. I can still boot your box, mount your root file-system, and
change the root password, all without you even knowing it.
If I have physical control of a computer, I own it. I can
do anything I want with it. If you could really prevent
somebody from "breaking in", then you can never sell it and
you are screwed if the password file gets corrupt (you would have
to throw everything away).

This patch is not useful.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (794.73 BogoMips).
            Note 96.31% of all statistics are fiction.



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

end of thread, other threads:[~2003-09-18 11:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-18  0:55 Small security option John R Moser
2003-09-18  1:11 ` Rene Rebe
2003-09-18  1:25 ` Mitchell Blank Jr
2003-09-18  1:25 ` Chris Wright
2003-09-18  6:11   ` bert hubert
2003-09-18 11:15 ` Richard B. Johnson

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

all inboxes | Powered by JetHome®