Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dracut can execute commands from malformed /etc/os-release #1064

Closed
0n0w1c opened this issue Feb 7, 2021 · 2 comments
Closed

dracut can execute commands from malformed /etc/os-release #1064

0n0w1c opened this issue Feb 7, 2021 · 2 comments
Assignees
Labels
bug Our bugs

Comments

@0n0w1c
Copy link

0n0w1c commented Feb 7, 2021

Describe the bug
A malformed /etc/os-release can execute commands during the creation of the initramfs.

Distribution used
Manjaro

Dracut version
051-1

Init system
systemd

To Reproduce
Create /usr/lib/os-release with the following:

NAME="Manjaro-ARM"
ID=manjaro-arm
ID_LIKE=manjaro arch
PRETTY_NAME="Manjaro ARM"
ANSI_COLOR="1;32"
HOME_URL="https://www.manjaro.org/"
SUPPORT_URL="https://forum.manjaro.org/c/arm/"

Create the the following symbolic link:
/etc/os-release -> /usr/lib/os-release

Create an initramfs and you will see the following in the output:

dracut: *** Including module: base ***
/etc/os-release: line 3: arch: command not found

If you create /usr/bin/arch and then recreate the initramfs, it will execute the file.

Expected behavior
An error or warning message of the syntax error, no execution of files.

Additional context

@0n0w1c 0n0w1c added the bug Our bugs label Feb 7, 2021
@johannbg
Copy link
Collaborator

johannbg commented Feb 7, 2021

Dracut is not a configuration file syntax checker, expecting that is somewhat out of the scope for the project.
You could file an RFE in the systemd repo asking that systemd-analyze could be extended to verify the syntax for the file in question, if implemented we could then use that.

That dracut tries to execute the second field of "ID_LIKE=" in operating system identification file is quite the bug and probably one that is happening elsewhere as well.

@haraldh
Copy link
Collaborator

haraldh commented Feb 8, 2021

OS-RELEASE(5)                                                           os-release                                                           OS-RELEASE(5)

NAME
       os-release - Operating system identification

SYNOPSIS
       /etc/os-release

       /usr/lib/os-release

DESCRIPTION
       The /etc/os-release and /usr/lib/os-release files contain operating system identification data.

       The basic file format of os-release is a newline-separated list of environment-like shell-compatible variable assignments.
       It is possible to source the configuration from shell scripts, ...

It is possible to source the configuration from shell scripts, ...

👆

@haraldh haraldh closed this as completed Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Our bugs
Projects
None yet
Development

No branches or pull requests

3 participants