Bug 15271 - Netbooting can lead to arbitrary commands execution
Summary: Netbooting can lead to arbitrary commands execution
Status: CLOSED CODE_FIX
Alias: None
Product: Other
Classification: Unclassified
Component: klibc/kinit (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: other_klibc-kinit
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-11 11:39 UTC by Andrea Canciani
Modified: 2012-05-14 17:14 UTC (History)
4 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Patch to add string escaping (2.92 KB, patch)
2010-02-11 11:39 UTC, Andrea Canciani
Details | Diff
Patch to do correct string escaping (2.92 KB, patch)
2010-02-13 10:17 UTC, Andrea Canciani
Details | Diff
Patch to do correct string escaping (2) (2.92 KB, patch)
2010-02-13 10:21 UTC, Andrea Canciani
Details | Diff
Patch to do correct string escaping (3) (2.93 KB, patch)
2010-02-13 10:26 UTC, Andrea Canciani
Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.