Bug 15271

Summary: Netbooting can lead to arbitrary commands execution
Product: Other Reporter: Andrea Canciani (ranma42)
Component: klibc/kinitAssignee: other_klibc-kinit
Status: CLOSED CODE_FIX    
Severity: normal CC: adobriyan, alan, max, warthog9
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: Patch to add string escaping
Patch to do correct string escaping
Patch to do correct string escaping (2)
Patch to do correct string escaping (3)

Description Andrea Canciani 2010-02-11 11:39:29 UTC
Created attachment 24990 [details]
Patch to add string escaping

At boot, init typically configures networking by running ipconfig and sourcing /tmp/net-*.conf right after it.
An (intentionally) misconfigured DHCP server can send arbitrary commands to be executed in the sourcing (tested on Ubuntu Karmic Koala kernel 2.6.31-14) because no escaping is applied to the strings.
For example, a DHCP server passing a filename of "test$(cat /init)" makes the boot sequence display the content of the init file.
Comment 1 Alexey Dobriyan 2010-02-11 13:01:23 UTC
nothing to do with kernel
Comment 2 Andrea Canciani 2010-02-11 13:14:33 UTC
(In reply to comment #1)
> nothing to do with kernel
I posted the report here since klibc development tree (http://git.kernel.org/?p=libs/klibc/klibc.git) is managed by kernel.org
Is there a more appropriate bug tracker to use for klibc?
Comment 3 Andrea Canciani 2010-02-13 10:17:45 UTC
Created attachment 25028 [details]
Patch to do correct string escaping

Escaping in the previous patch was incorrect.
Escaping rewritten following the specification http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
Comment 4 Andrea Canciani 2010-02-13 10:21:01 UTC
Created attachment 25029 [details]
Patch to do correct string escaping (2)

Oops! The previous patch contained a typo.
Comment 5 Andrea Canciani 2010-02-13 10:26:40 UTC
Created attachment 25030 [details]
Patch to do correct string escaping (3)

The previous patch compiles, but contains a thinko (it outputs "'" both escaped and unescaped). Sorry.
I hope this one is fine.