Skip to content

nsexec (CVE-2019-5736): avoid parsing environ#1982

Merged
cyphar merged 1 commit into
opencontainers:masterfrom
brauner:2019-02-13/remove_cmdline_parsing
Feb 15, 2019
Merged

nsexec (CVE-2019-5736): avoid parsing environ#1982
cyphar merged 1 commit into
opencontainers:masterfrom
brauner:2019-02-13/remove_cmdline_parsing

Conversation

@brauner
Copy link
Copy Markdown

@brauner brauner commented Feb 14, 2019

My first attempt to simplify this and make it less costly focussed on
the way constructors are called. I was under the impression that the ELF
specification mandated that arg, argv, and actually even envp need to be
passed to functions located in the .init_arry section (aka
"constructors"). Actually, the specifications is (cf. 2:

SHT_INIT_ARRAY
This section contains an array of pointers to initialization functions,
as described in ``Initialization and Termination Functions'' in Chapter
5. Each pointer in the array is taken as a parameterless procedure with
a void return.

which means that this becomes a libc specific decision. Glibc passes
down those args, musl doesn't. So this approach can't work. However, we
can at least remove the environment parsing part based on POSIX since
1 mandates that there should be an environ variable defined in
unistd.h which provides access to the environment. See also the relevant
Open Group specification 1.

Fixes: CVE-2019-5736
Signed-off-by: Christian Brauner christian.brauner@ubuntu.com

@brauner
Copy link
Copy Markdown
Author

brauner commented Feb 14, 2019

//Cc @cyphar

My first attempt to simplify this and make it less costly focussed on
the way constructors are called. I was under the impression that the ELF
specification mandated that arg, argv, and actually even envp need to be
passed to functions located in the .init_arry section (aka
"constructors"). Actually, the specifications is (cf. [2]):

SHT_INIT_ARRAY
This section contains an array of pointers to initialization functions,
as described in ``Initialization and Termination Functions'' in Chapter
5. Each pointer in the array is taken as a parameterless procedure with
a void return.

which means that this becomes a libc specific decision. Glibc passes
down those args, musl doesn't. So this approach can't work. However, we
can at least remove the environment parsing part based on POSIX since
[1] mandates that there should be an environ variable defined in
unistd.h which provides access to the environment. See also the relevant
Open Group specification [1].

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/
[2]: http://www.sco.com/developers/gabi/latest/ch4.sheader.html#init_array

Fixes: CVE-2019-5736
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
@brauner brauner force-pushed the 2019-02-13/remove_cmdline_parsing branch from e6b7b8b to bb7d8b1 Compare February 14, 2019 15:07
@cyphar
Copy link
Copy Markdown
Member

cyphar commented Feb 14, 2019

LGTM.

Approved with PullApprove

@crosbymichael
Copy link
Copy Markdown
Member

crosbymichael commented Feb 14, 2019

LGTM

Approved with PullApprove

@cyphar cyphar merged commit bb7d8b1 into opencontainers:master Feb 15, 2019
cyphar added a commit that referenced this pull request Feb 15, 2019
  nsexec (CVE-2019-5736): avoid parsing environ

LGTMs: @cyphar @crosbymichael
Closes #1982
@brauner
Copy link
Copy Markdown
Author

brauner commented Feb 15, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants